#yum install dhcp -y
#rpm -ql dhcp
------------------------
/etc/dhcp/dhcpd.conf 主配置文件
/etc/rc.d/init.d/dhcpd 启动脚本
/var/lib/dhcpd/dhcpd.leases 租约文件
/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
配置文件的样例文件
#cat /etc/dhcp/dhcpd.conf
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
#vi /etc/dhcp/dhcpd.conf
--------------------
#ddns-update-style none;
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.254.50 172.16.254.99;
}
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}
--------------------
service dhcpd start
#netstat -antulp | grep :67
客户端可以使用
dhclient -r -v //释放IP地址
dhclient -v //获取地址
---windows---
ipconfig /release 释放
ipconfig /renew 获取
------------------------
#ddns-update-style none;
#option domain-name "example.org";
option domain-name-servers 172.16.254.101; //指定域名服务器
option routers 172.16.254.101; //指定网关
#option nis-domain "domain.org";
#option ntp-servers 172.16.254.101;
default-lease-time 600;
max-lease-time 7200;
subnet 172.16.0.0 netmask 255.255.0.0 {
range 172.16.254.51 172.16.254.99;
}
host srv166 { 根据MAC地址进行IP定向分配
hardware ethernet 00:0C:29:C4:7B:C4;
fixed-address 172.16.254.166;
}
获取一个主机的mac地址,可以通过
#arping IP
查看默认网关
#route -n
查看是否获取到DNS服务器信息
#cat /etc/resolv.conf
服务器端查看租约文件
cat /var/lib/dhcpd/dhcpd.leases
客户端查看租约信息
cat /var/lib/dhclient/dhclient-eth0.leases