Trunk配置实例

 如图,两台交换机SW1和SW2各划分了三个VLAN,端口配置如下:

  VLAN 1: F0/1 - F0/3: VLAN 2: F0/4 - F0/10 VLAN 3: F0/11 - F0/23

  

两台交换机的配置类似,现在以SW1为例,介绍Trunk配置与验证的过程

1.在交换机上添加vlan
 

 

sw1(config)#vlan 2

sw1(config-vlan)#exit

 

sw1(config)#vlan 3

sw1(config-vlan)#exit

 

 

2.将接口添加到相应的VLAN中,命令如下

sw1(config)#interface range f0/4 - 10

sw1(config-if)#switchport mode access

sw1(config-if)#switchport access vlan 2

 

 

sw1(config)interface range f0/11 - 23

sw1(config-if)#switchport mode access

sw1(config-if)#switchport access vlan 3

 

 

3.配置交换机之间互联的端口为Trunk模式,命令如下

sw1(config)#interface f0/24

sw1(config-if)switchport mode trunk

4.在另一台交换机上执行类似的配置,配置完成后,使用show命令进行验证,命令如下。

 

SW1#show int fa0/24 switchport 

Name: Fa0/24

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Voice VLAN: none

Administrative private-vlan host-association: none

Administrative private-vlan mapping: none

Administrative private-vlan trunk native VLAN: none

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk private VLANs: none

Operational private-vlan: none

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

   在上面的命令输出中可以看出,在端口F0/24上配置接口模式为Trunk,并且工作模式也是Trunk,
   Trunk封装的协议是802.1Q,Trunk可以承载所有的VLAN。
 
5.如果不需要在Trunk上传输VLAN 2的数据,可以在Trunk上移除VLAN 2,如下所示
SW1(config)#interface fastEthernet 0/24
SW1(config-if)#switchport trunk allowed vlan remove 2
SW1(config-if)#exit
 

 

SW1#show int fa0/24 switchport 

Name: Fa0/24

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Voice VLAN: none

Administrative private-vlan host-association: none

Administrative private-vlan mapping: none

Administrative private-vlan trunk native VLAN: none

Administrative private-vlan trunk encapsulation: dot1q

Administrative private-vlan trunk normal VLANs: none

Administrative private-vlan trunk private VLANs: none

Operational private-vlan: none

Trunking VLANs Enabled: 1,3-1005

Pruning VLANs Enabled: 2-1001

Capture Mode Disabled

Capture VLANs Allowed: ALL

从上面show int fa0/24 switchport 命令的输出可以看出,Trunk中已经移除了VLAN2。

Trunk的排错

  VLAN中常见故障是设备不能跨越Trunk链路而建立连接。为了能够对Trunk接口的故障进行排错,需要验证下列配置是否正确。

1.接口模式

  要确保至少一则的链路的Trunk模式应当是Trunk或desirable。通过使用命令 show interfaces trunk 可以验证接口的Trunk配置。

2。封装类型

确保链路两端的Trunk的封装类型兼容