show ip route: legend omits OSPF/BGP, the default gateway is labelled static, and the administrative distance is invisible #1234

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

What happens

show ip route labels every row from a two-code legend, but the table it prints can carry four codes,
and the one row that most often explains a lab's behaviour — the default gateway — is mislabelled.

Codes: C - connected, S - static
C  10.1.2.0       /24  via -  eth0
S  0.0.0.0        /0  via 10.1.2.254  -

Three problems, all in what the command says rather than in what the engine does:

  1. The legend is short. routesTable() emits O (OSPF) and B (BGP) rows as well as C and S,
    so an OSPF-learned route prints as a code the legend never defines.
  2. The default gateway is labelled S (static). It is not a static route: routeTo() treats it as a
    separate source with administrative distance 254, while a static route has distance 1. On a device
    with both — ip default-gateway 10.1.2.254 and ip route 0.0.0.0 0.0.0.0 10.1.2.1 — the table
    prints two identical-looking S 0.0.0.0/0 rows and gives no clue which one wins. (The static one
    does; the operator cannot see that.)
  3. The administrative distance is not shown at all, although it is half of the rule that picks the
    installed route (routeTo() compares longest prefix first, then lowest AD). Two rows for the same
    prefix therefore have no visible tie-break.

Connected rows also print via -, which reads as "no next hop" rather than "directly connected".

Steps to reproduce

host# show ip route

on a host with ip default-gateway 10.1.2.254, and on a router with both a default gateway and a
static default route. The second case shows two S 0.0.0.0/0 rows with nothing to distinguish them.

Expected

The output convention every operator already knows:

Codes: C - connected, S - static, O - OSPF, B - BGP
Gateway of last resort is 10.1.2.254 to network 0.0.0.0
S*    0.0.0.0/0 [254/0] via 10.1.2.254
C     10.1.2.0/24 is directly connected, eth0
S     0.0.0.0/0 [1/0] via 10.1.2.1
O     10.9.0.0/24 [110/0] via 10.1.2.2, eth1
  • the legend names every code the table can emit;
  • the default gateway is marked as the candidate default (S*) and reported in a Gateway of last resort line, so it cannot be confused with a configured static route;
  • each row carries [distance/metric], which is the information the engine actually uses;
  • connected rows read is directly connected, <iface>.

Scope

Formatting and labelling of show ip route only. routesTable() already returns everything needed
(code, type, ad); no routing behaviour changes.

## What happens `show ip route` labels every row from a two-code legend, but the table it prints can carry four codes, and the one row that most often explains a lab's behaviour — the default gateway — is mislabelled. ``` Codes: C - connected, S - static C 10.1.2.0 /24 via - eth0 S 0.0.0.0 /0 via 10.1.2.254 - ``` Three problems, all in what the command *says* rather than in what the engine does: 1. **The legend is short.** `routesTable()` emits `O` (OSPF) and `B` (BGP) rows as well as `C` and `S`, so an OSPF-learned route prints as a code the legend never defines. 2. **The default gateway is labelled `S` (static).** It is not a static route: `routeTo()` treats it as a separate source with administrative distance 254, while a static route has distance 1. On a device with both — `ip default-gateway 10.1.2.254` and `ip route 0.0.0.0 0.0.0.0 10.1.2.1` — the table prints two identical-looking `S 0.0.0.0/0` rows and gives no clue which one wins. (The static one does; the operator cannot see that.) 3. **The administrative distance is not shown at all**, although it is half of the rule that picks the installed route (`routeTo()` compares longest prefix first, then lowest AD). Two rows for the same prefix therefore have no visible tie-break. Connected rows also print `via -`, which reads as "no next hop" rather than "directly connected". ## Steps to reproduce ``` host# show ip route ``` on a host with `ip default-gateway 10.1.2.254`, and on a router with both a default gateway and a static default route. The second case shows two `S 0.0.0.0/0` rows with nothing to distinguish them. ## Expected The output convention every operator already knows: ``` Codes: C - connected, S - static, O - OSPF, B - BGP Gateway of last resort is 10.1.2.254 to network 0.0.0.0 S* 0.0.0.0/0 [254/0] via 10.1.2.254 C 10.1.2.0/24 is directly connected, eth0 S 0.0.0.0/0 [1/0] via 10.1.2.1 O 10.9.0.0/24 [110/0] via 10.1.2.2, eth1 ``` * the legend names every code the table can emit; * the default gateway is marked as the candidate default (`S*`) and reported in a `Gateway of last resort` line, so it cannot be confused with a configured static route; * each row carries `[distance/metric]`, which is the information the engine actually uses; * connected rows read `is directly connected, <iface>`. ## Scope Formatting and labelling of `show ip route` only. `routesTable()` already returns everything needed (`code`, `type`, `ad`); no routing behaviour changes.
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#1234
No description provided.