创建虚拟局域网(VLAN)能够控制广播,增强网络安全性,简化网络管理,可以根据网络用户的位置,作用或部门等进行划分。

   在公司里有时候需要实现不同switch之间的VLAN进行通信,怎么做呢?其实很简单在switch之间建立trunk中继链路即可。

 

首先在GNS3上新建实验拓扑图,我使用的是三层交换机所以会有R1R2这样的标号

wKioL1PiMaXD37UfAAFHyCXWVlE970.jpg


2.R1上输入命令

 
enable
vlan database
vlan 10 name caiwu
vlan 20 name shichang
exit
configure terminal
interface fastEthernet 1/1
switchport mode access
switchport access vlan 10
interface fastEthernet 1/2
switchport mode access
switchport access vlan 20
interface range f1/14 - 15
channel-group 1 mode on
interface port-channel 1
switchport trunk encapsulation dot1q
switchport mode trunk
end


 

 

R2上输入命令

sw2:
en
vlan database
vlan 10 name caiwu
vlan 20 name shichang
exit
configure terminal
interface fastEthernet 1/3
switchport mode access
switchport access vlan 10
interface fastEthernet 1/4
switchport mode access
switchport access vlan 20
interface range f1/14 - 15
channel-group 1 mode on
interface port-channel 1
switchport trunk encapsulation dot1q
switchport mode trunk
end


 

 

 

GNS3vpcs上配置主机的IP地址

wKioL1PiMe2BCTSuAAGJ3FNWcBI205.jpg


验证实验的结果,即在VLAN10 host1能和host3正常通信,在VLAN20 host2能和host4正常通信

 

wKioL1PiMgnxyJpGAACbovBE-s0451.jpg