通过三层交换机实现 VLAN 间互通。 通过单臂路由实现 VLAN 间互通
实验一:通过三层交换机实现 VLAN 间互通。
网络拓扑图:
配置PC的IP地址、子网掩码、网关:
配置交换机S1的接口为Trunk,G0/0/1允许vlan 10通过、G0/0/2允许vlan 20 通过
[S1]vlan batch 10 20
[S1]int g0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10
[S1-GigabitEthernet0/0/1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan 20
[S1-GigabitEthernet0/0/2]quit
[S1]
配置S1两个vlan的IP地址:
[S1]int vlanif 10
[S1-Vlanif10]ip add 192.168.100.1 24
[S1-Vlanif10]quit
[S1]int vlanif 20
[S1-Vlanif20]ip add 192.168.200.1 24
查看S1的配置路由结果
[S1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.100.0/24 Direct 0 0 D 192.168.100.1 Vlanif10
192.168.100.1/32 Direct 0 0 D 127.0.0.1 Vlanif10
192.168.200.0/24 Direct 0 0 D 192.168.200.1 Vlanif20
192.168.200.1/32 Direct 0 0 D 127.0.0.1 Vlanif20
[S1]
接着配置S2的vlan10和连接pc端接口的Access接口:
[S2]vlan 10
[S2-vlan10]quit
[S2]int vlanif 10
[S2-Vlanif10]ip add 192.168.100.1 24
[S2]int e0/0/1
[S2-Ethernet0/0/1]port link-type access
[S2-Ethernet0/0/1]port default vlan 10
[S2-Ethernet0/0/1]int e0/0/2
[S2-Ethernet0/0/2]port link-type access
[S2-Ethernet0/0/2]port default vlan 10
[S2-Ethernet0/0/2]
同理配置S3:
[S3]vlan 20
[S3-vlan20]quit
[S3]int vlanif 20
[S3-Vlanif20]ip add 192.168.200.1 24
[S3]int e0/0/1
[S3-Ethernet0/0/1]port link-type access
[S3-Ethernet0/0/1]port default vlan 20
[S3-Ethernet0/0/1]int e0/0/2
[S3-Ethernet0/0/2]port link-type access
[S3-Ethernet0/0/2]port default vlan 20
[S3-Ethernet0/0/2]
接下来配置S2、S3连接三层交换机S1那一个接口为Trunk接口:
[S2-Ethernet0/0/2]int g0/0/1
[S2-GigabitEthernet0/0/1]port link-type trunk
[S2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S3-Ethernet0/0/2]int g0/0/1
[S3-GigabitEthernet0/0/1]port link-type trunk
[S3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
测试全网是否互通:
此处测试PC1ping通PC2和PC4ping通PC3
实验二:通过单臂路由实现Vlan间互通
网络拓扑图:
配置PC的IP 、子网掩码、网关:
首先配置S1的trunk接口:
[S1]int g0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
接着配置S1的两个连接PC的Access接口:
[S1]vlan batch 10 20
[S1]int g0/0/2
[S1-GigabitEthernet0/0/2]port link-type access
[S1-GigabitEthernet0/0/2]port default vlan 10
[S1-GigabitEthernet0/0/2]int g0/0/3
[S1-GigabitEthernet0/0/3]port link-type access
[S1-GigabitEthernet0/0/3]port default vlan 20
紧接着在Router上创建两个子接口,每个子接口配置IP地址和dot1Q封装VLANID
[R1]int g0/0/0.10
[R1-GigabitEthernet0/0/0.10]ip add 192.168.1.254 24
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.10]arp broadcast enable
[R1-GigabitEthernet0/0/0.10]int g0/0/0.20
[R1-GigabitEthernet0/0/0.20]ip add 192.168.2.254 24
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]arp broadcast enable
其中封装dot1q协议,这两个子接口分别对应vlan10和对应vlan20、并开启子接口的ARP广播
检测网络是否互通:
文章来源:https://www.toymoban.com/news/detail-487259.html
文章来源地址https://www.toymoban.com/news/detail-487259.html
到了这里,关于vlan的三层交换连通的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!