一、DHCP Relay组网场景
• DHCP Relay组网场景如下图:把用户的上线请求报文转发给DHCP Server。
二、DHCP Relay工作流程
• DHCP Relay的工作流程:
三、DHCP Relay实验
2.1、拓扑图
• 分别在路由器中拖出1台AR2220、交换机中拖出一台S5700、终端中拖出2台PC机,然后选择设备连线,点击Copper进行设备接线,完成后开启设备。
2.2、配置
PC1:
• 双击PC1,在基础配置中将IPv4配置更改为DHCP模式。
PC2:
• 双击PC2,在基础配置中将IPv4配置更改为DHCP模式。
LSW1:
<Huawei>system-view [Huawei]sysname LSW1 [LSW1]vlan 2 [LSW1-vlan2]vlan 3 [LSW1-vlan3]int g0/0/2 [LSW1-GigabitEthernet0/0/2]port link-type access [LSW1-GigabitEthernet0/0/2]port default vlan 2 [LSW1-GigabitEthernet0/0/2]int g0/0/3 [LSW1-GigabitEthernet0/0/3]port link-type access [LSW1-GigabitEthernet0/0/3]port default vlan 3 [LSW1-GigabitEthernet0/0/3]q [LSW1]display vlan [LSW1]interface vlanif 1 [LSW1-Vlanif1]ip add 12.1.1.1 24 [LSW1-Vlanif1]int vlanif 2 [LSW1-Vlanif2]ip add 192.168.2.1 24 [LSW1-Vlanif2]int vlanif 3 [LSW1-Vlanif3]ip add 192.168.3.1 24 [LSW1-Vlanif3]q [LSW1]display ip routing-table [LSW1]ospf [LSW1-ospf-1]area 0 [LSW1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255 [LSW1-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [LSW1-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [LSW1-ospf-1-area-0.0.0.0]q [LSW1-ospf-1]q [LSW1]dhcp enable [LSW1]int Vlanif 2 [LSW1-Vlanif2]dhcp select relay [LSW1-Vlanif2]dhcp relay server-ip 12.1.1.2 [LSW1-Vlanif2]int vlanif 3 [LSW1-Vlanif3]dhcp select relay [LSW1-Vlanif3]dhcp relay server-ip 12.1.1.2 [LSW1-Vlanif3]q [LSW1]display current-configuration
AR1:
<Huawei>system-view [Huawei]sysname AR1 [AR1]int g0/0/0 [AR1-GigabitEthernet0/0/0]ip add 12.1.1.2 24 [AR1-GigabitEthernet0/0/0]q [AR1]ospf [AR1-ospf-1]area 0 [AR1-ospf-1-area-0.0.0.0]net 12.1.1.0 0.0.0.255 [AR1-ospf-1-area-0.0.0.0]q [AR1-ospf-1]display ospf routing [AR1]display ospf peer [AR1]ip pool vlan2 [AR1-ip-pool-vlan2]network 192.168.2.0 mask 255.255.255.0 [AR1-ip-pool-vlan2]gateway-list 192.168.2.1 [AR1-ip-pool-vlan2]dns-list 4.4.4.4 [AR1-ip-pool-vlan2]lease day 2 [AR1-ip-pool-vlan2]q [AR1]ip pool vlan3 [AR1-ip-pool-vlan3]network 192.168.3.1 [AR1-ip-pool-vlan3]dns-list 8.8.8.8 [AR1-ip-pool-vlan3]lease day 3 [AR1-ip-pool-vlan3]q [AR1]display current-configuration [AR1]dhcp enable [AR1]int g0/0/0 [AR1-GigabitEthernet0/0/0]dhcp select global
2.3、验证
PC1:
• 双击PC1,在命令行中输入"ipconfig"查看IP地址。可以看到,PC1已经正常获取到IP地址。
PC2:
• 双击PC2,在命令行中输入"ipconfig"查看IP地址。可以看到,PC2已经正常获取到IP地址。