跨网段DHCP的配置

  • Post author:
  • Post category:其他






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


——————————————————————————-

转载于:https://blog.51cto.com/kidjang/1769365


关闭菜单