华为交换机:基于mac地址的vlan
程序员文章站
2024-03-21 08:59:22
...
sw2
<Huawei>sys
[Huawei]sysname sw2
[sw2]
[sw2]un in en #关闭消息回执
Info: Information center is disabled.
[sw2]vlan batch 10 20
[sw2]int g0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 10
[sw2-GigabitEthernet0/0/2]q
[sw2]int g0/0/3
[sw2-GigabitEthernet0/0/3]port link-type access
[sw2-GigabitEthernet0/0/3]port default vlan 20
[sw2-GigabitEthernet0/0/3]q
[sw2]dis 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(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 UT:GE0/0/2(U)
20 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
[sw2]
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
sw1
The device is running!
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn
[Huawei]sysname sw1
[sw1]
[sw1]
[sw1]int g0/0/2
[sw1]un in en
[sw1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20
[sw1-GigabitEthernet0/0/2]q
[sw1]vlan batch 10 20
[sw1]vlan 10
[sw1-vlan10]mac-vlan mac-address 0000-0000-0001
[sw1-vlan10]q
[sw1]vlan 20
[sw1-vlan20]mac-vlan mac-address 0000-0000-0002
[sw1-vlan20]q
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port hybrid untagged vlan 10 20 #让g0/01属于多个vlan
[sw1-GigabitEthernet0/0/1]mac-vlan enable #开启基于mac的学习vlan
[sw1]dis 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(U) GE0/0/2(U) 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/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(U)
TG:GE0/0/2(U)
20 common UT:GE0/0/1(U)
TG:GE0/0/2(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
[sw1]
说明:tag
可以称为带标签的数据帧,所以untag
即为不带标签;tagged
为带标签发送,untagged
为去掉标签后发送。上面这行port hybrid untagged vlan 10 20
的意思是让端口属于vlan10和20,发送数据帧时不打标签。
sw3
sw3我们当作傻瓜交换机用,什么都不用配置。
更改PC1和PC2的MAC
验证结果
用PC1 ping vlan10-server
PC>ping 192.168.1.5
Ping 192.168.1.5: 32 data bytes, Press Ctrl_C to break
From 192.168.1.5: bytes=32 seq=1 ttl=128 time=94 ms
From 192.168.1.5: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.1.5: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.1.5: bytes=32 seq=4 ttl=128 time=62 ms
--- 192.168.1.5 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/70/94 ms
用PC1 ping vlan20-server
PC>ping 192.168.1.6
Ping 192.168.1.6: 32 data bytes, Press Ctrl_C to break
From 192.168.1.1: Destination host unreachable
From 192.168.1.1: Destination host unreachable
From 192.168.1.1: Destination host unreachable
From 192.168.1.1: Destination host unreachable
From 192.168.1.1: Destination host unreachable
--- 192.168.1.6 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC>
用PC2 ping vlan10-server
PC>ping 192.168.1.5
Ping 192.168.1.5: 32 data bytes, Press Ctrl_C to break
From 192.168.1.2: Destination host unreachable
From 192.168.1.2: Destination host unreachable
From 192.168.1.2: Destination host unreachable
From 192.168.1.2: Destination host unreachable
From 192.168.1.2: Destination host unreachable
--- 192.168.1.5 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC>
用PC2 ping vlan20-server
PC>ping 192.168.1.6
Ping 192.168.1.6: 32 data bytes, Press Ctrl_C to break
From 192.168.1.6: bytes=32 seq=1 ttl=128 time=78 ms
From 192.168.1.6: bytes=32 seq=2 ttl=128 time=78 ms
From 192.168.1.6: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.1.6: bytes=32 seq=4 ttl=128 time=79 ms
From 192.168.1.6: bytes=32 seq=5 ttl=128 time=62 ms
--- 192.168.1.6 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/71/79 ms
PC>
上一篇: MySQL之间数据同步
下一篇: HUAWEI——动态路由(RIPv2)