OSPF Default Route

Why Use an OSPF Default Route?

In most enterprise networks, only one router is connected to the Internet. This router knows how to reach all external destinations.

Instead of configuring a static default route (0.0.0.0/0) on every internal router, we can define it once on the edge router (R1) and then inject it into the OSPF domain.

OSPF default route injection topology with R1 connected to the Internet and R2 and R3 in Area 0
Figure 1 – OSPF used to demonstrate OSPF Default Route

This approach ensures that internal routers like R2 and R3 can dynamically learn the default route via OSPF, and forward any unknown traffic toward R1, which acts as the gateway to the Internet.

Step 1 – Configure the Static Route

First, we need to configure the default route using ip route 0.0.0.0 <next-hop> pointing to the IP of the ISP router.
In our scenario, the next-hop IP address is 203.0.115.2.

We assume OSPF neighbor relationships are already established and that networks are being advertised in Area 0.

OSPF network diagram showing R1 injecting a default route to R2 and R3, with Internet access via 203.0.115.2
Figure 2 – Configuration of default static route on R1

We now configure the static default route on R1:

R1(config)# ip route 0.0.0.0 0.0.0.0 203.0.115.2

This instructs R1 to send all unknown destination traffic to the ISP router at 203.0.115.2.

To verify that the route has been installed correctly, you can inspect the routing table:

R1# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is 203.0.115.2 to network 0.0.0.0

     192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.1.0/24 is directly connected, GigabitEthernet0/1
L       192.168.1.1/32 is directly connected, GigabitEthernet0/1
     192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.2.0/24 is directly connected, GigabitEthernet0/0
L       192.168.2.1/32 is directly connected, GigabitEthernet0/0
     203.0.115.0/24 is variably subnetted, 2 subnets, 2 masks
C       203.0.115.0/24 is directly connected, GigabitEthernet0/2
L       203.0.115.1/32 is directly connected, GigabitEthernet0/2
S*      0.0.0.0/0 [1/0] via 203.0.115.2

In this output:

  • The letter S indicates a static route
  • The asterisk * indicates that this route is the candidate default route
  • The line Gateway of last resort… confirms that R1 is now set to forward unknown traffic via the ISP

Step 2 – Inject into OSPF

Now that the default route exists on R1, we need to advertise it into OSPF so that other routers can learn it dynamically.
This is done using the default-information originate command under the OSPF process:

OSPF configuration on router R1 using default-information originate to advertise a static default route to R2 and R3
Figure 3 – Advertising the default static route in OSPF

In R1 we applied this command:

R1(config)# router ospf 1
R1(config-router)# default-information originate

This tells R1 to inject the default route into OSPF but only if the route exists in the routing table.

We can verify OSPF status with:

R1# show ip protocols
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 203.0.115.1
  It is an autonomous system boundary router
  Redistributing External Routes from,
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    192.168.1.0 0.0.0.255 area 0
    192.168.2.0 0.0.0.255 area 0
  Routing Information Sources:
    Gateway         Distance      Last Update
    203.0.115.1     110           00:00:03
  Distance: (default is 110)

This confirms:

  • R1 is now acting as an Autonomous System Boundary Router (ASBR).
  • The default static route is being redistributed into OSPF.
  • The OSPF process is active and running in Area 0.

At this point, the default route is ready to be propagated to internal routers through OSPF.

Step 3 – Default Route on Internal Routers

Once the default-information originate command is applied on R1, the router generates a Type 5 LSA (AS External) advertising the prefix 0.0.0.0/0. This LSA is flooded throughout Area 0 so that all OSPF routers can learn the default route.

R1 injects a default route into OSPF and routers R2 and R3 receive it as a Type 5 LSA
Figure 4 – R1 sends a Type 5 LSA advertising the default route

As a result, routers R2 and R3 receive this LSA and install the default route in their routing tables.

Verifying the LSA on R1

To check that the Type 5 LSA was correctly generated and advertised, use the following command on R1:

R1# show ip ospf database external
            OSPF Router with ID (203.0.115.1) (Process ID 1)
                Type-5 AS External Link States

  Routing Bit Set on this LSA
  LS age: 3
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 0.0.0.0 (External Network Number )
  Advertising Router: 203.0.115.1
  LS Seq Number: 80000001
  Checksum: 0xc4cd
  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

