The Switchport Access Vlan [Vlan Number] Cisco command
Command: switchport access vlan [vlan number]
Function: Assigns a specific VLAN to an access port on a Cisco switch, limiting the port's communication to devices within that VLAN.
Usage:
- Enter the command in the privileged EXEC mode of the switch.
- Specify the interface or port number to configure.
- Use the 'switchport access vlan' keyword to assign the VLAN.
- Specify the VLAN number or name. Make sure the VLAN exists or is created before assigning it to the port.
Purpose:
- The 'switchport access vlan' command is used to configure a switch port as an access port, restricting traffic on the port to a specific VLAN.
- It allows for the segmentation of a network into different VLANs, improving security and network performance by limiting the broadcast domain to devices within the same VLAN.
Equipment:
- This command is typically used on Cisco switches that support VLANs and port-based VLAN assignment.
- The specific models and series of switches that support this command may vary, but it is commonly found on Cisco Catalyst switches, Cisco Nexus switches, and other Cisco switching platforms.
Additional Information:
- The 'switchport access vlan' command works in conjunction with other switchport commands, such as 'switchport mode access', to fully configure a port as an access port.
- When a port is configured as an access port, traffic from devices connected to that port is tagged with the assigned VLAN ID, ensuring that traffic is forwarded only to other devices within the same VLAN.
- This command can also be used to change the VLAN assignment of an existing access port, allowing for flexible network reconfiguration.
switchport access vlan [vlan number] Usage Examples
- To configure switchport access vlan 10 on interface GigabitEthernet 0/1:
switchport access vlan 10
- To configure switchport access vlan 10 and disable Dynamic Trunking Protocol (DTP) on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport mode access
- To configure switchport access vlan 10 and set the port priority to 5 on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport priority 5
- To configure switchport access vlan 10 and set the port cost to 10 on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport cost 10
- To configure switchport access vlan 10 and enable port security on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport port-security
- To configure switchport access vlan 10 and set the maximum number of allowed MAC addresses to 5 on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport port-security maximum 5
- To configure switchport access vlan 10 and enable sticky learning on interface GigabitEthernet 0/1:
switchport access vlan 10
switchport sticky
- To configure switchport access vlan 10 and enable spanning tree PortFast on interface GigabitEthernet 0/1:
switchport access vlan 10
spanning-tree portfast
- To configure switchport access vlan 10 and disable spanning tree PortFast on interface GigabitEthernet 0/1:
switchport access vlan 10
spanning-tree portfast disable