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