注:switchport mode trunk 在 2950 交换机上可直接运行,这将直接启用802.1q。在3550、4500 等交换机上要启用中继功能必须先选择封装方法,也就是要先运行 switchport trunk encapsulation dot1q 。
![](http://img1.51cto.com/attachment/201202/001523174.jpg)
sw0#vlan database
sw0(vlan)#vtp domain Contoso
sw0(vlan)#vtp password Contoso
sw0(vlan)#vtp server
sw0(vlan)#vlan 10
sw0(vlan)#vlan 20
sw0(config)#interface range gigabitEthernet 0/1-2
sw0(config-if-range)#switchport trunk encapsulation dot1q
sw0(config-if-range)#switch mode trunk
sw0(config)#interface vlan 10
sw0(config-if)#ip address 192.168.0.1 255.255.255.0
sw0(config)#interface vlan 20
sw0(config-if)#ip address 192.168.1.1 255.255.255.0
sw1#vlan database
sw1(vlan)#vtp domain Contoso
sw1(vlan)#vtp password Contoso
sw1(vlan)#vtp client
sw1(config)#interface gigabitEthernet 1/1
sw1(config-if)#switchport mode trunk
sw1(config)#interface range fastEthernet 0/1-10
sw1(config-if-range)#switchport access vlan 10
sw2#vlan database
sw2(vlan)#vtp domain Contoso
sw2(vlan)#vtp password Contoso
sw2(vlan)#vtp client
sw2(config)#interface gigabitEthernet 1/1
sw2(config-if)#switchport mode trunk
sw2(config)#interface range fastEthernet 0/1-10
sw2(config-if-range)#switchport access vlan 20
相关查看命令
show interface trunk
show vlan
show vtp status
show interfaces gigabitEthernet 0/1 switchport