CentOS 6.5配置和使用DHCPD
[root@i-it ~]# yum install dhcp [root@i-it ~]# rpm -Uvh dhcp-4.1.1-31.P1.el6.x86_64.rpm [root@i-it ~]# cat /etc/dhcp/dhcpd.conf ddns-update-style interim; #配置使用DHCP-DNS动态更新模式。 ignore client-updates; #忽略客户端更新 subnet 10.204.10.0 netmask 255.255.255.0 { #作用域 option routers 10.204.10.250; #路由器地址(Gateway) option subnet-mask 255.255.255.0; #子网掩码选项 option nis-domain "i-it.info"; option domain-name "i-it.info"; #域名 option domain-name-servers 8.8.8.8; #DNS地址 option time-offset -18000; #为客户端设定格林威治时间的偏移时间,单位是秒 range dynamic-bootp 10.204.10.251 10.204.10.253; #租用IP地址的范围 default-lease-time 21600; #缺省租约时间 max-lease-time 43200; #最大租约时间 # we want the nameserver to appear at a fixed address host i-it { #主机声明 hardware ethernet 00:0C:29:30:2D:D7; #保留主机的MAC地址 fixed-address 10.204.10.204; #指定保留的IP地址 } } [root@i-it ~]# ls /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample [root@i-it ~]# service dhcpd start Starting dhcpd: [ OK ] [root@i-it ~]# netstat -panu | grep dhc* udp 0 0 0.0.0.0:67 0.0.0.0:* 3472/dhcpd udp 0 0 0.0.0.0:68 0.0.0.0:* 1398/dhclient [root@i-it ~]# cat /var/lib/dhcpd/dhcpd.leases # The format of this file is documented in the dhcpd.leases(5) manual page. # This lease file was written by isc-dhcp-4.1.1-P1 server-duid " 00 01 00 01 32327'a 00 14)0-327"; lease 10.204.10.251 { starts 2 2014/04/08 21:48:34; ends 3 2014/04/09 03:48:34; cltt 2 2014/04/08 21:48:34; binding state active; next binding state free; hardware ethernet 00:0c:29:cc:de:94; } [root@i-it dhcpd]# grep -o '<[0-9]{1,3}.[0-9]{1,3}>' dhcpd.leases 10.204.10.251 10.204.10.251 [root@i-it dhcpd]# grep -o '<[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}>' dhcpd.leases 00:0c:29:cc:de:94 00:0c:29:cc:de:94 [root@i-it dhcpd]# tail -n +15 dhcpd.leases |less|awk 'BEGIN{RS=ORS="}"}{print $2,$25,"n"}'|sed 's |
