DHCP服务的配置及故障排除
DHCP服务介绍
可以为相同局域网内的客户端,动态分配ip地址,子掩码,网关和DNS
端口协议:UDP 67
UDP 68 一个负责发送,一个负责接收
配置文件路径: /etc/dhcpd/dhcpd.conf
示例文件 (/usr/share/doc/dhcp*/dhcpd.conf.example
)
日志文件路径: /var/log/messages
安装说明
yum install dhcp* -y
配置说明
1.先关闭防火墙,selinux,NetworkManager
2.vi /etc/dhcp/dhcpd.conf # 进入dhcp配置服务
.:r /usr/share/doc/dhcp*/dhcpd.conf.example // r 引入示例文档
// set nu 产生行编号
//37,$ s/^/#/ 从37行到末尾添加注释
3.编辑配置文件内容
option definitions common to all supported networks…
option domain-name “wayne.yeoman.com”; // 更改域名
option domain-name-servers 8.8.8.8; // 更改dns
default-lease-time 600;
max-lease-time 7200; // 保留租约时间
将没注释掉的注释掉
subnet 172.16.0.0 netmask 255.255.0.0 { // 设置网号子掩码
range dynamic-bootp 172.16.14.10 172.16.14.20; // 设备dhcp分配范围
option routers 192.168.0.254; // 设置网关
}
4.systemctl start dhcpd 开启dhcp服务
systemctl enable dhcpd 设备开机自动启动服务
[root@wayne dhcp]# netstat -antlup | grep :67 // 查看67端口是否产生
udp 0 0 0.0.0.0:67 0.0.0.0:* 5904/dhcpd
udp 0 0 0.0.0.0:67 0.0.0.0:* 1231/dnsmasq
5.查看dhcp服务是否开启,看状态 systemctl status dhcpd
查看firewalld 服务是否开启,看systemctl status firewalld
看67端口是否有dhcp 67端口 netstat -antlup | grep :67
故障排除:
提示如下,表示配置文件写错了
[root@localhost ~]# systemctl restart dhcpd
Job for dhcpd.service failed because the control process exited with error code. See “systemctl status dhcpd.service” and “journalctl -xe” for details.
解决方法:查看配置文件是否有没注释掉的符号,或者行