Create a VLAN and assign ports on a Cisco switch
This example is for Cisco switches running IOS or IOS XE. It creates VLAN 10, names it SALES, and assigns GigabitEthernet1/0/1 through 1/0/4 to it. Replace the VLAN number, name, and port names as needed for your switch.
Create the VLAN and assign ports
enable
configure terminal
vlan 10
name SALES
exit
interface range GigabitEthernet1/0/1 - 4
switchport mode access
switchport access vlan 10
no shutdown
end
copy running-config startup-config| Command | What it does |
|---|---|
enable | Enters privileged mode, allowing administration commands. |
configure terminal | Enters global configuration mode. |
vlan 10 | Creates VLAN 10, or opens its settings if it already exists. |
name SALES | Gives the VLAN the descriptive name SALES. |
exit | Returns from VLAN settings to global configuration mode. |
interface range GigabitEthernet1/0/1 - 4 | Selects ports 1 through 4 so the following commands affect all four. |
switchport mode access | Makes the selected ports access ports, typically used for computers or printers. |
switchport access vlan 10 | Assigns the selected ports to VLAN 10. |
no shutdown | Enables the ports if they were administratively disabled. |
end | Leaves configuration mode and returns to privileged mode. |
copy running-config startup-config | Saves the configuration so it survives a restart. Press Enter to accept the destination filename if prompted. |
Add one more port later
This example adds GigabitEthernet1/0/5 to VLAN 10:
configure terminal
interface GigabitEthernet1/0/5
switchport mode access
switchport access vlan 10
no shutdown
end
copy running-config startup-configinterface GigabitEthernet1/0/5 selects only port 5. The remaining commands have the same meanings as above. Run these commands from privileged mode (the prompt ends in #); use enable first if your prompt ends in >.
Verify the configuration
Run these commands from privileged mode:
show vlan brief
show interfaces GigabitEthernet1/0/1 switchport| Command | What it does |
|---|---|
show vlan brief | Lists VLANs and their assigned access ports. Look for VLAN 10, SALES, and the selected ports. |
show interfaces GigabitEthernet1/0/1 switchport | Shows port 1’s switching mode and access VLAN. Look for access mode and VLAN 10. |
Notes
- Port names vary by model, for example
FastEthernet0/1,GigabitEthernet0/1, orGigabitEthernet1/0/1. - Assigning a port to VLAN 10 changes its existing access VLAN membership.
- Use these access-port commands for end-device ports. A link carrying multiple VLANs between switches needs trunk configuration.
- Devices in different VLANs need a router or Layer 3 switch to communicate.
- Creating a VLAN does not configure device IP addresses, DHCP, or routing.