DHCP服务器
http://ming228.blog.51cto.com/421298/110659
[root@localhost zzx]# rpm -qa |grep dhcp
dhcp-libs-4.2.5-27.el7.centos.2.x86_64
dhcp-common-4.2.5-27.el7.centos.2.x86_64
[root@localhost zzx]# yum install dhcp
已安装:
dhcp.x86_64 12:4.2.5-27.el7.centos.2
完毕!
[root@localhost zzx]# rpm -qa |grep dhcp
dhcp-4.2.5-27.el7.centos.2.x86_64
dhcp-libs-4.2.5-27.el7.centos.2.x86_64
dhcp-common-4.2.5-27.el7.centos.2.x86_64
[root@localhost dhcp-4.2.5]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp.conf #拷贝配置文件到etc下( 正确位置应该是 /etc/dhcp/dhcpd.conf 再次验证放/etc/dhcp.cof是无法启动的)
修改文件内容
subnet 192.168.56.0 netmask 255.255.255.0 { //dhcp网段和掩码
range 192.168.56.150 192.168.56.180; //dhcp范围
option domain-name-servers 8.8.8.8; //dns服务器地址
option routers 192.168.56.1; //客户端默认路由
}
host zabbix-PC { //ns的名字随便设置一个 不固定 就是一个计算机名 设置好固定ip需要重启dhcpd服务
hardware ethernet 00:0C:29:9A:33:bb; //需要设置固定ip的电脑的mac地址
fixed-address 192.168.56.22; //固定ip
}
按教程把配置文件考到/etc/下 结果启动时失败 提示 See 'systemctl status dhcpd.service'' 运行systemctl status dhcpd.service' 提示 Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled) 打开 /usr/lib/systemd/system/dhcpd.service 提示ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid 原来是位置不对 正确位置应该是 /etc/dhcp/dhcpd.conf
接着启动
[root@localhost zzx]# service dhcpd restart #修改文件内容后需要重启服务 否则无法生效 别把dhcpd和named搞混了
Redirecting to /bin/systemctl restart dhcpd.service
ps aux |grep dhcp 看到多了一项 dhcpd 7521 0.0 1.8 109256 18220 ? Ss 10:45 0:00 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid
说明启动成功
/var/lib/dhcpd/dhcpd.leases 临时租期数据库被写入 dhcpd.leases 文件
[root@nginx ~]# 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 "\000\001\000\001\037Pdv\000\014)|\"\306";
lease 192.168.1.5 {
starts 3 2016/08/24 13:58:25;
ends 3 2016/08/24 14:08:25;
cltt 3 2016/08/24 13:58:25;
binding state active;
next binding state free;
hardware ethernet 68:3e:34:48:1e:52;
client-hostname "zzx";
}