[root@kvm8 ~]# yum install dhcp
[root@kvm8 ~]# cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample
{}
外的參數為全體設定
#
後的文字為註解
ddns-update-style none; # 支援 ddns (Dynamic DNS) 更新 IP, # 這個選項一定要存在才不會有錯誤。 option space PXE; # 定義選項空間給 PXE
class "PXE" { # 如果 dhcp client 的 vendor-class-identifier 為 PXEclient match if substring(option vendor-class-identifier, 0, 9) = "PXEClient"; # vendor-encapsulated-options (廠商封裝選項) 允許 vendors 定義自己的選項 option vendor-encapsulated-options 01:04:00:00:00:00:ff; option boot-size 0x1; # PXEclient 讀取的檔案, tftp 已經 chroot filename "pxelinux.0"; # 指定 tftp server option tftp-server-name "deyu.wang"; # pxe client 回應 dhcp server vendor-class-identifier 為 "PXEClient" # 若此選項不設定 pxe client 不回應 dhcp server vendor-class-identifier option vendor-class-identifier "PXEClient"; # vendor-option-space 宣告,告訴 DHCP server 使用 PXE option space # 去建構 vendor-encapsulated-options 選項 vendor-option-space PXE; }
subnet 192.168.1.0 netmask 255.255.255.0 { # The following lines are standard all of the time. option routers 192.168.1.254; option subnet-mask 255.255.255.0; option domain-name "deyu.wang"; option domain-name-servers 168.95.1.1,139.175.10.20; default-lease-time 21600; # 預設租期時間長度(秒) max-lease-time 43200; # 租期到可續租,但最大租期長度(秒) }
[root@e517nat ~]# grep dyw /etc/dhcp/dhcpd.conf -A4 host dywhd1 { hardware ethernet 00:E0:4C:4E:7A:F5; fixed-address 192.168.1.140; }
# Assign IPs 10-99 to PXE clients pool { allow members of "PXE"; default-lease-time 120; max-lease-time 180; range 192.168.1.10 192.168.1.99; } pool { deny members of "PXE"; range 192.168.1.100 192.168.1.139; range 192.168.1.141 192.168.1.199; }
host teacher { option host-name "teacher.deyu.wang"; hardware ethernet 3C:D9:2B:5E:8C:62; fixed-address 192.168.1.14; }
[root@kvm8 ~]# cat /etc/sysconfig/dhcpd # Command line options here DHCPDARGS="eth1"
# The following lines are examples of kickstart directives. next-server 192.168.1.254; filename "ftp://192.168.1.254/pub/centos6/add/crt-ks.cfg";
[root@kvm8 ~]# vim /etc/sysconfig/dhcpd [root@kvm8 ~]# cat /etc/sysconfig/dhcpd # Command line options here DHCPDARGS="eth0"
[root@kvm8 ~]# /etc/init.d/dhcpd restart
[root@kvm8 ~]# chkconfig dhcpd on