自动获取地址,在windows下肯定很简单吧 ,真正如何实现的想知道吗?看完本文就会了,好好学习吧。。



服务管理

dhcp (动态ip地址分配)

安装包

dhcp-3.0.5-31.el5.i386.rpm

启动服务

service dhcpd restart


配置文件

/etc/dhcpd.conf

cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf


----------------------------------


subnet 192.168.1.0 netmask 255.255.255.0 { 设置的网断

option routers 192.168.1.2; 网关

option subnet-mask 255.255.255.0; 子网眼玛

option domain-name-servers 202.106.0.20; DNS

range dynamic-bootp 192.168.1.1 192.168.1.254; 分配的范围 从大往小走

default-lease-time 21600; 租期时间

max-lease-time 43200; 超过这个租约就失效


帮定物理地址

host ns {

27 next-server marvin.redhat.com;

28 hardware ethernet 12:34:56:78:AB:CD; 帮定的物理地址

29 fixed-address 207.175.42.254; 要设定的地址



-----------------------------------------


原理:

C(客户端) S(服务器)

---DHCPDISCOVER---> 发现

<--DHCPOFFER-------回应

---DHCPREQUEST----> 请求租约时间

<--DHCPACK---------确定租约


------------------------------

服务端租约 vim/var/lib/dhcpd/dhcpd.lease

客户端租约 vim/var/lib/dhclient/chclient-eth0.lease


----------------------

DHCP的中继服务器

作用: 用两个DHCP服务器划分两个不同网断的主机们 其中一台服务器作中继

DHCP端


ddns-update-style interim;

ignore client-updates;

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers 192.168.1.2;

option subnet-mask 255.255.255.0;

option domain-name-servers 202.106.0.20;

range dynamic-bootp 192.168.1.1 192.168.1.254;

default-lease-time 21600;

max-lease-time 43200;

}

subnet 192.168.0.0 netmask 255.255.255.0 {

option routers 192.168.0.1;

option subnet-mask 255.255.255.0;

option domain-name-servers 202.106.0.20;

range dynamic-bootp 192.168.0.2 192.168.0.254;

default-lease-time 21600;

max-lease-time 43200;

}




中继端

vim /etc/sysconfig/dhcrelay 主配置文件

1 # Command line options here

2 DHCRELAYARGS=""

3 INTERFACES="eth0 eth1" 开启中继 指向那(两块网卡来作中继)

4 DHCPSERVERS="192.168.147.1" DHCP服务器地址


service dhcrelay restart 启动服务