在用戶端通過廣播方式發送資料包,尋找dhcp伺服器,dhcp伺服器收到用戶端的資料包,從ip池選擇一個尚未配置設定的ip給用戶端,當有多台伺服器向其發送ip時,用戶端随機選擇,用戶端以廣播形式宣告他所使用的ip,其他伺服器接收後,釋放欲配置設定給他的ip
在desktop裡
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR0=172.25.254.102
PREFIX0=24
IPV6INIT=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=yes
PERSISTENT_DHCLIENT=1

[[email protected] ~]# systemctl restart network
[[email protected] ~]# yum search dhcp #查找dhcp軟體
Loaded plugins: langpacks
============================== N/S matched:dhcp===============================
dhcp-common.x86_64 : Common files used by ISC dhcp client and server
dhcp-libs.i686 : Shared libraries used by ISC dhcp client and server
dhcp-libs.x86_64 : Shared libraries used by ISC dhcp client and server
dhclient.x86_64 : Provides the ISC DHCP client daemon and dhclient-script
dhcp.x86_64 : Dynamic host configuration protocol software
dnsmasq.x86_64 : A lightweight DHCP/caching DNS server
Name and summary matches only, use "search all" for everything.
[[email protected] ~]# yum install dhcp.x86_64 -y #下載下傳dhcp軟體
complete!
[[email protected] ~]# cd /etc/dhcp/
[[email protected] dhcp]# ls
dhclient.d dhcpd6.conf dhcpd.conf
[[email protected] dhcp]# vim dhcpd.conf
複制檔案名
cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[[email protected] dhcp]# vim dhcpd.conf #編寫配置檔案dhcp的規則
7 option domain-name "example.com"; #域名
8 option domain-name-servers 114.114.114.114; #客戶主機獲得dns
10 default-lease-time 600; #預設租約期
11 max-lease-time 7200; #最長租約期
26
27 #27.28删除
28 # This is a very basic subnet declaration.
29
30 subnet 172.25.254.0 netmask 255.255.255.0 { #subnet代表網絡位,netmask代表子網子網路遮罩
31 range 172.25.254.200 172.25.254.210; #range代表位址池,即可擷取ip的範圍
32 option routers 172.25.254.250; #客戶主機可擷取的網關
33 }
34 #34行以後删除
systemctl start dhcpd
systemctl enable dhcpd
拔掉網線
在真機裡
rht-vmctl reset server
rht-vmctl view server
在server虛拟機裡
ifconfig
位址已經被配置,dhcp配置完成。