Cisco switches VLAN configuration with access and trunk ports

Before all start with elevating access through enable command.

Initial configuration of the VLAN.

Switch# conf t
Switch(config)# vlan 254
Switch(config-vlan)# name Production
Switch(config-vlan)# end

Adding interface to a single VLAN in access mode.

Switch# conf t
Switch(config)# interface FastEthernet 0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 254
Switch(config-if)# end
Switch# copy running-config startup-config
Destination filename [startup-config]? [press enter]

Adding interface to multiple VLANs in trunk mode. Before enabling trunk mode the port encapsulation must be set to dot1q. Below configuration will allow all VLANs on the switch.

Switch# conf t
Switch(config)# interface FastEthernet 0/48
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# switchport mode trunk

If a set of only specific VLANs need to be allowed on that port the below configuration is needed. This will allow only VLANs 172 and 254, all other VLANs that are configured on the switch will not be available through that port.

Switch# conf t
Switch(config)# interface FastEthernet 0/48
Switch(config-if)# switchport trunk allowed vlan 172,254

On a trunk configured port, a VLAN can be configured in an access mode, if that is needed.

Switch# conf t
Switch(config)# interface FastEthernet 0/48
Switch(config-if)# switchport trunk native vlan 192
Switch(config-if)# end
Switch# copy running-config startup-config
Destination filename [startup-config]? [press enter]

If multiple interfaces need to be configured in the same way, a range can be used.

Switch# conf t
Switch(config)# interface range FastEthernet 0/1 - 24
Switch(config-if)# switchport access vlan 254

Leave a Reply