rpm -q dhcp

yum install dhcp -y 

cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcp.conf.$(date +%F)

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

/etc/dhcpd.conf:

以下是我的DHCPd.conf 配置文件

default-lease-time 1296000;

max-lease-time 4000000;

option domain-name-servers 172.17.9.16,202.96.209.133;

option subnet-mask 255.255.240.0;

option broadcast-address 172.17.15.255;

option routers 172.17.10.254;  一般定义在sub-net 中,在某个段中生效。我这里就一个段就这样放在全局了。

option domain-name-servers 172.17.9.16;

ddns-update-style ad-hoc;

subnet 172.17.0.0 netmask 255.255.240.0 {

#定义IP池的内容

range 172.17.15.100 172.17.15.200;

}

host xingming {hardware ethernet 48:4D:7E:BE:4D:4F;fixed-address 172.17.0.76;}

查看dhcpd服务器分配的IP:

cat /var/lib/dhcpd/dhcpd.lease  IP已经分配的IP在此文件中;

/etc/init.d/dhcpd stop/start/restart 服务的启动和停止


注意:分配IP的还有 DNSMASQ 这个更轻量级.DHCP 重量级。