http://blog.csdn.net/lizhiqiang5846/article/details/46121339
1. 首先利用su命令切换到root用户。
输入命令:yum -y install dhcp安装dhcp 服务程序
2.安装成功后编辑/etc/dhcpd.conf文件(有可能是/etc/dhcp/dhcpd.conf),有如下注释:
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
所以可以cp /usr/share/doc/dhcp-4.0.0(依据实际情况的版本号)/dhcpd.conf.sample /etc/dhcpd.conf
vi /etc/dhcpd.conf添加:
#subnet 192.168.1.0 netmask 255.255.255.0{ #dhcp服务所在网段
#range 192.168.1.50 192.168.1.100; #分配地址范围
#default-lease-time 21600;#默认租约(6小时)
#min-lease-time 21600;#最短租约
#max-lease-time 21600;#最长租约
#option routers 192.168.1.1;#网关地址
#option domain-name-servers 192.168.1.254;#DNS地址
#}
subnet 172.29.11.0 netmask 255.255.255.0 {
range 172.29.11.50 172.29.11.100;
default-lease-time 43200;
min-lease-time 43200;
max-lease-time 43200;
option routers 172.29.11.60;
option domain-name-servers 172.29.1.200;
}
以上可以在文件中添加多个这样的片段,来做多个网段的DHCP服务器~
3. 保存退出后运行命令service dhcpd start启动dhcp服务器,若启动失败,可执行/usr/sbin/dhcpd, 按提示查看配置错误