-
安裝 DHCP 套件:
#yum install dhcp
-
複製範例設定檔:
#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
-
編輯設定檔:
#vim /etc/dhcp/dhcpd.conf [...省略...] ### 設定子網段與 IP 位置配發範圍 ### subnet 192.168.5.0 netmask 255.255.255.0 { range 192.168.5.100 192.168.5.200; ### 指定 DNS IP 位置 ### option domain-name-servers 168.95.1.1, 8.8.8.8; ### 指定網域名稱 ### option domain-name "example.com"; ### 指定預設閘道與相關的路由協定 ### option routers 192.168.5.254; option broadcast-address 192.168.5.255; ### 指定租約更新時間 ### default-lease-time 600; max-lease-time 7200; } ### 指定特定主機的 IP 位置,避免該 IP 位置被配發出去 ### host mailserver { hardware ethernet 00:0C:29:05:A7:CB; fixed-address 192.168.5.110; } [...省略...]
-
啟動 DHCP Server:
#systemctl restart dhcpd #systemctl enable dhcpd
-
開啟防火牆設定:
#firewall-cmd --permanent --add-service=dhcp #firewall-cmd --reload
參考文獻:
- http://www.server-world.info/en/note?os=CentOS_7&p=dhcp
- http://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/install-and-configure-dhcp-server-on-centos-7-ubuntu-14-04.html