What an OSPF default route is
A default route is the route with destination 0.0.0.0 and mask 0.0.0.0. It matches every destination, but as the shortest possible match, so any other matching route wins over it (RFC 2328 Section 11.1).
Only certain LSAs may carry a default route in OSPF. RFC 2328 allows only the AS-external-LSA (type 5) and the summary-LSA (type 3) of a stub area (Appendix C). Carrying it inside an NSSA as a type 7 or type 3 was added by RFC 3101, which defines the NSSA.
How the default enters each area type
Which LSA brings the default in depends on the area type. On IOS XR it works as follows.
| Area type | Default injected by the ABR | Type 5 default from an ASBR |
|---|---|---|
| Normal area | None | Reaches it |
| Stub area / totally stub area | A type 3, automatically (metric from default-cost) | Does not reach it |
| NSSA | None by default. A type 7 (P bit clear) with nssa default-information-originate | Does not reach it |
| Totally NSSA | A type 3 | Does not reach it |
The stub area behaviour is verified on real hardware in OSPF stub area and totally stub area, and the NSSA behaviour in OSPF NSSA and totally NSSA. This article covers the type 5 default originated by an ASBR in a normal area.
The default originated by an ASBR
An ASBR advertises a default route out of the AS as a type 5 with link state ID 0.0.0.0 (RFC 2328 Section 12.4.4). Routers that receive it install an O*E2 (or O*E1) route. The originating ASBR itself does not, because a router does not use its own type 5 LSAs in its route calculation (Section 16.4 (2)).
On IOS XR it is originated with default-information originate under router ospf. The keyword always changes the behaviour.
| Configuration | When the type 5 is originated |
|---|---|
default-information originate | Only while the router’s routing table holds a 0.0.0.0/0 learned from a source other than OSPF. It is withdrawn when that route disappears |
default-information originate always | Regardless of whether a default route exists |
With always, the ASBR keeps advertising even when it has no exit itself. Receiving routers carry traffic to the ASBR, but it goes no further. This is Cisco’s implementation behaviour, not something the standard defines.
With route-policy, the default is originated only while the policy’s condition holds. In IOS XR’s routing policy language (RPL), rib-has-route can test whether a given route is in the routing table, and when that route disappears the default is withdrawn even with always.
The metric defaults to 1 and the type to E2; metric and metric-type change them. When several ASBRs originate a default, it is selected by the same rules as any external route (Section 16.4 (4)-(6)).
- E2 compares the external cost (
metric) first, and on a tie the cost to the ASBR - E1 compares the sum of the cost to the ASBR and the external cost
- If everything ties, the result is ECMP
Test topology
Six XRd routers (IOS XR 26.1.1) on CML. R1 - R3 - R4 - R2 form a line in area 0, and R1 and R2 at the ends are the ASBRs. R1 and R2 each hold a static default towards ISP1 and ISP2. ISP1 and ISP2 run no OSPF and both hold 192.0.2.1/32, so the traceroute hops show which exit was used.
R3 is one hop from R1 and two from R2; R4 is one hop from R2 and two from R1. Every link has cost 1.
| STEP | Change | What it confirms |
|---|---|---|
| 0 | Initial state (R1 and R2 hold a static default) | R3 and R4 have no default and cannot reach 192.0.2.1 |
| 1 | default-information originate on R1 | A type 5 default appears. R1 itself installs no O*E2 |
| 2 | R1’s static default removed | R1 withdraws the type 5 |
| 3 | R1 changed to default-information originate always | The type 5 appears without a static route, but traffic goes no further than R1 |
| 4 | R1’s static restored and always removed | Back to the STEP 1 state |
| 5 | default-information originate on R2 as well | Two defaults. R3 goes via R1, R4 via R2 |
| 6 | R1 set to metric 5 | R2, with the lower external cost, wins, and R3 also goes via R2 |
| 7 | R1 set to metric 2 metric-type 1, R2 to metric 1 metric-type 1 | E1 compares the sum. R3 uses ECMP, R4 goes via R2 |
| 8 | A route-policy on R1 originates only while the ISP1 link exists | The condition holds, so R1 keeps its type 5 |
| 9 | R1’s ISP1-facing interface shut down (final state) | The condition route disappears and R1 withdraws its type 5 despite always |
The sections that follow are organised by topic, not in STEP order.
Conditional origination and withdrawal
With default-information originate on R1 in STEP 1, R1 originates a type 5 default. The link state ID and netmask are 0.0.0.0, the metric is 1 and the type is E2.
Open Shortest Path First
OSPF Header
Version: 2
Message Type: LS Update (4)
Packet Length: 64
Source OSPF Router: 1.1.1.1
Area ID: 0.0.0.0 (Backbone)
Checksum: 0xbbf7 [correct]
Instance ID: Base IPv4 Unicast Instance (0)
Auth Type: Null (0)
Auth Data (none): 0000000000000000
LS Update Packet
Number of LSAs: 1
LSA-type 5 (AS-External-LSA (ASBR)), len 36
.000 0000 0000 0001 = LS Age (seconds): 1
0... .... .... .... = Do Not Age Flag: 0
Options: 0x20, (DC) Demand Circuits
0... .... = DN: Not set
.0.. .... = (O) Opaque: Not set
..1. .... = (DC) Demand Circuits: Supported
...0 .... = (L) LLS Data block: Not Present
.... 0... = (N) NSSA: Not supported
.... .0.. = (MC) Multicast: Not capable
.... ..0. = (E) External Routing: Not capable
.... ...0 = (MT) Multi-Topology Routing: No
LS Type: AS-External-LSA (ASBR) (5)
Link State ID: 0.0.0.0
Advertising Router: 1.1.1.1
Sequence Number: 0x80000001
Checksum: 0x1d91
Length: 36
Netmask: 0.0.0.0
1... .... = External Type: Type 2 (metric is larger than any other link state path)
.000 0000 = TOS: 0
Metric: 1
Forwarding Address: 0.0.0.0
External Route Tag: 1R3 installs an ospf 1 default from this type 5. On R1, which originates it, the default is still the static route.
RP/0/RP0/CPU0:R1#show route 0.0.0.0/0
Tue Sep 15 05:52:58.724 UTC
Routing entry for 0.0.0.0/0
Known via "static", distance 1, metric 0, candidate default path
Installed Sep 15 05:40:59.322 for 00:11:59
Routing Descriptor Blocks
198.51.100.254
Route metric is 0
No advertising protos. RP/0/RP0/CPU0:R3#show route 0.0.0.0/0
Tue Sep 15 05:54:03.135 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 1, candidate default path
Tag 1, type extern 2
Installed Sep 15 05:52:03.776 for 00:01:59
Routing Descriptor Blocks
10.0.13.1, from 1.1.1.1, via GigabitEthernet0/0/0/0
Route metric is 1
No advertising protos. Removing R1’s static default in STEP 2 makes R1 withdraw the type 5. The LSU carries LS age 3600 (MaxAge) and metric 16777215 (LSInfinity).
Open Shortest Path First
OSPF Header
Version: 2
Message Type: LS Update (4)
Packet Length: 64
Source OSPF Router: 1.1.1.1
Area ID: 0.0.0.0 (Backbone)
Checksum: 0xb8dd [correct]
Instance ID: Base IPv4 Unicast Instance (0)
Auth Type: Null (0)
Auth Data (none): 0000000000000000
LS Update Packet
Number of LSAs: 1
LSA-type 5 (AS-External-LSA (ASBR)), len 36
.000 1110 0001 0000 = LS Age (seconds): 3600
0... .... .... .... = Do Not Age Flag: 0
Options: 0x20, (DC) Demand Circuits
0... .... = DN: Not set
.0.. .... = (O) Opaque: Not set
..1. .... = (DC) Demand Circuits: Supported
...0 .... = (L) LLS Data block: Not Present
.... 0... = (N) NSSA: Not supported
.... .0.. = (MC) Multicast: Not capable
.... ..0. = (E) External Routing: Not capable
.... ...0 = (MT) Multi-Topology Routing: No
LS Type: AS-External-LSA (ASBR) (5)
Link State ID: 0.0.0.0
Advertising Router: 1.1.1.1
Sequence Number: 0x80000002
Checksum: 0x119d
Length: 36
Netmask: 0.0.0.0
1... .... = External Type: Type 2 (metric is larger than any other link state path)
.000 0000 = TOS: 0
Metric: 16777215
Forwarding Address: 0.0.0.0
External Route Tag: 1Adding always in STEP 3 brings the type 5 back while R1 still has no default. R1’s routing table holds no default route.
RP/0/RP0/CPU0:R1#show route 0.0.0.0/0
Tue Sep 15 06:03:54.334 UTC
% Network not in tableR3 follows this type 5 and sends traffic to R1, but R1 has no route onwards, so it never arrives. The traceroute ends at R1 (10.0.13.1) with !N (unreachable).
RP/0/RP0/CPU0:R3#ping 192.0.2.1 source 3.3.3.3 count 50 timeout 1
Tue Sep 15 06:05:18.996 UTC
Type escape sequence to abort.
Sending 50, 100-byte ICMP Echos to 192.0.2.1 timeout is 1 seconds:
..................................................
Success rate is 0 percent (0/50)
RP/0/RP0/CPU0:R3#traceroute 192.0.2.1 source 3.3.3.3
Tue Sep 15 06:06:10.349 UTC
Type escape sequence to abort.
Tracing the route to 192.0.2.1
1 10.0.13.1 !N * !N Restoring the static route and removing always in STEP 4 returns to the STEP 1 state. The contents of the type 5 do not change, so no LSU is sent and the sequence number stays 80000001.
Several ASBRs originating a default
With default-information originate on R2 as well in STEP 5, area 0 holds two type 5 defaults. Both are E2 with metric 1, so the cost to the ASBR decides. On R3, Routing Bit Set on this LSA appears only on the LSA from R1, one hop away.
RP/0/RP0/CPU0:R3#show ospf database external
Tue Sep 15 06:15:49.317 UTC
OSPF Router with ID (3.3.3.3) (Process ID 1)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 772
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 0.0.0.0 (External Network Number)
Advertising Router: 1.1.1.1
LS Seq Number: 80000001
Checksum: 0x1d91
Length: 36
Network Mask: /0
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 1
Forward Address: 0.0.0.0
External Route Tag: 1
LS age: 122
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 0.0.0.0 (External Network Number)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0xfeab
Length: 36
Network Mask: /0
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 1
Forward Address: 0.0.0.0
External Route Tag: 1R3 uses the default via R1, and R4 the one via R2.
RP/0/RP0/CPU0:R3#show route 0.0.0.0/0
Tue Sep 15 06:15:51.159 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 1, candidate default path
Tag 1, type extern 2
Installed Sep 15 06:02:59.070 for 00:12:52
Routing Descriptor Blocks
10.0.13.1, from 1.1.1.1, via GigabitEthernet0/0/0/0
Route metric is 1
No advertising protos. RP/0/RP0/CPU0:R4#show route 0.0.0.0/0
Tue Sep 15 06:16:33.289 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 1, candidate default path
Tag 1, type extern 2
Installed Sep 15 06:13:49.408 for 00:02:43
Routing Descriptor Blocks
10.0.24.2, from 2.2.2.2, via GigabitEthernet0/0/0/0
Route metric is 1
No advertising protos. Setting R1 to metric 5 in STEP 6 makes R3 choose R2’s default too, because E2 compares the external cost first. R3, one hop from R1, now goes through R4 and R2.
RP/0/RP0/CPU0:R3#show route 0.0.0.0/0
Tue Sep 15 06:20:26.082 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 1, candidate default path
Tag 1, type extern 2
Installed Sep 15 06:18:25.836 for 00:02:00
Routing Descriptor Blocks
10.0.34.4, from 2.2.2.2, via GigabitEthernet0/0/0/1
Route metric is 1
No advertising protos. STEP 7 makes both E1, with metric 2 on R1 and metric 1 on R2. E1 compares the sum with the cost to the ASBR. For R3 the path via R1 costs 2+1=3 and the path via R2 costs 1+2=3, so the result is two-path ECMP. For R4 the path via R2 costs 1+1=2, a single path.
RP/0/RP0/CPU0:R3#show route 0.0.0.0/0
Tue Sep 15 06:25:11.220 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 3, candidate default path
Tag 1, type extern 1
Installed Sep 15 06:23:09.423 for 00:02:01
Routing Descriptor Blocks
10.0.13.1, from 1.1.1.1, via GigabitEthernet0/0/0/0
Route metric is 3
10.0.34.4, from 2.2.2.2, via GigabitEthernet0/0/0/1
Route metric is 3
No advertising protos. RP/0/RP0/CPU0:R4#show route 0.0.0.0/0
Tue Sep 15 06:25:55.665 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 2, candidate default path
Tag 1, type extern 1
Installed Sep 15 06:23:09.417 for 00:02:46
Routing Descriptor Blocks
10.0.24.2, from 2.2.2.2, via GigabitEthernet0/0/0/0
Route metric is 2
No advertising protos. Adding a condition with a route-policy
In STEP 8, R1 gets a policy that originates the default only while the ISP1 link (198.51.100.0/24) is in the routing table.
route-policy DEF-IF-ISP1
if rib-has-route in (198.51.100.0/24) then
pass
endif
end-policyrouter ospf 1
router-id 1.1.1.1
default-information originate always metric 2 metric-type 1 route-policy DEF-IF-ISP1The condition route exists, so R1 keeps originating the same type 5 as in STEP 7.
Shutting down R1’s ISP1-facing interface in STEP 9 removes 198.51.100.0/24 from the routing table. R1 withdraws its type 5 despite always, and the withdrawing LSU went out 193 ms later.
RP/0/RP0/CPU0:Sep 15 06:32:48.044 UTC: ifmgr[155]: %PKT_INFRA-LINK-5-CHANGED : Interface GigabitEthernet0/0/0/0, changed state to Administratively Down Open Shortest Path First
OSPF Header
Version: 2
Message Type: LS Update (4)
Packet Length: 64
Source OSPF Router: 1.1.1.1
Area ID: 0.0.0.0 (Backbone)
Checksum: 0xc0d5 [correct]
Instance ID: Base IPv4 Unicast Instance (0)
Auth Type: Null (0)
Auth Data (none): 0000000000000000
LS Update Packet
Number of LSAs: 1
LSA-type 5 (AS-External-LSA (ASBR)), len 36
.000 1110 0001 0000 = LS Age (seconds): 3600
0... .... .... .... = Do Not Age Flag: 0
Options: 0x20, (DC) Demand Circuits
0... .... = DN: Not set
.0.. .... = (O) Opaque: Not set
..1. .... = (DC) Demand Circuits: Supported
...0 .... = (L) LLS Data block: Not Present
.... 0... = (N) NSSA: Not supported
.... .0.. = (MC) Multicast: Not capable
.... ..0. = (E) External Routing: Not capable
.... ...0 = (MT) Multi-Topology Routing: No
LS Type: AS-External-LSA (ASBR) (5)
Link State ID: 0.0.0.0
Advertising Router: 1.1.1.1
Sequence Number: 0x80000004
Checksum: 0x89a3
Length: 36
Netmask: 0.0.0.0
0... .... = External Type: Type 1 (metric is specified in the same units as interface cost)
.000 0000 = TOS: 0
Metric: 16777215
Forwarding Address: 0.0.0.0
External Route Tag: 1R3’s default is now a single path via R2.
RP/0/RP0/CPU0:R3#show route 0.0.0.0/0
Tue Sep 15 06:34:54.531 UTC
Routing entry for 0.0.0.0/0
Known via "ospf 1", distance 110, metric 3, candidate default path
Tag 1, type extern 1
Installed Sep 15 06:32:48.240 for 00:02:06
Routing Descriptor Blocks
10.0.34.4, from 2.2.2.2, via GigabitEthernet0/0/0/1
Route metric is 3
No advertising protos. References
| Document | Section | Content |
|---|---|---|
| RFC 2328 | Section 11.1 | Routing table lookup. The default route is the least specific match |
| RFC 2328 | Section 12.4.3.1 | The default summary-LSA originated into a stub area |
| RFC 2328 | Section 12.4.4 | A default route in an AS-external-LSA |
| RFC 2328 | Section 16.4 | Calculating AS external routes. Ignoring self-originated LSAs, comparing E1 and E2 |
| RFC 2328 | Appendix C | DefaultDestination |
| RFC 3101 | Section 2.4 | The type 7 default in an NSSA |
| RFC 3101 | Section 2.7 | When an NSSA uses a type 3 default |
Test configs and show output
At every STEP the following files were collected from all six routers, one file per router. The test config is the ..._run.txt (the final state is STEP 9’s).
| File | Content |
|---|---|
..._show.txt | show version / show interface description / show route / show route ospf / show ospf / show ospf interface / show ospf interface brief / show ospf neighbor / show ospf neighbor detail / show ospf database / show ospf database router / show ospf database network / show ospf statistics interface / show ospf database external / show ospf database external self-originate / show route 0.0.0.0/0 / show route static / show ospf database database-summary |
..._log.txt | show logging limited to that STEP |
..._run.txt | show running-config at that STEP (the test config of that STEP) |
..._trace.txt | show ospf trace spf_ext / show ospf trace adj_cycle / show ospf trace events / show ospf trace adj |
..._ping.txt | ping and traceroute from R3 and R4 to 192.0.2.1 |
..._commit.cfg | show configuration commit changes last 1 on the router changed in that STEP |
STEP 0: Initial state (R1 and R2 hold a static default)
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | - |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 1: default-information originate on R1
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 2: R1’s static default removed
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 3: R1 changed to default-information originate always
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 4: R1’s static restored and always removed
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 5: default-information originate on R2 as well
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | - |
| R2 | show | log | run | trace | - | commit |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 6: R1 set to metric 5
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 7: R1 set to metric 2 metric-type 1, R2 to metric 1 metric-type 1
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | commit |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 8: A route-policy on R1 originates only while the ISP1 link exists
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
STEP 9: R1’s ISP1-facing interface shut down (final state)
| Router | show output | syslog | running-config | trace | ping | Config applied |
|---|---|---|---|---|---|---|
| R1 | show | log | run | trace | - | commit |
| R2 | show | log | run | trace | - | - |
| R3 | show | log | run | trace | ping | - |
| R4 | show | log | run | trace | ping | - |
| ISP1 | show | log | run | trace | - | - |
| ISP2 | show | log | run | trace | - | - |
Before STEP 0, the help for default-information originate was taken in R1’s candidate config and discarded with abort (nothing was committed): precheck
Packet captures were taken per STEP at two points: R1 - R3 and R4 - R2. The LSUs quoted above are No.3 in STEP 1, No.3 in STEP 2 and No.2 in STEP 9 (all on R1 - R3).
| STEP | R1 - R3 | R4 - R2 |
|---|---|---|
| 0 | pcap | pcap |
| 1 | pcap | pcap |
| 2 | pcap | pcap |
| 3 | pcap | pcap |
| 4 | pcap | pcap |
| 5 | pcap | pcap |
| 6 | pcap | pcap |
| 7 | pcap | pcap |
| 8 | pcap | pcap |
| 9 | pcap | pcap |
Related articles
- What Is OSPF
- OSPF Router ID
- OSPF Packet Types and Header Format
- OSPF Authentication
- OSPF Neighbor States
- OSPF Options Field
- OSPF DR and BDR
- OSPF Network Types
- OSPF Cost (Metric)
- OSPF External Routes (Redistributing Static Routes)
- OSPF Multiple Areas and the ABR
- OSPF Virtual Links
- OSPF Stub and Totally Stubby Areas
- OSPF NSSA and Totally NSSA
- OSPF Default Route
- OSPF Route Summarization
- OSPF LSAs and the LSA Header
- OSPF router-LSA (type 1)
- OSPF network-LSA (type 2)
- OSPF summary-LSA (type 3)
- OSPF ASBR summary-LSA (type 4)
- OSPF AS external-LSA (type 5)
- OSPF NSSA External-LSA (Type 7)