华为交换机:三层交换机实现vlan间通信

it2024-01-31  66

实验拓扑

swh1配置

<Huawei>SYS Enter system view, return user view with Ctrl+Z. [Huawei]sys swh1 [swh1] [swh1]int g0/0/1 [swh1-GigabitEthernet0/0/1]port link-type access [swh1-GigabitEthernet0/0/1]int g0/0/2 [swh1-GigabitEthernet0/0/2]port link-type access [swh1-GigabitEthernet0/0/2]int g0/0/3 [swh1-GigabitEthernet0/0/3]port link-type access [swh1-GigabitEthernet0/0/3]q [swh1]vlan 10 [swh1-vlan10]port g0/0/1 [swh1-vlan10]q [swh1] [swh1]vlan 20 [swh1-vlan20] [swh1-vlan20]port g0/0/2 [swh1-vlan20]q [swh1]vlan 30 [swh1-vlan30]port g0/0/3

查看vlan

[swh1]dis vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D) 10 common UT:GE0/0/1(D) 20 common UT:GE0/0/2(D) 30 common UT:GE0/0/3(D) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030

swh2配置

The device is running! ########## <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys swh2 [swh2] [swh2]int g0/0/1 [swh2-GigabitEthernet0/0/1]port link-type access [swh2-GigabitEthernet0/0/1]int g0/0/2 [swh2-GigabitEthernet0/0/2]port link-type access [swh2-GigabitEthernet0/0/2]int g0/0/3 [swh2-GigabitEthernet0/0/3]port link-type access [swh2-GigabitEthernet0/0/3]q [swh2]vlan 10 [swh2-vlan10]port g0/0/1 [swh2-vlan10]q [swh2] [swh2]vlan 20 [swh2-vlan20]port g0/0/2 [swh2-vlan20]q [swh2]vlan 30 [swh2-vlan30]port g0/0/3 [swh2-vlan30]q [swh2]dis vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D) 10 common UT:GE0/0/1(D) 20 common UT:GE0/0/2(D) 30 common UT:GE0/0/3(D) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030 [swh2]

swh3配置

The device is running! <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys swh3 [swh3] [swh3]int g0/0/1 [swh3-GigabitEthernet0/0/1]port link-type access [swh3-GigabitEthernet0/0/1]int g0/0/2 [swh3-GigabitEthernet0/0/2]port link-type access [swh3-GigabitEthernet0/0/2]int g0/0/3 [swh3-GigabitEthernet0/0/3]port link-type access [swh3-GigabitEthernet0/0/3]q [swh3] [swh3]vlan 10 [swh3-vlan10]port g0/0/1 [swh3-vlan10]q [swh3]vlan 20 [swh3-vlan20]port g0/0/2 [swh3-vlan20]q [swh3]vlan 30 [swh3-vlan30]port g0/0/3 [swh3-vlan30]q [swh3]dis vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(U) 10 common UT:GE0/0/1(U) 20 common UT:GE0/0/2(U) 30 common UT:GE0/0/3(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030 [swh3] [swh3]q <swh3>save The current configuration will be written to the device. Are you sure to continue?[Y/N]y Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]: Oct 21 2020 10:18:18-08:00 swh3 %%01CFM/4/SAVE(l)[0]:The user chose Y when decid ing whether to save the configuration to the device. Now saving the current configuration to the slot 0. Save the configuration successfully. <swh3> Oct 21 2020 10:20:00-08:00 swh3 %%01PHY/1/PHY(l)[4]: GigabitEthernet0/0/24: c hange status to up Oct 21 2020 10:20:00-08:00 swh3 %%01IFNET/4/IF_STATE(l)[5]:Interface Vlanif1 has turned into UP state. <swh3>

配置trunk

swh1、swh2、swh3三台交换机的g0/0/24链接的是swh4,swh4可以看作是是核心交换机,所以我们必须将123三台交换机的g0/0/24配置成trunk,并且要配置允许所有vlan通过。

[swh1]int g0/0/24 [swh1-GigabitEthernet0/0/24]port link-type trunk [swh1-GigabitEthernet0/0/24]port trunk allow-pass vlan all ##允许所有vlan通过 [swh1-GigabitEthernet0/0/24]q [swh1]q <swh1>save [swh2]int g0/0/24 [swh2-GigabitEthernet0/0/24]port link-type trunk [swh2-GigabitEthernet0/0/24]port trunk allow-pass vlan all [swh2-GigabitEthernet0/0/24]q [swh2]q <swh2>save [swh3]int g0/0/24 [swh3-GigabitEthernet0/0/24]port link-type trunk [swh3-GigabitEthernet0/0/24]port trunk allow-pass vlan all [swh3-GigabitEthernet0/0/24]q [swh3]q <swh3>save

