同網段DHCP的配置




wKiom1cl4liyyGsZAAApIy8z9hI535.png






場景:用路由器模擬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的獲取過程



wKiom1cl4oTBJ7aPAACb0B4ufMA057.png




步驟五:查看接口地址獲取情況

 

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

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章