As you can see we have the Type 5 AS External Link States that represent the default route advertises in ospf.

Verifying the Default Route on R3

Now let’s check if R3 received the default route via OSPF.

First, verify the OSPF-specific entries in the routing table:

R3# show ip route ospf
O       192.168.1.0 [110/2] via 192.168.2.1, 00:00:07, GigabitEthernet0/1  
O*E2    0.0.0.0/0 [110/1] via 192.168.2.1, 00:00:07, GigabitEthernet0/1
  • O indicates the route was learned via OSPF
  • E2 denotes an external type 2 route
  • * means this is the candidate default route

Then, we can view the complete routing table to confirm the default route is active:

R3# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is 192.168.2.1 to network 0.0.0.0

O       192.168.1.0/24 [110/2] via 192.168.2.1, 00:00:24, GigabitEthernet0/1
     192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.2.0/24 is directly connected, GigabitEthernet0/1
L       192.168.2.2/32 is directly connected, GigabitEthernet0/1
     192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.20.0/24 is directly connected, GigabitEthernet0/0
L       192.168.20.2/32 is directly connected, GigabitEthernet0/0
O*E2    0.0.0.0/0 [110/1] via 192.168.2.1, 00:00:24, GigabitEthernet0/1

The ospf default route is installed with the code O for OSPF, E2 for OSPF external type 2 and * for candidate default.

Verifying the OSPF LSDB on R3

Finally, let’s verify the OSPF Link State Database (LSDB) to ensure the Type 5 LSA is present on R3:

R3# show ip ospf database
OSPF Router with ID (192.168.20.2) (Process ID 1)

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.10.2    192.168.10.2    332         0x80000003 0x00d03b 2
192.168.20.2    192.168.20.2    63          0x80000008 0x009a4c 2
203.0.115.1     203.0.115.1     63          0x80000006 0x00c448 2

                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.1.1     203.0.115.1     332         0x80000001 0x000b8a
192.168.1.2     192.168.10.2    97          0x80000001 0x000a3c
192.168.2.1     203.0.115.1     63          0x80000003 0x002b5e

                Type-5 AS External Link States
Link ID         ADV Router      Age         Seq#       Checksum Tag
0.0.0.0         203.0.115.1     263         0x80000001 0x00c4cd 1

The entry with Link ID: 0.0.0.0 confirms that R3 has learned the default route via a Type 5 LSA from R1 and that it is present in the OSPF database.

Step 4 – Test External Access

Now that the OSPF default route is installed on R3, devices within the internal network should be able to access external resources through the ASBR (R1).

Let’s verify this by testing Internet connectivity from PC2, which is connected to R3.

Traffic flow from PC2 to YouTube using OSPF default route via R3 and R1 acting as ASBR
Figure 5 – PC2 uses R3 and R1 to reach an external destination through the default route

From PC2, we use the ping command to test communication with a public website such as YouTube:

PC2> ping youtube.com

Pinging youtube.com [142.250.185.110] with 32 bytes of data:
Reply from 142.250.185.110: bytes=32 time=24ms TTL=116
Reply from 142.250.185.110: bytes=32 time=25ms TTL=116
Reply from 142.250.185.110: bytes=32 time=24ms TTL=116
Reply from 142.250.185.110: bytes=32 time=25ms TTL=116

Ping statistics for 142.250.185.110:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)

This confirms successful end-to-end communication using the OSPF-learned default route.

Summary

In this lesson, we demonstrated how to configure and propagate a OSPF default route.
The process starts by defining a static default route on the edge router (R1), then injecting it into OSPF with default-information originate. This allows internal routers like R2 and R3 to dynamically learn the route via a Type 5 LSA.
Once installed, internal devices can reach external networks through R1, acting as the gateway to the Internet.

Below is a quick recap of the key concepts:

ConceptExplanation
Static Default Routeip route 0.0.0.0 0.0.0.0 <ISP IP>
OSPF Default Advertisementdefault-information originate
Route Type in OSPFO*E2 (external type 2 route)
Propagation MethodType 5 LSA generated by the ASBR (R1)