show running-config cannot be pasted back: no exit between blocks, own header rejected, and the config lands on the wrong port #1230

Closed
opened 2026-11-09 16:27:48 +00:00 by jaylouisw · 0 comments
Owner

What happens

show running-config is not a config you can paste back. On a router with more than one interface the
output starts failing at the second line and — worse — the rest of the config silently lands on the
wrong port
.

Steps to reproduce

enable
configure terminal
hostname EDGE-1
ip route 0.0.0.0 0.0.0.0 10.1.2.1
interface Gi0/0/0
ip address 10.1.2.3 255.255.255.0
exit
interface Gi0/0/1
shutdown
exit
end
show running-config

Output (excerpt):

hostname EDGE-1
interface Gi0
interface Gi0/0/0
  ip address 10.1.2.3 255.255.255.0
interface Gi0/0/1
  shutdown
interface Gi0/0/2
...
ip route 0.0.0.0 0.0.0.0 10.1.2.1

Now paste that, header line and all, into a fresh device of the same model:

enable
configure terminal
! PacketForge running-config
hostname EDGE-1
interface Gi0
...

Every one of those lines is rejected, and the config that is accepted goes to the wrong place:

% Unrecognized config command: ! PacketForge running-config
% Unrecognized interface command: interface Gi0/0/0
% Unrecognized interface command: interface Gi0/0/1
% Unrecognized interface command: ip route 0.0.0.0 0.0.0.0 10.1.2.1

…and the replayed show running-config shows why this is a correctness problem, not just noise:

interface Gi0
  ip address 10.1.2.3 255.255.255.0     <- the address meant for Gi0/0/0
  shutdown                              <- the shutdown meant for Gi0/0/1
interface Gi0/0/0
interface Gi0/0/1

The device ends up with an address and a shutdown on a different interface from the one they were
configured on.

Three separate causes

  1. The printer never emits exit. show running-config writes interface <name> blocks back to
    back, so a reader never leaves interface mode. Every line after the first interface is then parsed
    as an interface command — including global ones like ip route, which is why the route is
    rejected and the address is applied to whatever interface was current.
  2. The printer's own header is rejected. The first line it emits, ! PacketForge running-config,
    comes back as % Unrecognized config command — a comment is not a comment.
  3. interface <name> inside interface mode is rejected. IOS treats a new interface line while in
    interface mode as a mode switch, not an error; this CLI reports
    % Unrecognized interface command: interface Gi0/0/0.

Expected

  • show running-config produces output that, pasted into a fresh device of the same model at the
    config prompt, reproduces the same running-config — same addresses on the same ports.
  • Comment lines (!) are ignored wherever they appear, like every other CLI.
  • interface <name> in interface mode selects that interface.
  • Configs printed before this is fixed keep working: the parser must accept the bare
    block-after-block shape, not just the corrected one.

Scope

Every device with more than one port: the second interface line is the first failure. A single-port
device survives only because its one block is the last thing before the global section.

## What happens `show running-config` is not a config you can paste back. On a router with more than one interface the output starts failing at the second line and — worse — **the rest of the config silently lands on the wrong port**. ## Steps to reproduce ``` enable configure terminal hostname EDGE-1 ip route 0.0.0.0 0.0.0.0 10.1.2.1 interface Gi0/0/0 ip address 10.1.2.3 255.255.255.0 exit interface Gi0/0/1 shutdown exit end show running-config ``` Output (excerpt): ``` hostname EDGE-1 interface Gi0 interface Gi0/0/0 ip address 10.1.2.3 255.255.255.0 interface Gi0/0/1 shutdown interface Gi0/0/2 ... ip route 0.0.0.0 0.0.0.0 10.1.2.1 ``` Now paste that, header line and all, into a fresh device of the same model: ``` enable configure terminal ! PacketForge running-config hostname EDGE-1 interface Gi0 ... ``` Every one of those lines is rejected, and the config that *is* accepted goes to the wrong place: ``` % Unrecognized config command: ! PacketForge running-config % Unrecognized interface command: interface Gi0/0/0 % Unrecognized interface command: interface Gi0/0/1 % Unrecognized interface command: ip route 0.0.0.0 0.0.0.0 10.1.2.1 ``` …and the replayed `show running-config` shows why this is a correctness problem, not just noise: ``` interface Gi0 ip address 10.1.2.3 255.255.255.0 <- the address meant for Gi0/0/0 shutdown <- the shutdown meant for Gi0/0/1 interface Gi0/0/0 interface Gi0/0/1 ``` The device ends up with an address and a shutdown on a different interface from the one they were configured on. ## Three separate causes 1. **The printer never emits `exit`.** `show running-config` writes `interface <name>` blocks back to back, so a reader never leaves interface mode. Every line after the first interface is then parsed as an *interface* command — including global ones like `ip route`, which is why the route is rejected and the address is applied to whatever interface was current. 2. **The printer's own header is rejected.** The first line it emits, `! PacketForge running-config`, comes back as `% Unrecognized config command` — a comment is not a comment. 3. **`interface <name>` inside interface mode is rejected.** IOS treats a new `interface` line while in interface mode as a mode switch, not an error; this CLI reports `% Unrecognized interface command: interface Gi0/0/0`. ## Expected * `show running-config` produces output that, pasted into a fresh device of the same model at the config prompt, reproduces the same running-config — same addresses on the same ports. * Comment lines (`!`) are ignored wherever they appear, like every other CLI. * `interface <name>` in interface mode selects that interface. * Configs printed **before** this is fixed keep working: the parser must accept the bare block-after-block shape, not just the corrected one. ## Scope Every device with more than one port: the second `interface` line is the first failure. A single-port device survives only because its one block is the last thing before the global section.
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#1230
No description provided.