DHCP中繼代理
阿新 • • 發佈:2018-05-16
Linux;DHCP中繼所謂DHCP中繼,即是跨網段為主機分配IP地址等配置,DHCP server和DHCP client處於不同的網段,這時就需要DHCPdelay。
實驗拓撲圖(GNS3)
實驗配置
三層交換機sw1:
sw1#conf t Enter configuration commands, one per line. End with CNTL/Z. sw1(config)#int f1/0 sw1(config-if)#sw mo t #接口設置Trunk模式 sw1(config-if)#sw t *Mar 1 00:24:35.099: %DTP-5-TRUNKPORTON: Port Fa1/0 has become dot1q trunk sw1(config-if)#sw t en dot #封裝dot1q協議 sw1(config-if)#ex sw1(config)#vlan 10,20,100 #創建vlan10,vlan20,vlan100 sw1(config-vlan)#ex sw1(config)#int vlan10 *Mar 1 00:25:04.011: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up sw1(config-if)#ip add 192.168.10.1 255.255.255.0 #設置vlan10的IP地址 sw1(config-if)#no shut sw1(config-if)#int vlan 20 *Mar 1 00:25:18.387: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up sw1(config-if)#ip add 192.168.20.1 255.255.255.0 #設置vlan20的IP地址 sw1(config-if)#no shut sw1(config-if)#int vlan 100 sw1(config-if)# *Mar 1 00:25:52.887: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up sw1(config-if)#ip add 192.168.100.1 255.255.255.0 #設置vlan100的地址 sw1(config-if)#no shut sw1(config-if)#ex sw1(config)#int vlan 10 sw1(config-if)#ip helper-ad sw1(config-if)#ip helper-address 192.168.100.130 #設置DHCP服務器的地址 sw1(config-if)#ex sw1(config)#int vlan 20 sw1(config-if)#ip helper-ad sw1(config-if)#ip helper-address 192.168.100.130 sw1(config-if)#ex sw1(config)#do show vlan-sw b VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa1/1, Fa1/2, Fa1/3, Fa1/4 Fa1/5, Fa1/6, Fa1/7, Fa1/8 Fa1/9, Fa1/10, Fa1/11, Fa1/12 Fa1/13, Fa1/14, Fa1/15 10 VLAN0010 active 20 VLAN0020 active 100 VLAN0100 active 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup sw1(config)#
交換機sw2:
sw2#conf t Enter configuration commands, one per line. End with CNTL/Z. sw2(config)#no ip routing #關閉路由功能 sw2(config)#vlan 10,20,100 #創建vlan10,vlan20,vlan100 sw2(config-vlan)#ex sw2(config)#int f1/1 sw2(config-if)#sw mo acc #接口設置接入模式 sw2(config-if)#sw acc vlan 10 #接口加入vlan10 sw2(config-if)#ex sw2(config)#int f1/2 sw2(config-if)#sw mo acc sw2(config-if)#sw acc vlan 20 #接口加入vlan20 sw2(config-if)#int f1/3 sw2(config-if)#sw mo acc sw2(config-if)#sw acc vlan 100 #接口加入vlan100 sw2(config-if)#ex sw2(config)#do show vlan-sw b VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa1/0, Fa1/4, Fa1/5, Fa1/6 Fa1/7, Fa1/8, Fa1/9, Fa1/10 Fa1/11, Fa1/12, Fa1/13, Fa1/14 Fa1/15 10 VLAN0010 active Fa1/1 20 VLAN0020 active Fa1/2 100 VLAN0100 active Fa1/3 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup sw2(config)#int f1/0 sw2(config-if)#sw mo t #接口設置Trunk模式 sw2(config-if)#sw t *Mar 1 00:23:49.083: %DTP-5-TRUNKPORTON: Port Fa1/0 has become dot1q trunk sw2(config-if)#sw t en dot #封裝dot1q協議
虛擬機rh6-3(網絡連接為“僅主機模式”):
在dhcpd.conf文件中修改如下相關配置:
開啟dhcpd服務:
三. 實驗測試
能夠成功利用DHCP進行地址分配,實驗成功。
DHCP中繼代理