天天看點

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"            //重新加載網卡           

繼續閱讀