centos6.5 DHCP服务的配置
yum -y install dhcp
1.DHCP的主配置文件
(1) vim /etc/dhcp/dhcpd.conf
subnet 192.168.3.0netmask 255.255.255.0{
range192.168.3.100 192.168.3.200;
option domain-name-servers 202.106.0.20;
option domain-name "internal.example.org";
option routers192.168.3.254;
option broadcast-address 192.168.3.255;
default-lease-time 600;
max-lease-time 7200;
}
dhcp服务的重启
service dhcpd restart
或/etc/rc.d/init.d/dhcpd restart
(2)IP地址保留
vim /etc/dhcp/dhcpd.conf
host lpc {保留的名称
hardware ethernet 00:c0:c3:22:46:81;指定对应主机的 MAC 地址
fixed-address192.168.3.250;指定为该主机保留的 IP 地址
}
dhcp服务的重启
service dhcpd restart
或/etc/rc.d/init.d/dhcpd restart
2.查看DHCP服务器的租约文件 /var/lib/dhcpd/dhcpd.lease
less /var/lib/dhcpd/dhcpd.leases
3.客户端获取和释放IP
首先将网卡的配置文件改为自动获取(dhcp)
dhclient
为除了回环接口以外的所有接口获取ip,自动调动后台运行
dhclient -d eth0
-d 在前台运行
dhclient -d eth0
-r 释放IP