dhcp服務
安裝包:dhcp-3.0.5-31.el5.i386.rpm
配置文件:/etc/dhcpd.conf
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
啓動服務:service dhcpd restart
日誌文件:/var/log/messages
tail -f /var/log/messages
實現原理
C S
-----DHCPDISCOVER------->
<----DHCPOFFER-----------
-----DHCPREQUEST-------->
<----DHCPACK-------------
配置過程
subnet 10.10.10.0 netmask 255.255.255.0 { --------------確定網段
option routers 10.10.10.10; -----分配網關
option subnet-mask 255.255.255.0;
option domain-name-servers 202.106.0.20; ------分配DNS
range dynamic-bootp 10.10.10.100 10.10.10.200; ---分配ip地址段
default-lease-time 21600;
max-lease-time 43200;
}
service dhcpd restart
測試
客戶端 設置網卡爲dhcp 虛擬機(host-only)
ifconfig eth0
route -n
租約文件位置
服務端/var/lib/dhcpd/dhcpd.leases
客戶端/var/lib/dhclient/dhclient.leases
指定ip地址分配
host ns {
next-server marvin.redhat.com;
hardware ethernet 00:0C:29:58:EC:A2;
fixed-address 10.10.10.110;
}
host ns1 {
next-server marvin.redhat.com;
hardware ethernet 00:0C:29:58:GF:B2;
fixed-address 10.10.10.120;
}
多網段分配ip(兩塊網卡)
DHCP
ddns-update-style interim;
ignore client-updates;
subnet 10.10.10.0 netmask 255.255.255.0 {
option routers 10.10.10.1;
option subnet-mask 255.255.255.0;
option domain-name "domain.org";
option domain-name-servers 202.106.0.20;
range dynamic-bootp 10.10.10.100 10.10.10.101;
default-lease-time 21600;
max-lease-time 43200;
}
subnet 100.100.100.0 netmask 255.255.255.0 {
option routers 100.100.100.1;
option subnet-mask 255.255.255.0;
option domain-name "domain.org";
option domain-name-servers 202.106.0.20;
range dynamic-bootp 100.100.100.100 100.100.100.101;
default-lease-time 21600;
max-lease-time 43200;
}
service dhcpd restart