DHCP:Dynamic Host Configuration Protocol前身是bootplease:租约续租:租约到一半的时候就要申请续租广播:第一个响应的服务器广播申请,广播响应广播回复确认
DHCP:Dynamic Host Configuration Protocol前身是bootplease:租约续租:租约到一半的时候就要申请续租广播:第一个响应的服务器广播申请,广播响应广播回复确认IP:MASK:GATEWAY:DNS:Client----->DHCPDISCOVER DHCPOFER<--------ServerClient----->DHCPREQUEST DHCPACK<-----Server以上都广播报文续租:Client----->DHCPREQUEST DHCPACK<-------Server以上为单播DHCP不能跨网段进行需要配置路由器的DHCP-RELAY,DHCP中继DHCP分配的网段要在某一个网卡的地址在同一网段内[root@salt-master ~]# yum install dhcpLoaded plugins: fastestmirrorSetting up Install ProcessLoading mirror speeds from cached hostfileiso | 3.7 kB 00:00 Not using downloaded repomd.xml because it is older than what we have: Current : Mon May 23 07:51:24 2016 Downloaded: Sun May 22 13:52:33 2016Resolving Dependencies--> Running transaction check---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed--> Finished Dependency ResolutionDependencies Resolved=========================================================================================================================================================================================== Package Arch Version Repository Size===========================================================================================================================================================================================Installing: dhcp x86_64 12:4.1.1-51.P1.el6.centos iso 823 kTransaction Summary===========================================================================================================================================================================================Install 1 Package(s)Total download size: 823 kInstalled size: 1.9 MIs this ok [y/N]: yDownloading Packages:dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm | 823 kB 00:00 Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum. Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Verifying : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Installed: dhcp.x86_64 12:4.1.1-51.P1.el6.centos Complete![root@salt-master ~]# rpm -ql dhcp/etc/dhcp/etc/dhcp/dhcpd.conf/etc/dhcp/dhcpd6.conf/etc/openldap/schema/dhcp.schema/etc/portreserve/dhcpd/etc/rc.d/init.d/dhcpd/etc/rc.d/init.d/dhcpd6/etc/rc.d/init.d/dhcrelay/etc/rc.d/init.d/dhcrelay6/etc/sysconfig/dhcpd/etc/sysconfig/dhcpd6/etc/sysconfig/dhcrelay/etc/sysconfig/dhcrelay6/usr/bin/omshell/usr/sbin/dhcpd/usr/sbin/dhcrelay/usr/share/doc/dhcp-4.1.1/usr/share/doc/dhcp-4.1.1/3.0b1-lease-convert/usr/share/doc/dhcp-4.1.1/IANA-arp-parameters/usr/share/doc/dhcp-4.1.1/README.ldap/usr/share/doc/dhcp-4.1.1/api+protocol/usr/share/doc/dhcp-4.1.1/dhclient-tz-exithook.sh/usr/share/doc/dhcp-4.1.1/dhcpd-conf-to-ldap/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/usr/share/doc/dhcp-4.1.1/dhcpd6.conf.sample/usr/share/doc/dhcp-4.1.1/draft-ietf-dhc-ldap-schema-01.txt/usr/share/doc/dhcp-4.1.1/ms2isc/usr/share/doc/dhcp-4.1.1/ms2isc/Registry.perlmodule/usr/share/doc/dhcp-4.1.1/ms2isc/ms2isc.pl/usr/share/doc/dhcp-4.1.1/ms2isc/readme.txt/usr/share/doc/dhcp-4.1.1/sethostname.sh/usr/share/doc/dhcp-4.1.1/solaris.init/usr/share/man/man1/omshell.1.gz/usr/share/man/man5/dhcpd.conf.5.gz/usr/share/man/man5/dhcpd.leases.5.gz/usr/share/man/man8/dhcpd.8.gz/usr/share/man/man8/dhcrelay.8.gz/var/lib/dhcpd/var/lib/dhcpd/dhcpd.leases/var/lib/dhcpd/dhcpd6.lease[root@salt-master ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf cp: overwrite `/etc/dhcp/dhcpd.conf'? yDHCP-Server:UDP/67DHCP-Client:UDP/68[root@salt-master ~]# vim /etc/dhcp/dhcpd.conf option domain-name "uplooking.com";option domain-name-servers 192.168.1.200;default-lease-time 600;max-lease-time 7200;log-facility local7;subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; option time-offset -18000; range 192.168.1.220 192.168.1.223; default-lease-time 21600; max-lease-time 43200;}[root@salt-master ~]# /etc/init.d/dhcpd startStarting dhcpd: [ OK ][root@salt-master ~]# netstat -anutlp|grep dhcpudp 0 0 0.0.0.0:67 0.0.0.0:* 2085/dhcpd 找一台服务器由于多个dhcp的存在他可能不会选则自己的服务器或者你想给服务器指定IP地址[root@salt-master ~]# vim /etc/dhcp/dhcpd.conf option domain-name "uplooking.com";option domain-name-servers 192.168.1.200;default-lease-time 600;max-lease-time 7200;log-facility local7;subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; option time-offset -18000; range 192.168.1.223 192.168.1.224; default-lease-time 21600; max-lease-time 43200; host ns2 { hardware ethernet 00:0C:29:38:1E:F7; fixed-address 192.168.1.201; }}添加host选项注意这个地址一定部在range的范围之内另外有专用的话等级比自动分配要高客户端[root@salt-master ~]# dhclient -hInternet Systems Consortium DHCP Client 4.1.1-P1Copyright 2004-2010 Internet Systems Consortium.All rights reserved.For info, please visit https://www.isc.org/software/dhcp/Usage: dhclient [-4|-6] [-SNTP1dvrx] [-nw] [-p <port>] [-s server] [-cf config-file] [-lf lease-file][-pf pid-file] [-e VAR=val] [-I <dhcp-client-identifier>] [-B] [-H <host-name> | -F <fqdn.fqdn>] [-timeout <timeout>] [-V <vendor-class-identifier>] [-R <request option list>] [-sf script-file] [interface]客户端直接dhclient命令就可以用了手动获取dhcp分配地址dhclient -d选项工作在前台