A real-life situation
OSPF is running in the lab and every LAN can reach every other LAN. Then a user on LAN 3 opens a website and gets nothing. R1 has a static default route to the ISP, so R1 itself can reach the internet. But R2 and R3 only know the routes OSPF told them about, and OSPF has never heard of the internet. Their routing tables have no match for a web server's address, so they drop the packets. The fix is one command on R1.
What a default route in OSPF is
A default route (0.0.0.0/0) matches every destination, so a router uses it when nothing more specific matches. In most networks only the edge router, here R1, connects to the internet. Typing a static default route on every other router works, but each one would point at a fixed next hop and wouldn't react if the path changed.
Instead, R1 advertises its default route into OSPF. Every other router learns it, with the correct next hop worked out by SPF, and loses it automatically if R1 stops advertising it.
- 1. R1 has a static default route ip route 0.0.0.0 0.0.0.0 203.0.113.1 points at the ISP. Gi0/2 is not in OSPF.
- 2. R1 advertises 0.0.0.0/0 into OSPF With default-information originate, R1 floods an external (type 5) LSA for the default. R1 is now an ASBR.
- 3. Internet traffic follows it R3 has no specific route for the web server, so it uses O*E2 0.0.0.0/0 towards R2, which forwards to R1, which sends it to the ISP.
Why it works this way
OSPF treats anything that didn't start inside OSPF as external. A static route is external, so R1 advertises it in a type 5 LSA (AS external LSA), which is flooded to every router in the OSPF domain. A router that injects external routes is called an ASBR (autonomous system boundary router).
The condition ("only while R1 has a default route itself") is a safety feature. If the ISP link goes down, R1's static route leaves its routing table, R1 withdraws the LSA, and the other routers stop sending internet traffic into a dead end. If there were a second exit elsewhere, they would switch to it.
E2 and E1: two ways to count the cost
| Metric type | Metric on R3 | When to use it |
|---|---|---|
| E2 (default) | The value R1 set, 1 by default, on every router | One exit, or when you only care which exit, not the path to it |
| E1 | R1's value + the OSPF cost from R3 to R1 | Several exits, when each router should use the nearest one |
With two exits advertising E2 routes of the same metric, a router still prefers the one it can reach with the lower internal cost. E1 simply builds that distance into the metric you see.
How to configure it on Cisco IOS
ip route 0.0.0.0 0.0.0.0 203.0.113.1
!
router ospf 1
default-information originateOn R1. The static route gives R1 its own way out; default-information originate shares it through OSPF. Nothing is configured on R2 or R3.
router ospf 1
default-information originate alwaysAdvertises the default route even when R1 has none of its own. Use it only when another mechanism guarantees the exit, for example a router whose default comes from somewhere OSPF doesn't see.
router ospf 1
default-information originate metric 10 metric-type 1Sets the starting metric (10) and makes the route E1, so each router adds its own cost to reach R1.
How to verify it
R3#show ip route Gateway of last resort is 10.0.23.1 to network 0.0.0.0 O*E2 0.0.0.0/0 [110/1] via 10.0.23.1, 00:04:02, GigabitEthernet0/0 10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks O 10.0.12.0/30 [110/2] via 10.0.23.1, 00:04:12, GigabitEthernet0/0 C 10.0.23.0/30 is directly connected, GigabitEthernet0/0 L 10.0.23.2/32 is directly connected, GigabitEthernet0/0 O 192.168.1.0/24 [110/3] via 10.0.23.1, 00:04:12, GigabitEthernet0/0 O 192.168.2.0/24 [110/2] via 10.0.23.1, 00:04:12, GigabitEthernet0/0 192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.3.0/24 is directly connected, GigabitEthernet0/1 L 192.168.3.1/32 is directly connected, GigabitEthernet0/1
R3#show ip ospf database external OSPF Router with ID (3.3.3.3) (Process ID 1) Type-5 AS External Link States LS age: 412 Options: (No TOS-capability, DC, Upward) 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: 0x5E7B Length: 36 Network Mask: /0 Metric Type: 2 (Larger than any link state path) MTID: 0 Metric: 1 Forward Address: 0.0.0.0 External Route Tag: 1
R1#show ip ospf | include boundary It is an autonomous system boundary router
With metric 10 metric-type 1 instead, R3 would show O*E1 0.0.0.0/0 [110/12]: the 10 set on R1 plus R3's cost of 2 to reach R1.
What goes wrong and how to troubleshoot it
- No default route on the other routers. R1 has the command but no default route of its own: the static route is missing, or its next hop is unreachable because the ISP interface is down. Check
show ip route 0.0.0.0on R1. - Internet traffic is black-holed during an ISP outage. Someone added
always, so R1 keeps advertising a default it can no longer use. - The default route is on the wrong router.
default-information originatewas typed on a router with no internet link. It does nothing there unlessalwaysis used, and then it attracts traffic it can't forward.
Common mistakes
- Trying to advertise the default with
network 0.0.0.0 255.255.255.255 area 0. That enables OSPF on every interface; it doesn't advertise a default route. - Expecting the E2 metric to grow with distance. It stays at 1 unless you choose E1.
- Adding
alwaysby habit, which breaks failover. - Configuring static default routes on R2 and R3 as well, which then override the OSPF route (static AD 1 beats OSPF 110).
💡 Exam tip: recognise O*E2 0.0.0.0/0 [110/1] in a routing table and know it comes from default-information originate on an ASBR. Know that the command needs a default route on that router unless always is added, and that E2 is the default metric type.
Key takeaways
default-information originateon the edge router advertises 0.0.0.0/0 to every OSPF router.- Without
alwaysit only works while the router has a default route of its own, which gives failover. - The route is external (type 5 LSA); the router becomes an ASBR.
- Other routers see
O*E2with metric 1; E1 would add the internal cost.
Check yourself
R1 has default-information originate but no default route of its own. What do R2 and R3 see?
R3 shows O*E2 0.0.0.0/0 [110/1]. R1 is two routers away. Why is the metric 1?
The ISP link on R1 fails. R1 has default-information originate always. What happens to traffic from LAN 3 to the internet?
Which router becomes an ASBR in this lesson?