基于端口的vlan划分
以下配置为例: 注意选择copper线,可以任意选择端口
PC配置如下:
LSW1配置如下
[LSW1]vlan 10 [LSW1-vlan10]qu [LSW1]interface g0/0/9 [LSW1-Gigabitethernet0/0/9] port link-type acces [LSW1-Gigabitethernet0/0/9] port default vlan 10 [LSW1-Gigabitethernet0/0/9] qu #显示g0/0/9的信息 [LSW1]display interface g0/0/9 GigabitEthernet0/0/9 current state : UP Line protocol current state : UP Description: Switch Port, PVID : 10, TPID : 8100(Hex), The Maximum Frame Length is 9216 IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc6c-2c40 Last physical up time : 2023-09-16 10:15:22 UTC-08:00 Last physical down time : 2023-09-16 10:15:21 UTC-08:00 Current system time: 2023-09-16 10:18:04-08:00 Hardware address is 4c1f-cc6c-2c40 Last 300 seconds input rate 0 bytes/sec, 0 packets/sec Last 300 seconds output rate 0 bytes/sec, 0 packets/sec Input: 0 bytes, 0 packets Output: 92582 bytes, 778 packets Input: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Output: Unicast: 0 packets, Multicast: 778 packets Broadcast: 0 packets Input bandwidth utilization : 0% Output bandwidth utilization : 0% #显示g0/0/9的vlan信息 [LSW1]display port vlan g0/0/9 Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/9 access 10 - #其他端口同理 [LSW1]interface g0/0/10 [LSW1-GigabitEthernet0/0/10]port link-type access [LSW1-GigabitEthernet0/0/10]port default vlan 10 [LSW1-GigabitEthernet0/0/10]qu [LSW1]display interface g0/0/10 GigabitEthernet0/0/10 current state : DOWN Line protocol current state : DOWN Description: Switch Port, PVID : 10, TPID : 8100(Hex), The Maximum Frame Length is 9216 IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc6c-2c40 Last physical up time : - Last physical down time : 2023-09-14 18:37:01 UTC-08:00 Current system time: 2023-09-16 10:01:30-08:00 Hardware address is 4c1f-cc6c-2c40 Last 300 seconds input rate 0 bytes/sec, 0 packets/sec Last 300 seconds output rate 0 bytes/sec, 0 packets/sec Input: 0 bytes, 0 packets Output: 0 bytes, 0 packets Input: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Output: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Input bandwidth utilization : 0% Output bandwidth utilization : 0% [LSW1]display port vlan g0/0/10 Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/10 access 10 - [LSW1]interface g0/0/11 [LSW1-GigabitEthernet0/0/11]port link-type access [LSW1-GigabitEthernet0/0/11]port default vlan 10 [LSW1-GigabitEthernet0/0/11]qu [LSW1]display interface g0/0/11 GigabitEthernet0/0/11 current state : DOWN Line protocol current state : DOWN Description: Switch Port, PVID : 10, TPID : 8100(Hex), The Maximum Frame Length is 9216 IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc6c-2c40 Last physical up time : - Last physical down time : 2023-09-14 18:37:01 UTC-08:00 Current system time: 2023-09-16 10:04:08-08:00 Hardware address is 4c1f-cc6c-2c40 Last 300 seconds input rate 0 bytes/sec, 0 packets/sec Last 300 seconds output rate 0 bytes/sec, 0 packets/sec Input: 0 bytes, 0 packets Output: 0 bytes, 0 packets Input: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Output: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Input bandwidth utilization : 0% Output bandwidth utilization : 0% [LSW1]display port vlan g0/0/11 Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/11 access 10 - [LSW1]interface g0/0/12 [LSW1-GigabitEthernet0/0/12]port link-type access [LSW1-GigabitEthernet0/0/12]port default vlan 10 [LSW1-GigabitEthernet0/0/12]qu [LSW1]display interface g0/0/12 GigabitEthernet0/0/12 current state : UP Line protocol current state : UP Description: Switch Port, PVID : 10, TPID : 8100(Hex), The Maximum Frame Length is 9216 IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cc6c-2c40 Last physical up time : 2023-09-16 10:01:17 UTC-08:00 Last physical down time : 2023-09-16 10:01:16 UTC-08:00 Current system time: 2023-09-16 10:05:01-08:00 Hardware address is 4c1f-cc6c-2c40 Last 300 seconds input rate 0 bytes/sec, 0 packets/sec Last 300 seconds output rate 0 bytes/sec, 0 packets/sec Input: 0 bytes, 0 packets Output: 48909 bytes, 411 packets Input: Unicast: 0 packets, Multicast: 0 packets Broadcast: 0 packets Output: Unicast: 0 packets, Multicast: 411 packets Broadcast: 0 packets Input bandwidth utilization : 0% Output bandwidth utilization : 0% [LSW1]display port vlan g0/0/12 Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/12 access 10 - [LSW1]display vlan 10 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 10 common UT:GE0/0/1(D) GE0/0/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 10 enable default enable disable VLAN 0010 #创建vlan30 [LSW1]vlan 30 [LSW1-vlan30]qu [LSW1]port-group pvlan30 #上面的操作重复繁琐,容易出错,这里可以对多个端口进行统一配置 [LSW1-port-group-pvlan30]group-member g0/0/13 to g0/0/16 [LSW1-port-group-pvlan30]display port-group pvlan30 [LSW1-port-group-pvlan30]display port-group pvlan30 Portgroup: pvlan30 GigabitEthernet0/0/13 GigabitEthernet0/0/14 GigabitEthernet0/0/15 GigabitEthernet0/0/16 [LSW1-port-group-pvlan30]port link-type access [LSW1-GigabitEthernet0/0/13]port link-type access [LSW1-GigabitEthernet0/0/14]port link-type access [LSW1-GigabitEthernet0/0/15]port link-type access [LSW1-GigabitEthernet0/0/16]port link-type access [LSW1-port-group-pvlan30]port default vlan 30 [LSW1-GigabitEthernet0/0/13]port default vlan 30 [LSW1-GigabitEthernet0/0/14]port default vlan 30 [LSW1-GigabitEthernet0/0/15]port default vlan 30 [LSW1-GigabitEthernet0/0/16]port default vlan 30 [LSW1-port-group-pvlan30]qu [LSW1]display vlan 30 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 30 common UT:GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 30 enable default enable disable VLAN 0030 [LSW1]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 access 10 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 10 - GigabitEthernet0/0/10 access 10 - GigabitEthernet0/0/11 access 10 - GigabitEthernet0/0/12 access 10 - GigabitEthernet0/0/13 access 30 - GigabitEthernet0/0/14 access 30 - GigabitEthernet0/0/15 access 30 - GigabitEthernet0/0/16 access 30 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 hybrid 1 -
统一创建vlan的命令
#批量创建2....100
vlan batch 2 to 100
华为端口恢复默认配置的命令
撤销操作或命令直接在命令前面加 undo
不同的vlan之间逻辑上是隔离的,不能相互通信
从以下信息可以看出,PC1可以与PC2进行通信,但是PC1不能与PC3,PC4相互通信
PC>ping 192.168.10.12 Ping 192.168.10.12: 32 data bytes, Press Ctrl_C to break From 192.168.10.12: bytes=32 seq=1 ttl=128 time=32 ms From 192.168.10.12: bytes=32 seq=2 ttl=128 time=47 ms From 192.168.10.12: bytes=32 seq=3 ttl=128 time=63 ms From 192.168.10.12: bytes=32 seq=4 ttl=128 time=46 ms From 192.168.10.12: bytes=32 seq=5 ttl=128 time=47 ms --- 192.168.10.12 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 32/47/63 ms PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable --- 192.168.10.254 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>ping 192.168.30.12 Ping 192.168.30.12: 32 data bytes, Press Ctrl_C to break From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable From 192.168.10.11: Destination host unreachable --- 192.168.10.254 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss PC>
基于mac地址的VLAN划分 PC-BOOK的mac地址如下 PC-BOOK-10-1:54-89-98-9F-25-B6 PC-BOOK-30-1:54-89-98-88-74-CD [LSW1]vlan 10 [LSW1-vlan10]qu [LSW1]vlan 30 [LSW1-vlan30]qu [LSW1]port-group pvlan10 [LSW1-port-group-pvlan10]group-member g0/0/9 to g0/0/12 [LSW1-port-group-pvlan10]display port-group pvlan10 Portgroup: pvlan10 GigabitEthernet0/0/9 GigabitEthernet0/0/10 GigabitEthernet0/0/11 GigabitEthernet0/0/12 [LSW1-port-group-pvlan10]qu [LSW1]port-group pvlan30 [LSW1-port-group-pvlan30]group-member g0/0/13 to g0/0/16 [LSW1-port-group-pvlan30]display port-group pvlan30 Portgroup: pvlan30 GigabitEthernet0/0/13 GigabitEthernet0/0/14 GigabitEthernet0/0/15 GigabitEthernet0/0/16 [LSW1-port-group-pvlan30]port link-type access [LSW1-GigabitEthernet0/0/13]port link-type access [LSW1-GigabitEthernet0/0/14]port link-type access [LSW1-GigabitEthernet0/0/15]port link-type access [LSW1-GigabitEthernet0/0/16]port link-type access [LSW1-port-group-pvlan30]port default vlan 30 [LSW1-GigabitEthernet0/0/13]port default vlan 30 [LSW1-GigabitEthernet0/0/14]port default vlan 30 [LSW1-GigabitEthernet0/0/15]port default vlan 30 [LSW1-GigabitEthernet0/0/16]port default vlan 30 [LSW1-port-group-pvlan30]qu [LSW1]port-group pvlan10 [LSW1-port-group-pvlan10]port link-type access [LSW1-GigabitEthernet0/0/9]port link-type access [LSW1-GigabitEthernet0/0/10]port link-type access [LSW1-GigabitEthernet0/0/11]port link-type access [LSW1-GigabitEthernet0/0/12]port link-type access [LSW1-port-group-pvlan10]port default vlan 10 [LSW1-GigabitEthernet0/0/9]port default vlan 10 [LSW1-GigabitEthernet0/0/10]port default vlan 10 [LSW1-GigabitEthernet0/0/11]port default vlan 10 [LSW1-GigabitEthernet0/0/12]port default vlan 10 [LSW1-port-group-pvlan10] [LSW1-port-group-pvlan10]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- 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(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(U) GE0/0/5(U) GE0/0/6(D) GE0/0/7(D) GE0/0/8(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/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) 30 common UT:GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 [LSW1-port-group-pvlan10]qu [LSW1]vlan 10 [LSW1-vlan10]mac-vlan mac-address 5489-989F-25B6 priority 0 [LSW1]vlan 30 [LSW1-vlan30]mac-vlan mac-address 5489-9888-74cd priority 0 [LSW1-vlan30]int g0/0/4 [LSW1-GigabitEthernet0/0/4]port link-type hybrid [LSW1-GigabitEthernet0/0/4]port hybrid untagged vlan 10 30 [LSW1-GigabitEthernet0/0/4]mac-vlan enable Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1-GigabitEthernet0/0/4]qu [LSW1]int g0/0/5 [LSW1-GigabitEthernet0/0/5]port link-type hybrid [LSW1-GigabitEthernet0/0/5]port hybrid untagged vlan 10 30 [LSW1-GigabitEthernet0/0/5]mac-vlan enable Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1-GigabitEthernet0/0/5]qu [LSW1]display mac-vlan mac-address all --------------------------------------------------- MAC Address MASK VLAN Priority --------------------------------------------------- 5489-989f-25b6 ffff-ffff-ffff 10 0 5489-9888-74cd ffff-ffff-ffff 30 0 Total MAC VLAN address count: 2 [LSW1]display mac-vlan vlan 10 --------------------------------------------------- MAC Address MASK VLAN Priority --------------------------------------------------- 5489-989f-25b6 ffff-ffff-ffff 10 0 Total MAC VLAN address count: 1 [LSW1]display mac-vlan vlan 30 --------------------------------------------------- MAC Address MASK VLAN Priority --------------------------------------------------- 5489-9888-74cd ffff-ffff-ffff 30 0 Total MAC VLAN address count: 1
至此,PC-BOOK-10-1加入vlan 10,PC-BOOK-30-1加入vlan30
将 PC-BOOK-10-1和PC-BOOK-30-1所连接的交换机端口互换,依旧可以与同一个vlan中的计算机通信
PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break From 192.168.30.11: bytes=32 seq=1 ttl=128 time=63 ms From 192.168.30.11: bytes=32 seq=2 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=3 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=4 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=5 ttl=128 time=47 ms --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/50/63 ms
基于IP地址的vlan划分
在原有的基础上扩展
PC-1030-1:IPV4地址 192.168.30.18 子网掩码:255.255.255.0
LSW1上的配置
[LSW1]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- 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(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(U) GE0/0/5(U) GE0/0/6(D) GE0/0/7(D) GE0/0/8(U) 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/4(U) GE0/0/5(U) GE0/0/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) 30 common UT:GE0/0/4(U) GE0/0/5(U) GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 [LSW1]vlan 10 #按ip地址划分vlan [LSW1-vlan10]ip-subnet-vlan 2 ip 192.168.10.0 24 priority 1 #2为子网索引,取值范围为1~12,一个vlan最多可以绑定12个子网 #192.168.10.0为子网地址,24为前缀长度,也可以采用子网掩码 #priority为优先级,取值范围为0~7,值越大优先级越高,默认值为0 [LSW1-vlan10]qu [LSW1]vlan 30 [LSW1-vlan30]ip-subnet-vlan 1 ip 192.168.30.0 24 priority 1 [LSW1-vlan30]qu [LSW1]interface g 0/0/8 #配置为hybrid,并使其在发送vlan 10和vlan 30的帧时剥除vlan tag [LSW1-GigabitEthernet0/0/8]port link-type hybrid [LSW1-GigabitEthernet0/0/8]port hybrid untagged vlan 10 30 [LSW1-GigabitEthernet0/0/8]ip-subnet-vlan enable [LSW1-GigabitEthernet0/0/8]qu [LSW1]display ip-subnet-vlan vlan all ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 10 2 192.168.10.0 255.255.255.0 1 30 1 192.168.30.0 255.255.255.0 1 ---------------------------------------------------------------- ip-subnet-vlan count: 2 total count: 2 [LSW1]display ip-subnet-vlan vlan 10 ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 10 2 192.168.10.0 255.255.255.0 1 ---------------------------------------------------------------- ip-subnet-vlan count: 1 total count: 2 [LSW1]display ip-subnet-vlan vlan 30 ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 30 1 192.168.30.0 255.255.255.0 1 ---------------------------------------------------------------- ip-subnet-vlan count: 1 total count: 2 至此这台PC加入了vlan10和vlan30 [LSW1]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- 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(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(U) GE0/0/5(U) GE0/0/6(D) GE0/0/7(D) GE0/0/8(U) 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/4(U) GE0/0/5(U) GE0/0/8(U) GE0/0/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) 30 common UT:GE0/0/4(U) GE0/0/5(U) GE0/0/8(U) GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 [LSW1] #切换到地址192.168.10.18后,能ping 192.168.10.11 PC>ping 192.168.10.11 Ping 192.168.10.11: 32 data bytes, Press Ctrl_C to break From 192.168.10.11: bytes=32 seq=1 ttl=128 time=47 ms From 192.168.10.11: bytes=32 seq=2 ttl=128 time=62 ms From 192.168.10.11: bytes=32 seq=3 ttl=128 time=47 ms From 192.168.10.11: bytes=32 seq=4 ttl=128 time=62 ms From 192.168.10.11: bytes=32 seq=5 ttl=128 time=63 ms --- 192.168.10.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/56/63 ms #切换到192.168.30.18后,能ping 192.168.30.11 PC>ping 192.168.30.11 Ping 192.168.30.11: 32 data bytes, Press Ctrl_C to break From 192.168.30.11: bytes=32 seq=1 ttl=128 time=62 ms From 192.168.30.11: bytes=32 seq=2 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=3 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=4 ttl=128 time=47 ms From 192.168.30.11: bytes=32 seq=5 ttl=128 time=31 ms --- 192.168.30.11 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 31/46/62 ms
跨以太网交换机的vlan扩展
PC配置如下
LSW1的配置
<LSW1>sys Enter system view, return user view with Ctrl+Z. [LSW1]vlan batch 10 30 Info: This operation may take a few seconds. Please wait for a moment...done. [LSW1]port-group pvlan10 [LSW1-port-group-pvlan10]group-member g0/0/9 to g0/0/12 [LSW1-port-group-pvlan10]port link-type access [LSW1-GigabitEthernet0/0/9]port link-type access [LSW1-GigabitEthernet0/0/10]port link-type access [LSW1-GigabitEthernet0/0/11]port link-type access [LSW1-GigabitEthernet0/0/12]port link-type access [LSW1-port-group-pvlan10]port default vlan 10 [LSW1-GigabitEthernet0/0/9]port default vlan 10 [LSW1-GigabitEthernet0/0/10]port default vlan 10 [LSW1-GigabitEthernet0/0/11]port default vlan 10 [LSW1-GigabitEthernet0/0/12]port default vlan 10 [LSW1-port-group-pvlan10]qu [LSW1]port-group pvlan30 [LSW1-port-group-pvlan30]group-member g0/0/13 to g0/0/16 [LSW1-port-group-pvlan30]port link-type access [LSW1-GigabitEthernet0/0/13]port link-type access [LSW1-GigabitEthernet0/0/14]port link-type access [LSW1-GigabitEthernet0/0/15]port link-type access [LSW1-GigabitEthernet0/0/16]port link-type access [LSW1-port-group-pvlan30]port default vlan 30 [LSW1-GigabitEthernet0/0/13]port default vlan 30 [LSW1-GigabitEthernet0/0/14]port default vlan 30 [LSW1-GigabitEthernet0/0/15]port default vlan 30 [LSW1-GigabitEthernet0/0/16]port default vlan 30 [LSW1-port-group-pvlan30]qu [LSW1]interface g0/0/24 [LSW1-GigabitEthernet0/0/24]port link-type trunk [LSW1-GigabitEthernet0/0/24]port trunk allow-pass vlan 10 30 [LSW1-GigabitEthernet0/0/24]qu [LSW1]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- 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(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(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/4(D) GE0/0/5(D) GE0/0/8(D) GE0/0/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) TG:GE0/0/24(U) 30 common UT:GE0/0/4(D) GE0/0/5(D) GE0/0/8(D) GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) TG:GE0/0/24(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 [LSW1]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 10 - GigabitEthernet0/0/10 access 10 - GigabitEthernet0/0/11 access 10 - GigabitEthernet0/0/12 access 10 - GigabitEthernet0/0/13 access 30 - GigabitEthernet0/0/14 access 30 - GigabitEthernet0/0/15 access 30 - GigabitEthernet0/0/16 access 30 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 trunk 1 1 10 30 [LSW1]
LSW2与LSW1的配置同理
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname LSW2 [LSW2]undo info-center enable Info: Information center is disabled. [LSW2]vlan batch 10 30 Info: This operation may take a few seconds. Please wait for a moment...done. [LSW2]port-group pvlan10 [LSW2-port-group-pvlan10]group-member g0/0/9 to g0/0/12 [LSW2-port-group-pvlan10]port link-type access [LSW2-GigabitEthernet0/0/9]port link-type access [LSW2-GigabitEthernet0/0/10]port link-type access [LSW2-GigabitEthernet0/0/11]port link-type access [LSW2-GigabitEthernet0/0/12]port link-type access [LSW2-port-group-pvlan10]port default vlan 10 [LSW2-GigabitEthernet0/0/9]port default vlan 10 [LSW2-GigabitEthernet0/0/10]port default vlan 10 [LSW2-GigabitEthernet0/0/11]port default vlan 10 [LSW2-GigabitEthernet0/0/12]port default vlan 10 [LSW2-port-group-pvlan10]qu [LSW2]port-group pvlan30 [LSW2-port-group-pvlan30]group-member g0/0/13 to g0/0/16 [LSW2-port-group-pvlan30]port link-type access [LSW2-GigabitEthernet0/0/13]port link-type access [LSW2-GigabitEthernet0/0/14]port link-type access [LSW2-GigabitEthernet0/0/15]port link-type access [LSW2-GigabitEthernet0/0/16]port link-type access [LSW2-port-group-pvlan30]port default vlan 30 [LSW2-GigabitEthernet0/0/13]port default vlan 30 [LSW2-GigabitEthernet0/0/14]port default vlan 30 [LSW2-GigabitEthernet0/0/15]port default vlan 30 [LSW2-GigabitEthernet0/0/16]port default vlan 30 [LSW2-port-group-pvlan30]qu [LSW2]interface g0/0/24 [LSW2-GigabitEthernet0/0/24]port link-type trunk [LSW2-GigabitEthernet0/0/24]port trunk allow-pass vlan 10 30 #这里也可以写 allow-pass vlan all [LSW2-GigabitEthernet0/0/24]qu [LSW2]display vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- 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(D) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(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/9(U) GE0/0/10(D) GE0/0/11(D) GE0/0/12(U) TG:GE0/0/24(U) 30 common UT:GE0/0/13(U) GE0/0/14(D) GE0/0/15(D) GE0/0/16(U) TG:GE0/0/24(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 30 enable default enable disable VLAN 0030 [LSW2]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 hybrid 1 - GigabitEthernet0/0/2 hybrid 1 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 access 10 - GigabitEthernet0/0/10 access 10 - GigabitEthernet0/0/11 access 10 - GigabitEthernet0/0/12 access 10 - GigabitEthernet0/0/13 access 30 - GigabitEthernet0/0/14 access 30 - GigabitEthernet0/0/15 access 30 - GigabitEthernet0/0/16 access 30 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 trunk 1 1 10 30
至此,PC-10-1能跨网段ping通PC-10-3,同理PC-30-1能跨网段ping通PC-30-3
查看捕获的以太网帧是否带标记,首先需要显示vlan id,步骤如下:
编辑--->首选项
number下拉,选择802.1Q VLAN id
这里对LSW1的g0/0/9进行抓包,其link-type为access
对于普通终端的连接,是不需要vlan标记的
这里对LSW1的g0/0/24进行抓包,其link-type为trunk,并且带vlan标记,用于标识该数据帧属于哪个 VLAN。