任务需求
公司的财务处、人事处、行政处、总经办分别在不同的楼层,现四个部门的同事需要共享资料,如何利用VLAN技术实现?
在核心交换机SWA创建VLAN10、VLAN20、VLAN30、VLAN40。
交换机启用gvrp。
接入层交换机学习到SWA的vlan。
所有VLAN间可以进行通信。
拓扑图
代码
(1)LSW1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]vlan batch 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int vlan 10
[Huawei-Vlanif10]ip add 192.168.10.1 24
[Huawei-Vlanif10]quit
[Huawei]int vlan 20
[Huawei-Vlanif20]ip add 192.168.20.1 24
[Huawei-Vlanif20]quit
[Huawei]int vlan 30
[Huawei-Vlanif30]ip add 192.168.30.1 24
[Huawei-Vlanif30]quit
[Huawei]int vlan 40
[Huawei-Vlanif40]ip add 192.168.40.1 24
[Huawei-Vlanif40]quit
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk all vlan 10 20 30 40
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type trunk
[Huawei-GigabitEthernet0/0/2]port trunk all vlan 10 20 30 40
[Huawei-GigabitEthernet0/0/2]quit
[Huawei]gvrp
[Huawei]user-interface console 0
[Huawei]user-interface vty 0 4
(2)LSW2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]vlan ba 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]port link-type trunk
[Huawei-Ethernet0/0/1]port trunk all vlan 10 20 30 40
[Huawei-Ethernet0/0/1]quit
[Huawei]int e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 10
[Huawei-Ethernet0/0/2]quit
[Huawei]int e0/0/3
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 20
[Huawei-Ethernet0/0/3]quit
[Huawei]gvrp
[Huawei]user-interface con 0
[Huawei]user-interface vty 0 4
(3)LSW3
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]vlan ba 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]port link-type trunk
[Huawei-Ethernet0/0/1]port trunk all vlan 10 20 30 40
[Huawei-Ethernet0/0/1]quit
[Huawei]int e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 30
[Huawei-Ethernet0/0/2]quit
[Huawei]int e0/0/3
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 40
[Huawei-Ethernet0/0/3]quit
[Huawei]gvrp
[Huawei]user-interface con 0
[Huawei]user-interface vty 0 4
测试
PC1与PC2、PC3、PC4通信情况
PC>ping 192.168.20.5
Ping 192.168.20.5: 32 data bytes, Press Ctrl_C to break
From 192.168.20.5: bytes=32 seq=1 ttl=127 time=140 ms
From 192.168.20.5: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.20.5: bytes=32 seq=3 ttl=127 time=93 ms
From 192.168.20.5: bytes=32 seq=4 ttl=127 time=79 ms
From 192.168.20.5: bytes=32 seq=5 ttl=127 time=94 ms
--- 192.168.20.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 79/100/140 ms
PC>ping 192.168.30.5
Ping 192.168.30.5: 32 data bytes, Press Ctrl_C to break
From 192.168.30.5: bytes=32 seq=1 ttl=127 time=125 ms
From 192.168.30.5: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.30.5: bytes=32 seq=3 ttl=127 time=94 ms
From 192.168.30.5: bytes=32 seq=4 ttl=127 time=109 ms
From 192.168.30.5: bytes=32 seq=5 ttl=127 time=110 ms
--- 192.168.30.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 94/106/125 ms
PC>ping 192.168.40.5
Ping 192.168.40.5: 32 data bytes, Press Ctrl_C to break
From 192.168.40.5: bytes=32 seq=1 ttl=127 time=125 ms
From 192.168.40.5: bytes=32 seq=2 ttl=127 time=125 ms
From 192.168.40.5: bytes=32 seq=3 ttl=127 time=141 ms
From 192.168.40.5: bytes=32 seq=4 ttl=127 time=109 ms
From 192.168.40.5: bytes=32 seq=5 ttl=127 time=94 ms
--- 192.168.40.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 94/118/141 ms