Assigning and Deleting Ports

Assigning Ports to VLAN

Once VLAN is created, then the next step is assigning ports to the VLAN. Port in access mod can belong to only one VLAN at a time. Only in one case when the access port is connected to an IP phone, there are two VLAN associated with this port, one for voice and one for data. Following is the syntax for defining a port to be an access port and assigning it to a VLAN.

Enter Global Configuration Mode Switch1# configure Terminal
Enter interface Configuration Mode Switch1(Config)# interface interface_id
Set the Port to access Mode Switch1(Config-if)# switchport mode access
Assign Ports to VLAN Switch1(Config-if)# switchport access vlan vlan-id
Return to the Privileged EXEC Mode Switch1(Config-if)#end

AssigningThe command switch port mode access is optional, although this command is strongly recommended for a security. This command changes the switch interface permanently to access mode. To execute the command for more than one interface we can use the interface range command.

In the Figure below, VLAN 10 is assigned to port Fa0/1, Fa0/2 on switch1 as a result, the PC2 and PC3 are in VLAN 10 and VLAN is assigned port fa 0/3 and fa0/4, so PC4 and PC5 is the part of VLAN 20. We can use the Syntax Checker show vlan brief command to display the contents of the vlan.dat file.

assigning ports

If VLAN does not exist the switchport access vlan command forces the creation of a VLAN on the switch. For example, VLAN 100 does not exist in the output of show vlan brief command. If the switchport access vlan 30 commands entered on an interface without any prior configuration, then the will display the following:

% Access VLAN does not exist. Creating VLAN 100

Now we can show the vlan.dat file using show vlan brief command.

Changing VLAN Port Membership

There are several ways to change the VLAN port association. The table below shows the syntax for changing a switch port membership to VLAN 1 with the no switchport access vlan interface configuration mode command.

Enter Global Configuration Mode Switch1# configure Terminal
Enter interface Configuration Mode Switch1(Config)# interface interface_id
Assign Ports to VLAN Switch1(Config-if)# no switchport access vlan vlan-id
Return to the Privileged EXEC Mode Switch1(Config-if)#end

VLAN 10 has assigned interface Fa0/1. The no switchport access vlan command is entered for interface Fa0/1 and Fa0/2, now check the output in the show vlan brief command that instantly follows as shown in Figure 2. The show vlan brief command displays the VLAN association and type for all switch ports. The show vlan brief command shows one line for every VLAN. The output for every VLAN includes the name, status, and switch ports.

assigning ports

VLAN 10 is still active, but there are no ports in the VLAN. In Figure 3, the show interfaces f0/1 switchport and show interfaces f0/2 switchport output verifies that the access VLAN for Fa0/1 interface and fa0/2 interface has been reset to VLAN 1. It is not required to first remove a port from a VLAN for changing its membership. Now we can again assign these ports to any VLAN.

Please follow and like us: