查看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 0030swh1、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上的配置尤为重要,步骤如下:
首先必须将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>