查看vlan

[swh1]dis vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(U) 10 common UT:GE0/0/1(U) TG:GE0/0/24(U) #允许所有vlan通过 20 common UT:GE0/0/2(U) TG:GE0/0/24(U) #允许所有vlan通过 30 common UT:GE0/0/3(U) TG:GE0/0/24(U) #允许所有vlan通过 VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030 [swh1]

swh4配置

我们从拓扑图上看出swh4是此网络的核心交换机,因此swh4上的配置尤为重要,步骤如下:

首先必须将g0/0/1、g0/0/2、g0/0/3的端口类型更改为trunk;其次必须将g0/0/1、g0/0/2、g0/0/3的端口配置为允许所有vlan通过;创建对应的vlan10、vlan20、vlan30,并且为这三个vlan配置IP地址。 <Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sys swh4 [swh4] [swh4]int g0/0/1 [swh4-GigabitEthernet0/0/1]port link-type trunk #端口类型更改为trunk [swh4-GigabitEthernet0/0/1]port trunk allow-pass vlan all #允许所有vlan通过 [swh4-GigabitEthernet0/0/1]int g0/0/2 [swh4-GigabitEthernet0/0/2]port link-type trunk [swh4-GigabitEthernet0/0/2]port trunk allow-pass vlan all [swh4-GigabitEthernet0/0/2]int g0/0/3 [swh4-GigabitEthernet0/0/3]port link-type trunk [swh4-GigabitEthernet0/0/3]port trunk allow-pass vlan all [swh4]vlan 10 #创建vlan [swh4-vlan10]q [swh4]vlan 20 [swh4-vlan20]q [swh4]vlan 30 [swh4-vlan30]q [swh4]int vlan 10 [swh4-Vlanif10] [swh4-Vlanif10]ip address 192.168.10.254 24 #给vlan10配置IP地址 [swh4-Vlanif10]q [swh4]int vlan 20 [swh4-Vlanif20]ip add 192.168.20.254 24 [swh4-Vlanif20] [swh4-Vlanif20]q [swh4]vlan 30 [swh4]int vlan 30 [swh4-Vlanif30]ip add 192.168.30.254 24 [swh4-Vlanif30] [swh4-Vlanif30]q [swh4]dis vlan The total number of vlans is : 4 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/3(U) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D) GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D) GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D) GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D) 10 common TG:GE0/0/1(U) GE0/0/2(U) GE0/0/3(U) 20 common TG:GE0/0/1(U) GE0/0/2(U) GE0/0/3(U) 30 common TG:GE0/0/1(U) GE0/0/2(U) GE0/0/3(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 20 enable default enable disable VLAN 0020 30 enable default enable disable VLAN 0030 [swh4]

验证结果

在PC1上ping PC 789

Welcome to use PC Simulator! PC>ping 192.168.10.3 Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break From 192.168.10.1: Destination host unreachable From 192.168.10.1: Destination host unreachable From 192.168.10.1: Destination host unreachable From 192.168.10.1: Destination host unreachable From 192.168.10.1: Destination host unreachable --- 192.168.10.3 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.20.1 Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break From 192.168.10.1: Destination host unreachable PC>ping 192.168.10.3 Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break From 192.168.10.3: bytes=32 seq=1 ttl=128 time=78 ms From 192.168.10.3: bytes=32 seq=2 ttl=128 time=78 ms From 192.168.10.3: bytes=32 seq=3 ttl=128 time=78 ms --- 192.168.10.3 ping statistics --- 3 packet(s) transmitted 3 packet(s) received 0.00% packet loss round-trip min/avg/max = 78/78/78 ms PC>ping 192.168.30.3 Ping 192.168.30.3: 32 data bytes, Press Ctrl_C to break From 192.168.30.3: bytes=32 seq=1 ttl=127 time=141 ms From 192.168.30.3: bytes=32 seq=2 ttl=127 time=63 ms --- 192.168.30.3 ping statistics --- 2 packet(s) transmitted 2 packet(s) received 0.00% packet loss round-trip min/avg/max = 63/102/141 ms PC>ping 192.168.20.3 Ping 192.168.20.3: 32 data bytes, Press Ctrl_C to break From 192.168.20.3: bytes=32 seq=1 ttl=127 time=110 ms From 192.168.20.3: bytes=32 seq=2 ttl=127 time=78 ms From 192.168.20.3: bytes=32 seq=3 ttl=127 time=62 ms From 192.168.20.3: bytes=32 seq=4 ttl=127 time=62 ms --- 192.168.20.3 ping statistics --- 4 packet(s) transmitted 4 packet(s) received 0.00% packet loss round-trip min/avg/max = 62/78/110 ms PC>
最新回复(0)