Assigning a VLAN ID to a trunk interface

Prerequisites
至少有一个定义的VLAN。
Procedure
  1. Switch to configuration context with the commandconfig.
  2. Switch to the interface that you want to define as a trunk interface with the commandinterface.
  3. Disable routing with the commandno routing.
  4. Configure the trunk interface and assign a VLAN ID with the commandvlan trunk allowed.

Examples

This example configures interface1/1/2as a trunk interface allowing traffic with VLAN ID set to20.
switch#configswitch(config)#vlan 20switch(config-vlan-20)#exitswitch(config)#interface 1/1/2switch(config-lag-if)#no routingswitch(config-if)#vlan trunk allowed 20
This example configures interface1/1/2as a trunk interface allowing traffic with VLAN IDs2,3, and4.
switch#configswitch(config)#vlan 2,3,4switch(config)#interface 1/1/2switch(config-lag-if)#no routingswitch(config-if)#vlan trunk allowed 2,3,4
This example configures interface1/1/2as a trunk interface allowing traffic with VLAN IDs2to 8.
switch#configswitch(config)#vlan 2-8switch(config)#interface 1/1/2switch(config-lag-if)#no routingswitch(config-if)#vlan树干允许2 - 8
This example configures interface1/1/2as a trunk interface allowing traffic with VLAN IDs2to 8 and10.
switch#configswitch(config)#vlan 2-8,10switch(config)#interface 1/1/2switch(config-lag-if)#no routingswitch(config-if)#vlan树干允许2 - 8,10
This example configures interface1/1/2as a trunk interface allowing traffic on all configured VLAN IDs (20-100).
switch#configswitch(config)#vlan 20-100switch(config)#interface 1/1/2switch(config-lag-if)#no routingswitch(config-if)#vlan trunk allowed all