二层交换机实现不同vlan通信
实验拓扑
一、 第一种实现方式:
sw1:
vlan batch 10 20
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 10 //默认为1,为了去标签改成10
port trunk allow-pass vlan 2 to 4094
sw2:
vlan batch 10 20
interface GigabitEthernet0/0/1
port link-type trunk
port trunk pvid vlan 20 //无标签打上20为了能够发到vlan20
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/2
port link-type trunk
port trunk pvid vlan 10 //无标签打上10为了能够发到vlan10
port trunk allow-pass vlan 2 to 4094
sw3:
vlan batch 10 20
interface GigabitEthernet0/0/1
port link-type trunk
port trunk pvid vlan 20 //为了去标签
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
实验原理:
Access链路
收包时打标签 pvid
发包时去标签
Trunk链路
发包时如果pvid相同则去标签(默认pvid=1)可以修改,如果pvid不同直接发送不改标签
收包时如果有标签直接收,无标签打标签转发
二、第二种实现方式:所有链路类型改成access
Sw1
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
sw2
interface GigabitEthernet0/0/1
port link-type access
port default vlan 20
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
sw3
interface GigabitEthernet0/0/1
port link-type access
port default vlan 20
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
三、第三种实现方式:Hybrid类型
Sw1
interface GigabitEthernet0/0/1
port hybrid pvid vlan 10
port hybrid untagged vlan 10 20
interface GigabitEthernet0/0/2
port hybrid tagged vlan 10 20
sw2
interface GigabitEthernet0/0/1
port hybrid tagged vlan 10 20
interface GigabitEthernet0/0/2
port hybrid tagged vlan 10 20
sw3
interface GigabitEthernet0/0/1
port hybrid tagged vlan 10 20
interface GigabitEthernet0/0/2
port hybrid pvid vlan 20
port hybrid untagged vlan 10 20
实验原理:
通过tag和untag确定哪种数据帧通过