How to Configure a Cisco VLAN Step by Step
#The VLAN Bring-Up: From Flat Network to Segmented Access Layer on Cisco IOS#link
A Cisco Catalyst switch with no VLAN configuration is a single broadcast domain. Every host on every port hears every other host's ARP requests, DHCP discoveries, and broadcast chatter. That is fine for a lab bench and unacceptable for anything carrying user traffic. The moment a second department, a guest network, or a voice deployment enters the picture, VLANs stop being an optional design choice and become the baseline. The good news is that VLAN creation and port assignment on IOS is genuinely simple — about six commands for the happy path. The bad news is that the surrounding decisions (which VLAN for management, how to handle the native VLAN on trunks, why a VLAN shows up in the database but not in `show vlan brief`) are where most configurations go wrong. This guide walks through the full sequence on IOS-XE 17.12: creating the VLAN, assigning access ports, building a management SVI, and verifying that traffic is actually segmenting the way you intend.
TL;DR: Create VLANs with `vlan <id>` and `name <label>`, assign access ports with `switchport mode access` + `switchport access vlan <id>`, build a management SVI for reachability, and verify with `show vlan brief` and `show interfaces switchport`. The most common self-inflicted failure is assigning a port to a VLAN that does not exist in the database.
Prerequisites
- ▪A Cisco Catalyst switch running IOS 15.2E+ or IOS-XE 16.x/17.x — this guide uses IOS-XE 17.12 on a Catalyst 9200
- ▪Console or SSH access to the switch
- ▪A VLAN plan: VLAN IDs, names, and which access groups map to which IDs
- ▪An IP address plan for any VLAN that needs an SVI (management, inter-VLAN routing)
- ▪The default VLAN 1 left intact for control-plane traffic — do not delete it
- ▪A management workstation to test reachability after the SVI is up
Step 1 — Create the VLAN in the Database
VLANs on Cisco IOS are stored in a separate file called `vlan.dat` in flash, not in `running-config`. This is the single most important thing to understand about VLAN configuration: a `copy running-config startup-config` does not save VLAN definitions. If you create a VLAN, verify it works, and then back up only the running config, the VLAN will be gone after a reload. The first step is to create the VLAN in the database and give it a name. The name is not cosmetic — it appears in every `show vlan` output and makes an incident response session dramatically faster when you are staring at a list of VLAN IDs at 2 a.m.
VLAN IDs 1 through 1005 are considered normal-range VLANs and are stored in `vlan.dat`. Extended-range VLANs (1006–4094) are stored in `running-config` instead and behave differently with VTP. For most access-layer deployments, stick to the normal range.
Step 2 — Assign Access Ports to the VLAN
An access port carries a single VLAN to an end device. The default port mode on a Cisco switch is `dynamic auto`, which will become a trunk if the connected device negotiates it. That is dangerous — a malicious endpoint can spoof DTP and turn a user port into a trunk, gaining access to every VLAN on the switch. Always hardcode access ports with `switchport mode access` before assigning a VLAN. You can assign a range of ports in one command, which is the practical approach for a 24-port access block.
interface range GigabitEthernet1/0/1 - 20switchport mode accessswitchport access vlan 10spanning-tree portfastspanning-tree bpduguard enableexit!interface range GigabitEthernet1/0/21 - 24switchport mode accessswitchport access vlan 20switchport voice vlan 20spanning-tree portfastspanning-tree bpduguard enableexit
If you assign a port to a VLAN that does not exist in the VLAN database, the switch will silently create that VLAN for you. This is convenient until it is not: a typo in a `switchport access vlan` command creates a phantom VLAN with no name, and the port ends up in a broadcast domain you did not plan for. Always run `show vlan brief` after assigning ports and confirm the VLAN IDs match what you intended.
Step 3 — Build a Management SVI
A Layer 2 switch has no routed ports. To reach the switch over the network — for SSH, SNMP, or syslog — you need a Switch Virtual Interface (SVI), which is a logical interface that carries an IP address for the switch itself. The default management VLAN on every Cisco switch is VLAN 1, and using it for management is a well-known security antipattern: VLAN 1 carries STP, CDP, VTP, and DTP control traffic, and every port defaults to it. A dedicated management VLAN, reachable only from a restricted source range, is the correct design. The SVI requires an IP, a subnet mask, and a default gateway on a Layer 2 switch.
On a Layer 2 switch, `ip default-gateway` is required for the switch to reply to hosts outside its management subnet. A Layer 3 switch uses `ip routing` and does not need it. If SSH works from the local subnet but times out from a remote one, a missing `ip default-gateway` is the first thing to check.
Step 4 — Restrict Management Access to the SVI
An SVI with an IP address is reachable by anything that can route to it. The vty lines need an access-class to restrict SSH to a known management source range. Without this, the switch answers SSH from any network that can route to the management VLAN — which in a poorly segmented environment is every network.
ip access-list standard MGMT-ACCESSpermit 192.0.2.0 0.0.0.255deny any log!line vty 0 15transport input sshlogin localaccess-class MGMT-ACCESS inexec-timeout 10 0
Step 5 — Assign the Management VLAN to an Access Port
The management VLAN is only reachable if at least one port carries it. In a typical access-layer deployment, the management VLAN traverses the trunk uplink to the distribution layer, and a dedicated access port on the switch connects to an out-of-band management segment or a jump host. If the switch has no trunk uplink configured yet, assign a single access port to the management VLAN for initial testing.
interface GigabitEthernet1/0/26description MGMT access for jump hostswitchport mode accessswitchport access vlan 99spanning-tree portfastspanning-tree bpduguard enable
Step 6 — Verify the VLAN and Port Assignments
Three commands tell you whether the VLAN configuration is correct: `show vlan brief` lists every VLAN and the ports assigned to it, `show interfaces switchport` shows a single interface's administrative and operational modes, and `show ip interface brief` confirms the SVI is up. Run all three before saving.
Step 7 — Save the Configuration and the VLAN Database
This is the step that trips up people who are used to router configuration. On a router, `write memory` saves everything. On a switch, VLANs live in `vlan.dat` and interface configuration lives in `running-config` — they are separate files. Save both.
Troubleshooting
| Symptom | Likely Cause | Fix |
|---|---|---|
| VLAN exists in `show vlan` but hosts cannot communicate | Ports are not assigned to that VLAN, or the VLAN is not active on any trunk | Run `show vlan brief` and confirm the expected ports appear; check trunk allowed list with `show interfaces trunk` |
| `show vlan brief` shows a VLAN with no name and unexpected ports | Typo in a `switchport access vlan` command auto-created a phantom VLAN | Identify the port, remove the VLAN assignment, correct the VLAN ID, and reassign |
| VLAN missing after reload | `vlan.dat` not saved or not backed up | Always run `copy flash:vlan.dat` to a backup location; VLANs are not in `running-config` |
| Management SVI unreachable from remote subnet | `ip default-gateway` not configured on a Layer 2 switch | Add `ip default-gateway <gw-ip>` in global config |
| `show interfaces switchport` shows `dynamic auto` on an access port | Port mode was not hardcoded | Set `switchport mode access`; without this, DTP can negotiate a trunk |
| Port assigned to VLAN but `Operational Mode` shows `down` | VLAN is shutdown, or the port is administratively down | Run `no shutdown` on both the interface and the VLAN; check `show vlan` for `act/lshut` status |
| Trunk not passing a newly created VLAN | VLAN missing from the trunk's allowed list | Run `switchport trunk allowed vlan add <id>` on the trunk interface |
| `show vlan brief` shows VLAN as `act/unsup` | VLAN is a reserved ID (1002–1005) or unsupported on this platform | Use a different VLAN ID in the normal range (2–1001) |
Where to Go Next
- ▪Add the new VLANs to the trunk uplink's allowed list and verify with `show interfaces trunk`
- ▪Configure DHCP snooping on the access VLANs and set the uplink as a trusted port to block rogue DHCP servers
- ▪Enable `ip arp inspection` with a DHCP snooping binding table to stop ARP spoofing on the access layer
- ▪Set `storm-control broadcast level 5` on access ports to cap broadcast traffic at 5% and prevent a single misbehaving host from flooding the segment
- ▪Disable unused ports with `shutdown` and assign them to a dead-end VLAN — a dead-end VLAN has no SVI and no trunk membership, so a device plugged into it goes nowhere
- ▪Back up `vlan.dat` and `running-config` to version control so the VLAN database survives a hardware replacement
The VLANs are now defined, access ports are assigned, and a dedicated management SVI is reachable over SSH. The failure mode that catches most engineers next is not in VLAN creation — it is in trunk propagation. A VLAN exists on the access switch, ports are assigned, but the trunk uplink's allowed list does not include it, so traffic never leaves the switch. Always check `show interfaces trunk` after adding a VLAN, and remember that `switchport trunk allowed vlan 10,20` without the `add` keyword replaces the entire list rather than appending to it.