switchport access vlan 22 moves the port and never creates VLAN 22, so the port and the running-config disagree #1535

Closed
opened 2026-11-15 20:11:24 +00:00 by jaylouisw · 0 comments
Owner

What a real switch does

Assigning an access port to a VLAN that does not exist creates that VLAN. The console says so in two lines, and applies the assignment anyway:

Switch(config)# interface gigabitethernet1/0/7
Switch(config-if)# switchport access vlan 22
% Access VLAN does not exist.
Creating vlan 22

show vlan lists VLAN 22 afterwards, under the generated name, and show running-config carries the vlan 22 line.

Evidence:

What this console does

switchport access vlan 22 moves the port and says Access VLAN 22 on Fa0/1. Nothing else. show vlan grows a row anyway, because that table is built from the port list as well as from config.vlans — so the port and the table agree — while show running-config prints no vlan 22 line. That is the gap #1232 closed for VLANs somebody typed vlan 22 for, left open on the one command that can create a VLAN without anybody typing vlan.

Consequence: a config saved from the device is not self-contained, and pasting it into a fresh switch loses the VLAN.

Expected

  • the two vendor lines, in that order, before the console's own confirmation, only when the VLAN is not already in the table;
  • the VLAN entry created under the same generated name vlan <id> would have given it;
  • VLAN 1 never created (it exists on every switch);
  • nothing announced when the VLAN is already there.
## What a real switch does Assigning an access port to a VLAN that does not exist **creates that VLAN**. The console says so in two lines, and applies the assignment anyway: ``` Switch(config)# interface gigabitethernet1/0/7 Switch(config-if)# switchport access vlan 22 % Access VLAN does not exist. Creating vlan 22 ``` `show vlan` lists VLAN 22 afterwards, under the generated name, and `show running-config` carries the `vlan 22` line. Evidence: - Catalyst 3750 Switch Software Configuration Guide, 12.2(52)SE — [Configuring IEEE 802.1Q and Layer 2 Protocol Tunneling](http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst3750/software/release/12-2_52_se/configuration/guide/3750scg/swtunnel.html) - Layer 2 Configuration Guide, Cisco IOS XE Fuji 16.9.x (Catalyst 9300) — [Configuring IEEE 802.1Q Tunneling](https://cisco.com/c/en/us/td/docs/switches/lan/catalyst9300/software/release/16-9/configuration_guide/lyr2/b_169_lyr2_9300_cg/configuring_ieee_802_1q_tunneling.html); the same wording is still there in [17.17.x](https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9300/software/release/17-17/configuration_guide/lyr2/b_1717_lyr2_9300_cg/configuring_ieee_802_1q_tunneling.html) and 26.x - Cisco Networking Academy, *Assigning Ports to VLANs* — "the `switchport access vlan` command forces the creation of a VLAN if it does not already exist on the switch" — https://www.ii.pwr.edu.pl/~kano/course/module3/3.2.1.3/3.2.1.3.html ## What this console does `switchport access vlan 22` moves the port and says `Access VLAN 22 on Fa0/1`. Nothing else. `show vlan` grows a row anyway, because that table is built from the port list as well as from `config.vlans` — so the port and the table agree — while `show running-config` prints no `vlan 22` line. That is the gap #1232 closed for VLANs somebody typed `vlan 22` for, left open on the one command that can create a VLAN without anybody typing `vlan`. Consequence: a config saved from the device is not self-contained, and pasting it into a fresh switch loses the VLAN. ## Expected - the two vendor lines, in that order, before the console's own confirmation, only when the VLAN is not already in the table; - the VLAN entry created under the same generated name `vlan <id>` would have given it; - VLAN 1 never created (it exists on every switch); - nothing announced when the VLAN is already there.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge#1535
No description provided.