场景:用路由器模拟PC以及DHCP_SERVER,在同一网段配置DHCP。将PC接口配置为动态获取地址时,PC会广播DHCP_DISCOVER报文发现DHCP服务器,这时可能有多个DHCP服务器收到报文后会广播回复DHCP_OFFER报文,而PC只会选取一个然后广播DHCP_REQUEST告诉服务器要这个地址,服务器检查可行就回复DHCP_Ack,这样地址就获取完成。
操作步骤:
步骤一:按照拓扑搭建实验环境
步骤二:用路由器模拟PC,关闭路由功能并将接口配置为动态获取IP
PC(config)#no iprouting //关闭路由功能
PC(config)#intf0/0
PC(config-if)#ip add
PC(config-if)#ipaddress dh
PC(config-if)#ipaddress dhcp //将接口配置为动态获取IP
步骤三:在DHCP_SERVER配置接口地址,DHCP地址池以及租期等信息
DHCP_SERVER(config)#
DHCP_SERVER(config)#intf0/0
DHCP_SERVER(config-if)#ipadd 192.168.10.254 255.255.255.0
DHCP_SERVER(config-if)#
DHCP_SERVER(config-if)#nosh
DHCP_SERVER(config)#ipdhcp pool dhcp_pool_1 // 配置DHCP的地址池名字
DHCP_SERVER(dhcp-config)#network192.168.10.0 255.255.255.0 // 配置DHCP地址范围
DHCP_SERVER(dhcp-config)#default-router192.168.10.254 //配置分配给主机的网关
DHCP_SERVER(dhcp-config)#lease0 8 0 //租期为0天8小时0分钟
DHCP_SERVER(dhcp-config)#ex
DHCP_SERVER(config)#ipdhcp excluded-address 192.168.10.250 192.168.10.254 //地址池中
需要排除的地址
步骤四:使用Wireshark,观察DHCP的获取过程
步骤五:查看接口地址获取情况
PC#sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.10.2 YES DHCP up up
FastEthernet1/0 unassigned YES unset administratively down down
配置文件
------------------------------------------------------------------------------
PC#sh run
Buildingconfiguration...
version 12.4
no ip routing
!
!
……
!
interface FastEthernet0/0
ip address dhcp
no ip route-cache
duplex auto
speed auto
!
!
……
!
end
-------------------------------------------------------------------------------
DHCP_SERVER#sh run
Buildingconfiguration...
!
version 12.4
!
hostname DHCP_SERVER
!
!
!
ip cef
no ip dhcp use vrfconnected
ip dhcpexcluded-address 192.168.10.250 192.168.10.254
!
ip dhcp pooldhcp_pool_1
network 192.168.10.0 255.255.255.0
default-router 192.168.10.254
lease 0 8
!
!
interfaceFastEthernet0/0
ip address 192.168.10.254 255.255.255.0
duplex auto
speed auto
!
………
!
!
end
-------------------------------------------------------------------------------
本文出自 “集大成者,美若天成” 博客,请务必保留此出处http://kidjang.blog.51cto.com/9975340/1769364
原文地址:http://kidjang.blog.51cto.com/9975340/1769364