网络拓扑图实现如下:
[Huawei]SYS 041740509-SW2 //进行重命名[041740509-SW2]vlan batch 2 3 //创建VLAN[041740509-SW2]vlan 5[041740509-SW2]int e0/0/1[041740509-SW2-Ethernet0/0/1]port link-type access //设置接口模式[041740509-SW2-Ethernet0/0/1]port default vlan 2 //将接口加入VLAN2[041740509-SW2]int e0/0/2[041740509-SW2-Ethernet0/0/2]port link-type access [041740509-SW2-Ethernet0/0/2]port default vlan 3 //将接口加入VLAN3[041740509-SW2-Ethernet0/0/2]q[041740509-SW2-vlan5]int g0/0/1[041740509-SW2-GigabitEthernet0/0/1]port link-type access [041740509-SW2-GigabitEthernet0/0/1]port default vlan 5[041740509-SW2-GigabitEthernet0/0/1]q[041740509-SW2]int vlan 2 //为VLAN 2 配置IP地址[041740509-SW2-Vlanif2]ip add 192.168.2.1 24[041740509-SW2-Vlanif2]int vlan 3//为VLAN 3 配置IP地址[041740509-SW2-Vlanif3]ip add 192.168.3.1 24[041740509-SW2]int vlan 5//为VLAN 5 配置IP地址[041740509-SW2-Vlanif5]ip add 192.168.5.2 24[041740509-SW2-Vlanif3]q[041740509-SW2-vlan5]int g0/0/1[041740509-SW2-GigabitEthernet0/0/1]port link-type access [041740509-SW2-GigabitEthernet0/0/1]port default vlan 5[041740509-SW2-GigabitEthernet0/0/1]q//配置静态路由表[041740509-SW2]ip route-static 0.0.0.0 0.0.0.0 192.168.5.1[041740509-SW2]q[Huawei]sys 041740509-SW3[041740509-SW3]vlan 4[041740509-SW3-vlan4]vlan 5[041740509-SW3-vlan5]int e0/0/1[041740509-SW3-Ethernet0/0/1]port link-type access [041740509-SW3-Ethernet0/0/1]port default vlan 4[041740509-SW3-Ethernet0/0/1]q[041740509-SW3]int vlan 4[041740509-SW3-Vlanif4]ip add 192.168.4.1 24[041740509-SW3-Vlanif4]q[041740509-SW3]INT g0/0/2[041740509-SW3-GigabitEthernet0/0/2]port link-type access [041740509-SW3-GigabitEthernet0/0/2]port default vlan 5[041740509-SW3]int vlan 5[041740509-SW3-Vlanif5]ip add 192.168.5.3 24[041740509-SW3-Vlanif5]q[041740509-SW3]ip route-static 0.0.0.0 0.0.0.0 192.168.5.1[Huawei]sys 041740509-sw1[041740509-sw1]vlan 5[041740509-sw1-vlan5]q[041740509-sw1]int vlan 5[041740509-sw1-Vlanif5]ip add 192.168.5.1 24[041740509-sw1-Vlanif5]q[041740509-sw1]int g0/0/3[041740509-sw1-GigabitEthernet0/0/3]port link-type access [041740509-sw1-GigabitEthernet0/0/3]port default vlan 5[041740509-sw1-GigabitEthernet0/0/3]q[041740509-sw1]int g0/0/1[041740509-sw1-GigabitEthernet0/0/1]port link-type access [041740509-sw1-GigabitEthernet0/0/1]port default vlan 5[041740509-sw1-GigabitEthernet0/0/1]int g0/0/2[041740509-sw1-GigabitEthernet0/0/2]port link-type access [041740509-sw1-GigabitEthernet0/0/2]port default vlan 5[041740509-sw1-GigabitEthernet0/0/2]q[041740509-sw1]ip route-static 192.168.2.0 255.255.255.0 192.168.5.2[041740503-SW1]ip route-static 192.168.3.0 255.255.255.0 192.168.5.2[041740509-sw1]ip route-static 192.168.4.0 255.255.255.0 192.168.5.3[041740509-sw1]ip route-static 0.0.0.0 0.0.0.0 192.168.5.4路由器R1的配置命令如下:[Huawei]sys 041740509-R1[041740509-R1]int g0/0/3 // 为接口配置IP地址[041740509-R1-GigabitEthernet0/0/3]ip add 192.168.5.4 24[041740509-R1-GigabitEthernet0/0/3]q//为路由器配置静态路由信息[041740509-R1]ip route-static 0.0.0.0 0.0.0.0 192.168.5.1[041740509-R1]q<041740509-R1>save
查看各交换机的路由表信息:
在路由表中测试到各主机的通信情况:
测试各VLAN间主机的通信: