DHCP服务的配置,下载最新版DHCPD:
1
| wget http://ftp.isc.org/isc/dhcp/dhcp-4.1.1b1.tar.gz
|
解压、安装、配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| [root@localhost src]# tar -zxvf dhcp-4.1.1b1.tar.gz [root@localhost src]# cd dhcp-4.1.1b1 [root@localhost dhcp-4.1.1b1]# configure [root@localhost dhcp-4.1.1b1]# make;make install [root@localhost ~]# vi /etc/dhcpd.conf ddns-update-style none; subnet 192.168.1.0 netmask 255.255.255.0{ range 192.168.1.200 192.168.1.254; ignore client-updates; default-lease-time 3600; max-lease-time 7200; option routers 192.168.1.1; option domain-name"qiufeng.cc"; option domain-name-servers 192.168.1.126; } host c1{ hardware ethernet 00:E0:4E:70:33:65; fixed-address 192.168.1.222; } [root@localhost ~]# touch /var/state/dhcp/dhcpd.leases //新建租约文件 [root@localhost ~]# vi /etc/sysconfig/dhcpd //设置DHCP守护进程的工作参数 DHCPDARGS=eth0(设置DHCP守护进程监听网卡接口)
|
下面如何启动呢、我们可以新建个启动脚本. 很简单修改下就行了……
1 2 3 4 5 6 7 8 9
| $cd /etc/rc.d/init.d/ $cp atd dhcpd //我们拷贝atd为dhcpd $vi dhcpd //把里面的所有atd修改为dhcpd $chkconfig --add dhcpd //加载启动项dhcpd $service dhcpd start //启动DHCPD [root@localhost ~]# pstree|grep dhcpd |-dhcpd [root@localhost ~]# netstat -nlt udp 0 0 0.0.0.0:67 0.0.0.0:*
|
启动成功…..
1.Linux客户端
设置网卡采用dhcp启动协议,自动获取ip地址信息:
1
| $vi /etc/sysconfig/network-scripts/ifcfg-ethX(X可以0,1,2……)
|
修改BOOTPROTO为:
获取IP地址:
1
| $ifdown ethX ;ifup ethX (X可以取0,1,2,……)
|
注意:
linux系统的dhcp客户端使用dhclient脚本来获取IP地址信息.
2.Windows客户端
右击网上邻居—-属性——双击tcp/ip协议—-选择”自动获动IP地址”.
1 2
| c:>ipconfig/release c:>ipconfig/renew
|
测试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| C:>ipconfig/all Windows IP Configuration Host Name . . . . . . . . . . . . : 20090315-0851 Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Unknown IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : qiufeng.cc Ethernet adapter 本地连接: Connection-specific DNS Suffix . : qiufeng.cc Description . . . . . . . . . . . : Realtek RTL8139/810x Family Fast Eth ernet NIC Physical Address. . . . . . . . . : 00-0A-EB-79-9C-20 Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.1.211 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.126 DNS Servers . . . . . . . . . . . : 192.168.1.126 Lease Obtained. . . . . . . . . . : 2009年4月18日 星期六 17:41:41 Lease Expires . . . . . . . . . . : 2009年4月18日 星期六 18:41:41
|
OK成功……