目的:
1.实现多交换机不同Vlan间通信.
2.基于三层交换机配置路由,实现全网互通.
拓扑图:
步骤:
1. 配置PC主机的IP,掩码,网关.
2. 在二层交换机LSW1和LSW2上配置VLAN
[Huawei]sysname sw1 //配置LSW1
[sw1]vlan 2
[sw1-vlan2]quit
[sw1]vlan 3
[sw1-vlan3]quit
[sw1]interface e0/0/1
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]port default vlan 1
[sw1-Ethernet0/0/1]quit
[sw1]interface e0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 2
[sw1-Ethernet0/0/2]quit
[sw1]interface e0/0/3
[sw1-Ethernet0/0/3]port link-type access
[sw1-Ethernet0/0/3]port default vlan 3
[sw1-Ethernet0/0/3]quit
[sw1]interface g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw1-GigabitEthernet0/0/1]quit
[Huawei]sysname sw2 //配置LSW2
[sw2]vlan 4
[sw2-vlan4]quit
[sw2]vlan 5
[sw2-vlan5]quit
[sw2]interface e0/0/1
[sw2-Ethernet0/0/1]port link-type access
[sw2-Ethernet0/0/1]port default vlan 4
[sw2-Ethernet0/0/1]quit
[sw2]interface e0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 5
[sw2-Ethernet0/0/2]quit
[sw2]interface g0/0/2
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw2-GigabitEthernet0/0/2]quit
3. 配置三层交换机
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname sw3
[sw3]vlan batch 1 to 5
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3]interface g0/0/1
[sw3-GigabitEthernet0/0/1]port link-type trunk
[sw3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw3-GigabitEthernet0/0/1]quit
[sw3]interface g0/0/2
[sw3-GigabitEthernet0/0/2]port link-type trunk
[sw3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw3-GigabitEthernet0/0/2]quit
[sw3]interface vlanif 1
[sw3-Vlanif1]ip address
[sw3-Vlanif1]ip address 192.168.1.254 24
[sw3-Vlanif1]quit
[sw3]interface vlanif 2
[sw3-Vlanif2]ip address 192.168.2.254 24
[sw3-Vlanif2]quit
[sw3]interface vlanif 3
[sw3-Vlanif3]ip address 192.168.3.254 24
[sw3-Vlanif3]quit
[sw3]interface vlanif 4
[sw3-Vlanif4]ip address 192.168.4.254 24
[sw3-Vlanif4]quit
[sw3]interface vlanif 5
[sw3-Vlanif5]ip address 192.168.5.254 24
[sw3-Vlanif5]quit
[sw3]vlan 6
[sw3-vlan6]interface g0/0/3
[sw3-GigabitEthernet0/0/3]port link-type access
[sw3-GigabitEthernet0/0/3]port default vlan 6
[sw3-GigabitEthernet0/0/3]quit
[sw3]interface vlanif 6
[sw3-Vlanif6]ip address 192.168.6.254 24
[sw3-Vlanif6]quit
[sw3]ip route-static 192.168.7.0 255.255.255.0 192.168.6.1
4. 配置路由
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]interface g0/0/0
[AR1-GigabitEthernet0/0/0]ip address 192.168.6.1 24
[AR1-GigabitEthernet0/0/0]quit
[AR1]interface g0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.7.254 24
[AR1-GigabitEthernet0/0/1]quit
[AR1]ip route-static 0.0.0.0 0.0.0.0 192.168.6.254
[AR1]quit
[AR1]display ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 192.168.6.254 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.6.0/24 Direct 0 0 D 192.168.6.1 GigabitEthernet
0/0/0
192.168.6.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.6.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.7.0/24 Direct 0 0 D 192.168.7.254 GigabitEthernet
0/0/1
192.168.7.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.7.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[AR1]
5. 测试5台PC之间是否互通
结束.