跨網段DHCP的配置

 


wKioL1cl5ESjbWl2AAA00MjVT9E728.png




場景:用路由器模擬PC以及DHCP_SERVER,DHCP_CLIENT與DHCP_SERVER不在同一網段。DHCP_CLIENT會廣播DHCP_DISCOVER包發現DHCP_SERVER,由於不在同一網段而且路由器默認不轉發廣播包,所以要配置DHCP_RELAY幫忙轉發廣播包到DHCP_SERVER。

 

操作步驟:

步驟一:按照拓撲搭建實驗環境

步驟二:用路由器模擬PC,關閉路由功能並將接口配置爲動態獲取IP

 

PC(config)#no iprouting      //關閉路由功能

PC(config)#intf0/0    

PC(config-if)#ipaddress dhcp  //將接口配置爲動態獲取IP

 

步驟三:在DHCP_SERVER配置接口地址,DHCP地址池以及租期等信息

 

DHCP_SERVER(config)#intf1/0

DHCP_SERVER(config-if)#ipadd 172.16.10.254 255.255.255.0

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 //地址池中

需要排除的地址

 

DHCP_SERVER(config)#iproute 0.0.0.0 0.0.0.0 f1/0    //配置默認路由

 

步驟四:配置DHCP中繼

 

DHCP_RELAY(config)#intf0/0

DHCP_RELAY(config-if)#ipadd 192.168.10.254 255.255.255.0

DHCP_RELAY(config-if)#nosh

DHCP_RELAY(config-if)#iphelper-address 172.16.10.254

 

DHCP_RELAY(config)#intf1/0

DHCP_RELAY(config-if)#ipadd 172.16.10.1 255.255.255.0

DHCP_RELAY(config-if)#nosh

 

 

步驟五:使用Wireshark,觀察DHCP中繼的過程

wKioL1cl5FTwXOWpAAA_xLQKD_U276.png

 

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

 

PC#sh ip int b

Interface                  IP-Address      OK? Method Status                Protocol

FastEthernet0/0            192.168.10.1    YES DHCP  up                    up     

FastEthernet1/0            unassigned      YES unset administratively down down   

 

配置文件

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

PC#sh run

!

hostname PC

!

no ip routing

!

!

……

!

!

interfaceFastEthernet0/0

 ip address dhcp

 no ip route-cache

 duplex auto

 speed auto

!

interfaceFastEthernet1/0

 no ip address

 no ip route-cache

 shutdown

 duplex auto

 speed auto

!

!

……

!

line con 0

line aux 0

line vty 0 4

!

!

end

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

DHCP_RELAY#sh run

Buildingconfiguration...

 

Currentconfiguration : 628 bytes

!

version 12.4

!

hostname DHCP_RELAY

!

!

!        

interfaceFastEthernet0/0

 ip address 192.168.10.254 255.255.255.0

 ip helper-address 172.16.10.254

 duplex auto

 speed auto

!

interfaceFastEthernet1/0

 ip address 172.16.10.1 255.255.255.0

 duplex auto

 speed auto

!

……

!        

line con 0

line aux 0

line vty 0 4

!

!

end

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

DHCP_SERVER#sh run

Buildingconfiguration...

 

!

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

 no ip address

 shutdown

 duplex auto

 speed auto

!

interfaceFastEthernet1/0

 ip address 172.16.10.254 255.255.255.0

 duplex auto

 speed auto

!

!

ip route 0.0.0.00.0.0.0 FastEthernet1/0

!

!

!

line con 0

line aux 0

line vty 0 4

!

!

end

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


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