Assigning Ports to VLANs

In this article we will discuss Assigning Ports to VLANs, will make brief discussion on Assigning Ports to VLANs, In last article we discuss about Creating a VLAN.

After creating a VLAN, the next step is to assign ports to the VLAN.

The switchport mode access command is optional, but strongly recommended as a security best practice. With this command, the interface changes to permanent access mode.

Note: Use the interface range command to simultaneously configure multiple interfaces.

VLAN 20 is assigned to port F0/18 on switch S1. Any device connected to that port is associated with VLAN 20. Therefore, in our example, PC2 is in VLAN 20.

It is important to note that VLANs are configured on the switch port and not on the end device. PC2 is configured with an IPv4 address and subnet mask that is associated with the VLAN, which is configured on the switch port. In this example, it is VLAN 20. When VLAN 20 is configured on other switches, the network administrator must configure the other student computers to be in the same subnet as PC2 (

An access port can belong to only one VLAN at a time. However, one exception to this rule is that of a port connected to an IP phone and an end device. In this case, there would be two VLANs associated with the port: one for voice and one for data.

In this example, PC5 is connected to the Cisco IP phone, which in turn is connected to the FastEthernet 0/18 interface on S3. To implement this configuration, VLAN 20 and the voice VLAN 150 are created.

Use the switchport voice vlan vlan-# interface configurationcommandto assign a voice VLAN to a port.

LANs supporting voice traffic typically also have Quality of Service (QoS) enabled. Voice traffic must be labeled as trusted as soon as it enters the network. Use the mls qos trust[cos | device cisco-phone | dscp | ip-precedence] interface configuration command to set the trusted state of an interface, and to indicate which fields of the packet are used to classify traffic.

Creates the two VLANs (i.e., VLAN 20 and VLAN 150) and then assigns the F0/18 interface of S3 as a switchport in VLAN 20. It also assigns voice traffic to VLAN 150 and enables QoS classification based on the class of service (CoS) assigned by the IP phone.

The switchport access vlan command forces the creation of a VLAN if it does not already exist on the switch. For example, VLAN 30 is not present in the show vlan brief output of the switch. If the switchport access vlan 30 command is entered on any interface with no previous configuration, then the switch displays the following:

% Access VLAN does not exist. Creating vlan 30

Add a Comment

Your email address will not be published. Required fields are marked *