注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 利用手机和电池实现反地心..
 帮助

学习-ip dhcp 与参数分析


2007-06-21 12:13:50
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://skyyue.blog.51cto.com/159530/30979
  
 
 
DHCP Request for an IP Address from a DHCP Server
主机获取IP address的过程,我们可以 debug ip packet.

Note A DHCP client may receive offers from multiple DHCP servers and can accept any one of the offers; however, the client usually accepts the first offer it receives. Additionally, the offer from the DHCP server is not a guarantee that the IP address will be allocated to the client; however, the server usually reserves the address until the client has had a chance to formally request the address.

The client returns a formal request for the offered IP address to the DHCP server in a DHCPREQUEST broadcast message. The DHCP server confirms that the IP address has been allocated to the client by returning a DHCPACK unicast message to the client.

Note The formal request for the offered IP address (the DHCPREQUEST message) that is sent by the client is broadcast so that all other DHCP servers that received the DHCPDISCOVER broadcast message from the client can reclaim the IP addresses that they offered to the client.

If the configuration parameters sent to the client in the DHCPOFFER unicast message by the DHCP server are invalid (a misconfiguration error exists), the client returns a DHCPDECLINE broadcast message to the DHCP server.

The DHCP server will send to the client a DHCPNAK denial broadcast message, which means the offered configuration parameters have not been assigned, if an error has occurred during the negotiation of the parameters or the client has been slow in responding to the DHCPOFFER message (the DHCP server assigned the parameters to another client) of the DHCP server.
 
二。参数分析
PC1(config-if)#
*Apr 19 21:16:39.803: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast  //这是PC1向dhcp server获取IP address.采用广播
*Apr 19 21:16:40.119: IP: s=192.168.1.2 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1 //回复用的单播
*Apr 19 21:16:40.123: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast  //
*Apr 19 21:16:40.239: IP: s=192.168.1.2 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1
*Apr 19 21:16:41.755: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Apr 19 21:16:42.599: IP: s=172.16.1.1 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1 //因为存在两个DHCP server,
*Apr 19 21:16:42.755: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
*Apr 19 21:16:43.295: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.1.9, mask 255.255.255.0, hostname PC1   //可以看到现在PC1得到192.168.1.9的地址
 
PC1(config-if)#
*Apr 19 21:34:23.967: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast
*Apr 19 21:34:25.923: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Apr 19 21:34:26.923: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
*Apr 19 21:34:26.951: IP: s=192.168.1.2 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1  //因为PC1是最先收到192.168.1.2的地址。
*Apr 19 21:34:26.955: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast
*Apr 19 21:34:27.411: IP: s=172.16.1.1 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1
*Apr 19 21:34:27.447: IP: s=192.168.1.2 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1  //从上面可以看到PC1收192.168.1.2与172.16.1.1收过来的地址,而172.16.1.1先到收到,但为什么用了192.168.1.2发过来的地址呢?
*Apr 19 21:34:30.499: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.1.10, mask 255.255.255.0, hostname PC1
 
PC1(config-if)#
*Apr 19 21:38:30.339: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast
*Apr 19 21:38:30.699: IP: s=172.16.1.1 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1
*Apr 19 21:38:30.703: IP: s=0.0.0.0 (local), d=255.255.255.255 (FastEthernet0/0), len 604, sending broad/multicast
*Apr 19 21:38:30.891: IP: s=172.16.1.1 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1
*Apr 19 21:38:33.339: IP: s=192.168.1.2 (FastEthernet0/0), d=255.255.255.255, len 328, rcvd 1
*Apr 19 21:38:33.935: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 172.16.1.5, mask 255.255.255.0, hostname PC1   //得到的是172.16.1.0是地址
 
R3#sh ip dhcp pool
Pool xia :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0
 Total addresses                : 254
 Leased addresses               : 1   //租借时间分一天
 Pending event                  : none
 1 subnet is currently in the pool :
 Current index        IP address range                    Leased addresses
 172.16.1.6           172.16.1.1       - 172.16.1.254      1  //当前分配的是172.16.1.6的地址

本文出自 “skyyue” 博客,请务必保留此出处http://skyyue.blog.51cto.com/159530/30979





    文章评论
 
2007-06-21 19:28:47
看的有一些迷糊,IP DHCP的分配原则呢?

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: