switchport access vlan 22 creates VLAN 22, and says so the way the device does (#1535) #1536

Merged
jaylouisw merged 1 commit from rev/1115-1930 into main 2026-11-15 20:17:45 +00:00
Owner

Closes #1535.

The question

What does a real IOS-like switch do when an access port is assigned to a VLAN that does not exist?

Evidence

It creates the VLAN, and says so in two lines, then applies the assignment:

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

Six vendor guides across fourteen years, one for one: the notice is two lines, % on the first only.

The gap

switchport access vlan 22 moved the port and said nothing about the VLAN. show vlan grew a row anyway (that table is built from the port list as well as from config.vlans), so the port and the table agreed while show running-config printed no vlan 22 line. A config saved from the device was not self-contained — paste it into a fresh switch and the VLAN was gone. That is the hole #1232 closed for VLANs somebody typed vlan 22 for, still open on the one command that creates a VLAN without anybody typing vlan.

Change

  • engine/cli.js: assigning an access VLAN writes the table entry the port needs, under the same generated name vlan <id> would have given it, and announces the two vendor lines before the console's own confirmation. Said once: not for VLAN 1 (every switch has it), not when the VLAN already exists, and not when somebody created it with vlan 20 (their name survives).
  • test/vlan-auto-create.test.js (new, 16 assertions): the two lines in order, the assignment still applied, the three views agreeing (show running-config, show vlan, show vlan after a copy-paste replay), once-only behaviour, VLAN 1, a pre-existing VLAN keeping its name, and a port staged for a trunk.
  • test/switchport-mode.test.js, test/switchport-negation.test.js: their replay checks treated any % line as a rejection. This notice is information — nothing was refused and the replayed config is still byte-identical — so they now allow exactly % Access VLAN does not exist. and fail on any other %.

Gates

  • node scripts/syntax-check.js: 322 files, all OK
  • Full suite: 252 suites, 9217 assertions passed, 0 failed
  • skip-audit, canonical-urls, config-roundtrip, config-completeness, replay-identical, vlan, cli, switchport-mode, switchport-negation, vlan-auto-create: all green

Not resolved here

  • Real IOS answers Creating vlan 22 on a switch whose VTP mode is server or transparent; a client in a VTP domain learns the VLAN from an advertisement instead and words it differently. The simulator has no VTP, so this stays out.
  • switchport voice vlan 44 creates a voice VLAN without the same notice here; whether a real device announces it identically is a separate question.
  • The console's own confirmation (Access VLAN 44 on Fa0/1) is printed after the vendor lines; a real device prints nothing at all after them. Removing it is a wider change to every command's output and was left alone.
Closes #1535. ## The question What does a real IOS-like switch do when an access port is assigned to a VLAN that does not exist? ## Evidence It creates the VLAN, and says so in two lines, then applies the assignment: ``` Switch(config)# interface gigabitethernet1/0/7 Switch(config-if)# switchport access vlan 22 % Access VLAN does not exist. Creating vlan 22 ``` - 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); identical wording 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 Six vendor guides across fourteen years, one for one: the notice is two lines, `%` on the first only. ## The gap `switchport access vlan 22` moved the port and said nothing about the VLAN. `show vlan` grew a row anyway (that table is built from the port list as well as from `config.vlans`), so the port and the table agreed while `show running-config` printed no `vlan 22` line. A config saved from the device was not self-contained — paste it into a fresh switch and the VLAN was gone. That is the hole #1232 closed for VLANs somebody typed `vlan 22` for, still open on the one command that creates a VLAN without anybody typing `vlan`. ## Change - `engine/cli.js`: assigning an access VLAN writes the table entry the port needs, under the same generated name `vlan <id>` would have given it, and announces the two vendor lines before the console's own confirmation. Said once: not for VLAN 1 (every switch has it), not when the VLAN already exists, and not when somebody created it with `vlan 20` (their name survives). - `test/vlan-auto-create.test.js` (new, 16 assertions): the two lines in order, the assignment still applied, the three views agreeing (`show running-config`, `show vlan`, `show vlan` after a copy-paste replay), once-only behaviour, VLAN 1, a pre-existing VLAN keeping its name, and a port staged for a trunk. - `test/switchport-mode.test.js`, `test/switchport-negation.test.js`: their replay checks treated any `%` line as a rejection. This notice is information — nothing was refused and the replayed config is still byte-identical — so they now allow exactly `% Access VLAN does not exist.` and fail on any other `%`. ## Gates - `node scripts/syntax-check.js`: 322 files, all OK - Full suite: **252 suites, 9217 assertions passed, 0 failed** - `skip-audit`, `canonical-urls`, `config-roundtrip`, `config-completeness`, `replay-identical`, `vlan`, `cli`, `switchport-mode`, `switchport-negation`, `vlan-auto-create`: all green ## Not resolved here - Real IOS answers `Creating vlan 22` on a switch whose VTP mode is server or transparent; a *client* in a VTP domain learns the VLAN from an advertisement instead and words it differently. The simulator has no VTP, so this stays out. - `switchport voice vlan 44` creates a voice VLAN without the same notice here; whether a real device announces it identically is a separate question. - The console's own confirmation (`Access VLAN 44 on Fa0/1`) is printed after the vendor lines; a real device prints nothing at all after them. Removing it is a wider change to every command's output and was left alone.
switchport access vlan 22 creates VLAN 22, and says so the way the device does (#1535)
All checks were successful
CI / Classify the change (pull_request) Successful in 20s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 21s
CI / Test (Node 18) (pull_request) Successful in 3m38s
CI / Test (Node 20) (pull_request) Successful in 3m19s
CI / Server smoke test (pull_request) Successful in 29s
CI / Docker build (pull_request) Successful in 45s
CI / Test (Node 22) (pull_request) Successful in 3m6s
081e244d48
A Cisco switch assigns an access port to a VLAN that does not exist by making the VLAN:
`% Access VLAN does not exist.` / `Creating vlan 22`, then the assignment applies and
`show vlan` lists it. The transcript is in the Catalyst 3750 12.2(52)SE configuration
guide and is unchanged in the Catalyst 9300 Layer 2 guide from IOS XE 16.9.x to 26.x.

This console moved the port and said nothing about the VLAN. `show vlan` still grew a
row, because that table is built from the port list as well as from `config.vlans` - so
the port and the table agreed while `show running-config` printed no `vlan 22`. A config
saved from the device was therefore not self-contained: paste it into a fresh switch and
the VLAN was gone. 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`.

The port command now writes the table entry under the name `vlan <id>` would have given
it, announces the two vendor lines once (never for VLAN 1, never when the VLAN is already
there), and the confirmation follows. Two replay suites stopped treating the notice as a
rejection: it is information - nothing was refused, and the replayed config is still
byte-identical - so they now allow exactly that line and fail on any other `%`.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-15 20:17:11 +00:00
jaylouisw force-pushed rev/1115-1930 from 081e244d48
All checks were successful
CI / Classify the change (pull_request) Successful in 20s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 21s
CI / Test (Node 18) (pull_request) Successful in 3m38s
CI / Test (Node 20) (pull_request) Successful in 3m19s
CI / Server smoke test (pull_request) Successful in 29s
CI / Docker build (pull_request) Successful in 45s
CI / Test (Node 22) (pull_request) Successful in 3m6s
to f6c608ea8a
All checks were successful
CI / Classify the change (pull_request) Successful in 17s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 2m28s
CI / Test (Node 18) (pull_request) Successful in 3m25s
CI / Test (Node 20) (pull_request) Successful in 3m6s
CI / Server smoke test (pull_request) Successful in 29s
CI / Test (Node 22) (pull_request) Successful in 3m9s
CI / Docker build (pull_request) Successful in 1m16s
2026-11-15 20:17:14 +00:00
Compare
Sign in to join this conversation.
No reviewers
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!1536
No description provided.