Configuring a VLAN in trunk mode

Do the following to add or remove VLANs on a Layer 2 interface in trunk mode. The configuration is also used to configure the VLANs to send and receive data packets.

Before you begin

Ensure that reserved VLANs are not used.

Procedure

  1. Enter the configure terminal command to access global configuration mode.
    device# configure terminal 
  2. Enter the interface ethernet command to specify an Ethernet interface.
    device(config)# interface ethernet 0/1
    
  3. Enter the switchport command to set the interface as switchport.
    device(conf-if-eth-0/1)# switchport
    
  4. Enter the switchport trunk allowed vlan command to set the mode of the interface to trunk and add a VLAN.
    device(conf-if-eth-0/1)# switchport trunk allowed vlan add 5
    

Example

The example sets the mode of the Ethernet interface to trunk.

device# configure terminal
device(config)# interface ethernet 0/1
device(conf-if-eth-0/1)# switchport mode trunk

Example

The example sets the mode of a port-channel interface to trunk and allows all VLANs.

device# configure terminal
device(config)# interface port-channel 35
device(config-Port-channel-35)# switchport trunk allowed vlan all