首页 > 其他 > 详细

dhcp

时间:2014-02-07 23:44:31      阅读:793      评论:0      收藏:0      [点我收藏+]

DHCP:

先有client端发出discovery message

D:255.255.255.255

S:0.0.0.0  代表未知IP或默认路由


SERVER发送OFFER message 广播报文


client发送request message 该报文应用于有多个sever的情况下

该报文有两个作用:

1、当做ack

2、让另一个server回收地址


acknowledgment message是server端的确认报文

l2+ip+udp+bootstrap+dhcp+fcs  dhcp只用在以太网环境


bubuko.com,布布扣

按上图做一个DHCP实验:

R1:

interface f0/0

ip address 192.168.1.1 255.255.255.0

no shut

!

service dhcp

ip dhcp pool ip_pool

network 192.168.1.0 /24

default-router 192.168.1.1

dns-server 61.147.37.1 61.177.7.1

lease 1

!

ip dhcp excluded-address 192.168.1.1

ip dhcp excluded-address 192.168.1.254


R2:

interface f0/1

no shut

no ip address

ip address dhcp


R2获取地址是地址池里最小的开始分配


如果你想查看R1的dhcp池的分配情况,可以用这个命令:show ip dhcp binding

R1#show ip dhcp binding

Bindings from all pools not associated with VRF:

IP address          Client-ID/              Lease expiration        Type

                   Hardware address/

                   User name

192.168.1.2         0063.6973.636f.2d63.    Mar 02 2002 12:10 AM    Automatic

                   3030.312e.3133.6663.

                   2e30.3030.312d.4661.

                   302f.31

我们查看下抓包结果吧

1、就是discovery message

bubuko.com,布布扣

2、offer message

bubuko.com,布布扣

3、request message

bubuko.com,布布扣

4、ack message

bubuko.com,布布扣

ip dhcp excluded-address low_ip  hight_ip 定义一个例外地址范围

R2上可以获取默认路由的show ip route

R2#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

      D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

      N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

      E1 - OSPF external type 1, E2 - OSPF external type 2

      i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

      ia - IS-IS inter area, * - candidate default, U - per-user static route

      o - ODR, P - periodic downloaded static route


Gateway of last resort is 192.168.1.1 to network 0.0.0.0


C    192.168.1.0/24 is directly connected, FastEthernet0/1

S*   0.0.0.0/0 [254/0] via 192.168.1.1


helper-address client和server不在同一个子网的情况下,需要help address

过程如下:

当设备接收到一个广播报文,如果配置了help address 就把该报文的目的地址改为help address

变成单播报文,发送到指定IP地址


DHCP扩展应用helper-address

bubuko.com,布布扣

R1和R2之间链路的配置不变

R2:

interface f0/0

ip address 192.168.2.2 255.255.255.0

ip helper-address 192.168.1.1

no shut

R3:

interface f0/1

no shutdown

ip address dhcp

R1:

ip dhcp excluded-address 192.168.2.1 192.168.2.2

ip dhcp excluded-address 192.168.2.254

ip dhcp pool wolf

network 192.168.2.0 /24

default-router 192.168.2.1

dns-server 8.8.8.8

lease 1


在R3上show ip interface brief,我们发现没有IP地址被获取哦!

为什么呢?可能是路由问题吗?

在R1上show ip route 只有直连路由

手动写一条静态路由ip route 192.168.2.0 255.255.255.0 f0/0

过一会儿,我们发现R3获取IP地址了

我们抓包看看问题出在哪里

bubuko.com,布布扣

知道问题了吧,discovery offer request ack 报文都变成了单播报文了

而R1没有到192.168.2.0 的路由条目,所以报文送不到R3



dhcp

原文:http://867645.blog.51cto.com/857645/1357124

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!