前言:通过三层交换技术构建vlan间路由,避免单臂路由配置繁杂,带宽承载力过小等问题,提高网络健壮性和可维护性。
PC1:192.168.1.10/24
PC2:192.168.2.20/24
PC3:192.168.2.21/24
PC4:192.168.3.30/24
1,创建vlan10、vlan20:
[SW2]vlan batch 10 20 //批量创建vlan10、vlan20
2,配置access类型接口,将eth0/0/1口划入vlan10:
(ATTENTION:只能先配置接口类型,才能划入vlan)
[SW2]int e0/0/1 //进入0/0/1口
[SW2-Ethernet0/0/1]port link-type access //配置接口类型access
[SW2-Ethernet0/0/1]port default vlan 10 //划分vlan10
3,将eth0/0/2口划入vlan20,配置access类型接口:
[SW2]int e0/0/2
[SW2-Ethernet0/0/2]port link-type access
[SW2-Ethernet0/0/2]port default vlan 20
4,配置eth0/0/3为trunk:
[SW2-Ethernet0/0/3]port link-type trunk
1,创建vlan20、vlan30:
[SW3]vlan batch 20 30
2, eth0/0/1口划入vlan20,配置access类型接口:
[SW3]int e0/0/1
[SW3-Ethernet0/0/1]port link-type access
[SW3-Ethernet0/0/1]port default vlan 20
3,eth0/0/2口划入vlan30,配置access类型接口:
[SW3]int Eth0/0/2
[SW3-Ethernet0/0/2]port link-type access
[SW3-Ethernet0/0/2]port default vlan 30
4, 配置eth0/0/3为trunk型接口:
[SW3]int Ethernet0/0/3
[SW3-Ethernet0/0/3]port link-type trunk
创建vlan10、vlan20、vlan30:
[SW6]vlan batch 10 20 30 //批量创建vlan10,vlan20,vlan30
配置eth0/0/1,eth0/0/2 为trunk接口,并允许全部vlan通信:
[SW6]int Eth0/0/1
[SW6-Ethernet0/0/1]port link-type trunk
[SW6-Ethernet0/0/1]port trunk allow-pass vlan all //允许通过所有vlan通过
[SW6]int Eth0/0/2
[SW6-Ethernet0/0/2]port link-type trunk
[SW6-Ethernet0/0/2]port trunk allow-pass vlan all
配置网关地址(缺省路由):
[SW6]int Vlanif 10
[SW6-Vlanif10]ip address 192.168.1.1 24
[SW6]interface Vlanif 20
[SW6-Vlanif20]ip address 192.168.2.1 24
[SW6]int Vlanif 30
[SW6-Vlanif30]ip address 192.168.3.1 24
vlanif:虚拟vlan接口,用来指明对应vlan网关。
不同vlan,不同网关之间可以ping通。
方法:各个PC互ping
PC>ping 192.168.3.30
Ping 192.168.3.30: 32 data bytes, Press Ctrl_C to break
From 192.168.3.30: bytes=32 seq=1 ttl=127 time=78 ms
From 192.168.3.30: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.3.30: bytes=32 seq=3 ttl=127 time=63 ms
From 192.168.3.30: bytes=32 seq=4 ttl=127 time=94 ms
From 192.168.3.30: bytes=32 seq=5 ttl=127 time=78 ms
--- 192.168.3.30 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 63/78/94 ms
PC>ping 192.168.2.21
Ping 192.168.2.21: 32 data bytes, Press Ctrl_C to break
From 192.168.2.21: bytes=32 seq=1 ttl=127 time=94 ms
From 192.168.2.21: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.2.21: bytes=32 seq=3 ttl=127 time=78 ms
From 192.168.2.21: bytes=32 seq=4 ttl=127 time=78 ms
From 192.168.2.21: bytes=32 seq=5 ttl=127 time=63 ms
--- 192.168.2.21 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 63/78/94 ms
验证通过。