
[root@localhost ~]# vi /etc/dhcpd.conf
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
当步入到配置文档上面时,这儿是空的,有如上一行的提示,说可以参考这个文档来编写配置文档,那就复制一份再编辑。
[root@localhost ~]# cp -rvf /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@localhost ~]# vi /etc/dhcpd.conf
ddns-update-style interim;//配置DHCP和DNS为互动更新模式,
ignore client-updates;//忽略客户端的更新。
subnet 192.168.100.0 netmask 255.255.255.0 {//定义作用域
option routers192.168.100.1;//默认路由
option subnet-mask255.255.255.0; //子网掩码
option nis-domain"rhel.com";//NIS域名
option domain-name"rhel.com";//DNS域名
option domain-name-servers192.168.100.10; //DNS服务器地址
option time-offset-18000; # Eastern Standard Time//为客户端设置与格林威治的时间偏移
option ntp-servers192.168.1.1;//网络时间服务器地址
option netbios-name-servers192.168.1.1;//指定WINS服务器地址
range dynamic-bootp 192.168.100.128 192.168.100.254;//动态分配的地址范围
default-lease-time 21600;//默认租约时间

max-lease-time 43200;//最大租约时间
host abc {//指定特殊主机
hardware ethernet 00:C:29:FD:44:C8;//设备地址
fixed-address 192.168.100.30;//IP地址
}
}
如有多个要绑定的主机时可以把所有主机信息用group{ }包括起来,如此更方便管理。格式如下 :
group {
……这里不可以添加一些佤全局选项,如此就不用在每位上面写了。
host abc {
……
……
}
host xyz {
……
……
}
}

[root@localhost ~]# service dhcpd restart
检测:
在linux下:
首先让地址从DHCP获取:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
[root@localhost ~]# service network restart//重启一下网络服务,这儿不能使用ifdown和ifupbootp和dhcp怎么设置bootp和dhcp怎么设置,因为要配置路由信息。
[root@localhost ~]# ifconfig
eth0Link encap:Ethernet HWaddr 00:C:29:FD:44:C8
inet addr:192.168.100.30 Bcast:192.168.100.255 Mask:255.255.255.0
这就是绑定的IP地址。
[root@localhost ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search rhel.com
nameserver 192.168.100.10
这里的DNS服务器地址也获取到了。
[root@localhost ~]# route -n

Kernel IP routing table
DestinationGatewayGenmaskFlags Metric Ref Use Iface
192.168.100.0 0.0.0.0255.255.255.0 U000 eth0
169.254.0.00.0.0.0255.255.0.0U000 eth0
0.0.0.0192.168.100.1 0.0.0.0UG 000 eth0
默认路由也获取到了。查看一下端口:
[root@localhost ~]# netstat -tlunp | grep 68
udp 0 0 0.0.0.0:68 0.0.0.016150/dhclient
察看客户端的租约文件:
lease {
interface "eth0";
fixed-address 192.168.100.30;//固定地址
option subnet-mask 255.255.255.0;//子网掩码
option time-offset -18000;//时间偏移
option routers 192.168.100.1;//默认路由
option dhcp-lease-time 21600;//租约时间
option dhcp-message-type 5;
option domain-name-servers 192.168.100.10;

option dhcp-server-identifier 192.168.100.20;
option nis-domain "rhel.com";
option domain-name "rhel.com";
renew 5 2010/4/9 09:01:40;
rebind 5 2010/4/9 11:34:53;
expire 5 2010/4/9 12:19:53;
}
windows下:
把IP地址设成自动获取。
C:\Documents and Settings\Administrator>ipconfig /all
Connection-specific DNS Suffix . : rhel.com
Physical Address. . . . . . . . . : 00-0C-29-D3-C6-B3
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 192.168.100.253
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.100.1
DHCP Server . . . . . . . . . . . : 192.168.100.20
DNS Servers . . . . . . . . . . . : 192.168.100.10
Lease Obtained. . . . . . . . . . : 2010年4月9日 14:44:12
Lease Expires . . . . . . . . . . : 2010年4月9日 20:44:12
完全配置完成。
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-119078-1.html
对于强盗
楼主是张少将徒弟
玩它一玩