4-6·配置DHCP服务器

1)配置DHCP服务器

安装服务端

[root@localhost ~]# yum -y install dhcp                
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf 
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
option domain-name      "servera.example.com";              //本机域名(如果没有可以不写)

option domain-name-servers      "example.com";              //指向DNS(如果没有可以不写)

default-lease-time 600;             //租约(s)

max-lease-time 7200;                    //最大租约(s)

authoritative;

subnet 172.25.0.0 netmask 255.255.255.0 {
        range dynamic-bootp 172.25.0.100 172.25.0.200;
        option broadcast-address 172.25.0.255;
        option routers 172.25.0.1;
}
#设置网段,掩码
#分发地址范围
#广播地址
#路由地址
[root@localhost ~]# systemctl restart dhcpd                //重启服务
[root@localhost ~]# systemctl enable dhcpd             //开机自启
ln -s '/usr/lib/systemd/system/dhcpd.service' '/etc/systemd/system/multi-user.target.wants/dhcpd.service'

设置防火墙放行

[root@localhost ~]# firewall-cmd --add-service=dhcp --permanent 
success
[root@localhost ~]# firewall-cmd --reload 
success

2)配置客户端

确保UDP68端口可达网络

[root@localhost ~]# nmcli connection modify "System eth0" ipv4.method auto                 //将IP地址设置为自动获取
[root@localhost ~]# nmcli connection down "System eth0" ; nmcli connection up "System eth0"            //重新加载网卡

你可能感兴趣的:(Services)