switchport parameters flip the port's mode, and a port can hold a static address and a DHCP client at once #1285

Closed
opened 2026-11-09 22:26:24 +00:00 by jaylouisw · 0 comments
Owner

A command that is about a VLAN parameter also changes the port's mode, and a port with a static address
accepts a DHCP client on top of it. Both are one command changing something the operator did not ask about.

1. switchport trunk native vlan on an access port makes it a trunk

sw1(config-if)#switchport trunk native vlan 20
Trunk native VLAN 20 on Fa0/1
sw1(config-if)#do show running-config
interface Fa0/1                        <- and nothing else: the value is not even in the backup

Measured on a plain access port, before: vlan.mode was access; after: trunk. Same for
switchport trunk allowed vlan 10,20 and, in the other direction, switchport access vlan 30 on a trunk
port (which turned the trunk into an access port).

  • the data plane follows the mode, so a port that was supposed to carry VLAN 1 starts emitting trunks for
    VLAN 20 — a configuration change nobody asked for, in a column nobody typed into;
  • staging a trunk before the cable is patched is the reason the command exists, and it is what real gear
    accepts: the parameter is stored and the mode is left alone;
  • because the printer only prints parameters "in the mode that uses them", what it stored was then lost in
    show running-config and never came back on restore.

2. A port holds a static address and a DHCP client at once

R1(config-if)#ip address 10.0.0.1 255.255.255.0
R1(config-if)#ip address dhcp
Interface Gi0/0 set to DHCP

state afterwards: { ip: "10.0.0.1", dhcp: true }. Three surfaces then disagree about one port:

  • it holds an address it does not own, and routeTo() will route for it;
  • show ip interface brief reports Method DHCP beside that address;
  • show running-config prints only ip address 10.0.0.1 255.255.255.0, so restoring the backup loses the
    DHCP intent.

The reverse direction already cleared the flag, but silently — the operator could not tell which method was
in force — and no ip address answered "IP address removed from Gi0/0" whether or not there was an address,
and whether or not the port was a DHCP client.

3. Found while testing #2: the backup bakes in a leased address

A DHCP host that has leased 10.0.0.100 printed

interface eth0
  ip address 10.0.0.100 255.255.255.0

Restored on a different network, that host claims a stale address and never asks for a new one. A backup has to
describe what was configured, not what the last exchange produced.

What "done" looks like

  • switchport trunk native vlan, switchport trunk allowed vlan and switchport access vlan store their
    value and never change the mode; only switchport mode changes the mode;
  • when the value cannot be used in the current mode, the console says so and names the command that would use
    it — Trunk native VLAN 20 on Fa0/1 (stored; the port is in access mode - set "switchport mode trunk" to use it) — and says nothing when the value is used immediately;
  • a staged trunk is printed in show running-config in either mode, and a backup replays byte-identically;
  • show vlan and the data plane still report only what the port carries, not what it is staged for;
  • one method per port, in both directions, with the displaced method named — Interface Gi0/0 set to DHCP (static address 10.0.0.1/24 removed) / IP address set on Gi0/0: 10.0.0.1/24 (DHCP client removed);
  • no ip address names what it removed, or refuses when there is nothing to remove;
  • show running-config prints ip address dhcp for a leased host, never the leased address;
  • a host moved from a static address to DHCP gets a real lease from a real pool and can ping.
A command that is about a VLAN parameter also changes the port's **mode**, and a port with a static address accepts a DHCP client on top of it. Both are one command changing something the operator did not ask about. ## 1. `switchport trunk native vlan` on an access port makes it a trunk ``` sw1(config-if)#switchport trunk native vlan 20 Trunk native VLAN 20 on Fa0/1 sw1(config-if)#do show running-config interface Fa0/1 <- and nothing else: the value is not even in the backup ``` Measured on a plain access port, before: `vlan.mode` was `access`; after: `trunk`. Same for `switchport trunk allowed vlan 10,20` and, in the other direction, `switchport access vlan 30` on a trunk port (which turned the trunk into an access port). * the **data plane follows the mode**, so a port that was supposed to carry VLAN 1 starts emitting trunks for VLAN 20 — a configuration change nobody asked for, in a column nobody typed into; * staging a trunk before the cable is patched is the reason the command exists, and it is what real gear accepts: the parameter is stored and the mode is left alone; * because the printer only prints parameters "in the mode that uses them", what it stored was then lost in `show running-config` and never came back on restore. ## 2. A port holds a static address and a DHCP client at once ``` R1(config-if)#ip address 10.0.0.1 255.255.255.0 R1(config-if)#ip address dhcp Interface Gi0/0 set to DHCP ``` state afterwards: `{ ip: "10.0.0.1", dhcp: true }`. Three surfaces then disagree about one port: * it holds an address it does not own, and `routeTo()` will route for it; * `show ip interface brief` reports Method `DHCP` beside that address; * `show running-config` prints only `ip address 10.0.0.1 255.255.255.0`, so restoring the backup loses the DHCP intent. The reverse direction already cleared the flag, but silently — the operator could not tell which method was in force — and `no ip address` answered "IP address removed from Gi0/0" whether or not there was an address, and whether or not the port was a DHCP client. ## 3. Found while testing #2: the backup bakes in a leased address A DHCP host that has leased `10.0.0.100` printed ``` interface eth0 ip address 10.0.0.100 255.255.255.0 ``` Restored on a different network, that host claims a stale address and never asks for a new one. A backup has to describe what was **configured**, not what the last exchange produced. ## What "done" looks like * `switchport trunk native vlan`, `switchport trunk allowed vlan` and `switchport access vlan` store their value and never change the mode; only `switchport mode` changes the mode; * when the value cannot be used in the current mode, the console says so and names the command that would use it — `Trunk native VLAN 20 on Fa0/1 (stored; the port is in access mode - set "switchport mode trunk" to use it)` — and says nothing when the value is used immediately; * a staged trunk is printed in `show running-config` in either mode, and a backup replays byte-identically; * `show vlan` and the data plane still report only what the port carries, not what it is staged for; * one method per port, in both directions, with the displaced method named — `Interface Gi0/0 set to DHCP (static address 10.0.0.1/24 removed)` / `IP address set on Gi0/0: 10.0.0.1/24 (DHCP client removed)`; * `no ip address` names what it removed, or refuses when there is nothing to remove; * `show running-config` prints `ip address dhcp` for a leased host, never the leased address; * a host moved from a static address to DHCP gets a real lease from a real pool and can ping.
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#1285
No description provided.