3.22.2 Port VLAN Configuration

This command defines the port mode as access (default), trunk, or hybrid unconditionally.

Command Syntax:

switchport mode { access | trunk | hybrid }
Table 3-93. Command Desccription

Argument

Description

Parameter

access

Configure a switch port to Access mode.

trunk

Configure a switch port to Trunk mode.

hybrid

Configure a switch port to Hybrid mode.

Default

The switch port default mode is access

Mode

Port List Interface mode

Usage

Set port mode. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure the port 3 mode as trunk.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode trunk

Configure VLAN ID to be added internally by the Switch whenever native VLAN packet (packet with no VLAN header) is received.

Command Syntax:

switchport trunk native vlan <pvid>
switchport hybrid native vlan <pvid> 
Table 3-94. Command Description

Argument

Description

Parameter

<pvid>

VLAN ID of the native VLAN when this port is in trunk/hybrid mode.

Default

Trunk/Hybrid native default VLAN is VLAN1

Mode

Port List Interface mode

Usage

Configure a port VLAN ID for a trunk/hybrid port. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as trunk with PVID 4.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode trunk
(config-if)# switchport trunk native vlan 4

Port in Trunk mode may control the tagging of frames on egress. Options are default Untag Port VLAN (frames classified to the Port VLAN are transmitted untagged and all other frames are transmitted with the relevant tag) and Tag all (all frames transmitted with a tag).

Command Syntax:

switchport trunk vlan tag native
Table 3-95. Command Description

Argument

Description

Parameter

N.A

N.A

Default

Frames classified to the Port VLAN (Native VLAN) do not get tagged on egress.

Mode

Port List Interface mode

Usage

Set the trunk port egress tagging to all. To revert to the default (untag native VLAN), use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as trunk with PVID 4 and set egress tagging to tag all.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode trunk
(config-if)# switchport trunk native vlan 4
(config-if)# switchport trunk vlan tag native

Ports in Trunk and Hybrid mode may control which VLANs they are allowed to become members of. By default, Trunk or Hybrid port will become a member of all VLANs (1–4095). The ports can also be configured to never become members of one or more VLANs (forbidden VLANs).

Command Syntax:

switchport trunk allowed vlan { all | none | [ add | remove | except ] <vlan_list> }
switchport forbidden vlan { add | remove } <vlan_list>
Table 3-96. Command Description

Argument

Description

Parameter

all

all VLANs are allowed (1–4095)

none

Port will not become member of any VLAN

add

Add VLANs to the current list

remove

Remove VLANs from the current list

except

All VLANs except the following (VLAN ID or list)

<vlan_list>

VLAN IDs. Individual elements are separated by commas and ranges are specified with a dash.

Default

All VLANs are allowed (1–4095)

Mode

Port List Interface mode

Usage

Configure allowed/forbidden VLANs for a port. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as trunk and exclude VLAN 10, 30, 31, and 32 from allowed VLANs.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode trunk
(config-if)# switchport trunk allowed vlan except 10,30-32

Example 2:

Configure port 3 as trunk and add VLAN 4 to the list of forbidden VLANs.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode trunk
(config-if)# switchport forbidden vlan add 4

Use this command to specify the port type in Hybrid mode.

Command Syntax:

switchport hybrid port-type { unaware | c-port | s-port | s-custom-port }

Argument

Description

Parameter

unaware

Port is not aware of VLAN tags. No matter the received frame is tagged or untagged, port adds a tag (based on PVID) to the frame and then forward it.

c-port

Customer port. If the received frame is untagged, the C-port adds a tag (based on the PVID) to the frame and then forwards it. If the frame is already tagged, the C-port forwards it without adding a tag.

s-port

Provider port. Port only accepts untagged frames. If the received frame is untagged, S-port adds a tag (based on PVID) to the frame and then forwards it. If the frame is already tagged, it is discarded.

s-custom-port

Custom provider port. When Ethertype is set to 0x8100, S-custom ports do the same as C-ports: If the received frame is untagged, S-custom port adds a tag (based on PVID) to the frame and then forward it; If the frame is already tagged, it will be forwarded without adding a tag.

Default

Hybrid port type is C-port

Mode

Port List Interface mode

Usage

Configure Hybrid port type. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as hybrid Unaware type.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode hybrid
(config-if)# switchport hybrid port-type unaware

Use this command to enable/disable ingress filtering on hybrid ports. Access and Trunk ports always have ingress filtering enabled. Set Ingress acceptance criteria.

Command Syntax:

switchport hybrid ingress-filtering 
switchport hybrid acceptable-frame-type { all | tagged | untagged }
Table 3-97. Command Description

Argument

Description

Parameter

all

Both tagged and untagged frames are accepted

tagged

Only frames tagged with the corresponding port type tag are accepted.

untagged

Only untagged frames are accepted.

Default

Ingress filtering disabled. Hybrid port is set to accept all frames (tagged and untagged)

Mode

Port List Interface mode

Usage

Enable ingress filtering and configure type of frames accepted on ingress. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as hybrid, enable ingress fltering and accept tagged frames only on ingress.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode hybrid
(config-if)# switchport hybrid ingress-filtering
(config-if)# switchport hybrid acceptable-frame-type tagged

Use this command to configure Egress tagging on Hybrid port.

Command Syntax:

switchport hybrid egress-tag { none | all [ except-native ] } 
Table 3-98. Command Description

Argument

Description

Parameter

none

No Egress tagging. All frames transmitted without a tag.

all

Tag all frames. All frames are transmitted with a tag.

except-native

Tag all frames except frames classified to native VLAN.

Default

Hybrid port is set to tag all frames except frames classified to native VLAN.

Mode

Port List Interface mode

Usage

Configure egress tagging. To revert to the default, use the ‘no’ version of the command.

Example

Example 1:

Configure port 3 as hybrid and set egress tagging to all.

# configure terminal
(config)# interface GigabitEthernet 1/3
(config-if)# switchport mode hybrid
(config-if)# switchport hybrid egress-tag all