先輸入下方指令安裝dhcp
yum install -y dhcp
輸入下方指令編輯配置檔
vim /etc/dhcp/dhcpd.conf
配置檔:
ddns-update-style interim; ignore client-updates; #subnet = IP範圍, netmask = 遮罩 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.10 192.168.1.240; #IP Range option domain-name-servers 192.168.40.13; #DNS Server IP option domain-name "cy.local"; #DNS option routers 192.168.1.254; #閘道 default-lease-time 10000; #預設租約時間 max-lease-time 15000; #最長租約時間 }
輸入下方指令設定DHCP網卡:
vim /etc/sysconfig/dhcpd
設定完後就輸入下方指令啟動DHCP Server
service dhcp start
無法啟動可以查看/var/log/message
最常見錯誤可可能是網卡的IP與設定檔的IP不符合
配置檔可以參考/usr/share/doc/dhcp-???/dhcpd.conf.sample
參考資料:
http://linux.vbird.org/linux_server/0340dhcp.php