Linux DHCP服务器简单配置示例
1、DHCP安装及配置
yum install dhcp
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
option domain-name "redhat.com";
option domain-name-servers 202.96.128.166, 114.114.114.114; # 设置DNS
default-lease-time 3600; # 默认租约时间,单位秒
max-lease-time 7200; # 最大租约时间,单位秒
log-facility local7; # 日志级别
subnet 192.168.101.0 netmask 255.255.255.0 {
range 192.168.101.150 192.168.101.180; # DHCP可获取的IP地址范围
option routers 192.168.101.254; # 网关
option subnet-mask 255.255.255.0; # 子网掩码
host test {
hardware ethernet 00:0C:29:6F:38:E4; # 绑定主机的MAC地址
fixed-address 192.168.101.208; # 绑定的IP
}
}
2、启动DHCP服务
service dhcpd restart
3、查看DHCP客户端状态
cat /var/lib/dhcpd/dhcpd.leases
cat /var/lib/dhcpd/dhcpd.leases~
dhclient:获取地址
-d:在前台运行并显示获取过程
-r:释放地址
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。