DHCP服务

动态主机配置协议
主要分配以下参数:
1.IP地址
2.子网掩码
3.广播地址
4.默认网关地址
5.DNS服务器地址

DHCP地址分配的四次会话:
DISCOVERY-->OFFER-->REQUEST-->ACK

步骤:
1.装软件包dhcp
yum -y install dhcp

2.配置文件路径/etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
:r /usr/share/doc/dhcp/dhcp.conf.example
(vim末行模式r:读取/usr/share/doc/dhcp/dhcp.conf.example文件)

subnet 192.168.4.0 netmask 255.255.255.0 {
(分配192.168.4.0网段)

range 192.168.4.1 192.168.4.254;
(分配的IP地址池)

option domain-name-server 8.8.8.8;
(配置DNS)

option routers 192.168.4.254;
(配置网关)

default-lease-time 600;
(IP地址默认租用时间)

max-lease-time 7200;
(IP地址租用最大时间)
}

3.起服务dhcpd
systemctl restart dhcpd

4.查看端口号67
netstat -lntpu | grep :67