How to generate a default route in OSPF

There are several ways to generate a default route as an OSPF route and advertise it to other routers, as follows.

  • default-information originate command
  • Make the area as a stub area

This section describes a simple configuration example of generating a default route by configuring a stub area.

Generate default route by stub area

Network diagram

Figure OSPF generating default route (stub area)
Figure OSPF generating default route (stub area)

Conditions

  • Allow R2 to advertise the default route to R3 with OSPF to ensure connectivity for all interfaces.
  • The default route generation in R2 is done by making area 1 as a stub area.

Initial configuration

R1

interface Loopback0
 ip address 172.16.2.1 255.255.255.0 secondary
 ip address 172.16.1.1 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
!
ip route 192.168.0.0 255.255.0.0 192.168.12.2

R2

interface Loopback0
 ip address 192.168.2.2 255.255.255.0
 ip ospf network point-to-point
!
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0
!
!
router ospf 100
 log-adjacency-changes
 network 192.168.2.0 0.0.0.255 area 0
 network 192.168.23.0 0.0.0.255 area 1

R3

interface Loopback0
 ip address 192.168.3.3 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.23.3 255.255.255.0
!
router ospf 100
 log-adjacency-changes
 network 192.168.3.0 0.0.0.255 area 1
 network 192.168.23.0 0.0.0.255 area 1

Step1:Configuring the default route on R2.

Configure the default route as a static route on R2 to route packets to R1’s network.

R2

ip route 0.0.0.0 0.0.0.0 192.168.12.1

This default route configuration is only to ensure the connectivity to R1. The ABR in the stub area will generate a default route even if there is no default route in the routing table.

Step2:Make area 1 as a stub area.

Configure Area 1 as a normal stub area. Designate Area 1 as a stub area for both R2 and R3 that are included in Area 1.

R2/R3

router ospf 100
 area 1 stub

Step3:Verify the default route

Look at the OSPF LSDB and routing table on R3 and verify that the default route has been advertised from R2.

R3

R3#show ip ospf database

            OSPF Router with ID (192.168.3.3) (Process ID 100)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.2.2     192.168.2.2     6           0x80000003 0x009AAD 1
192.168.3.3     192.168.3.3     5           0x80000003 0x00893A 2

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.3    192.168.3.3     5           0x80000001 0x00E685

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         192.168.2.2     23          0x80000001 0x008B45
192.168.2.0     192.168.2.2     23          0x80000002 0x00C1A2
R3#show ip route
-- omitted --
Gateway of last resort is 192.168.23.2 to network 0.0.0.0
C    192.168.23.0/24 is directly connected, Ethernet0/0
O IA 192.168.2.0/24 [110/11] via 192.168.23.2, 00:00:11, Ethernet0/0
C    192.168.3.0/24 is directly connected, Loopback0
O*IA 0.0.0.0/0 [110/11] via 192.168.23.2, 00:00:11, Ethernet0/0

R2 (RID:192.168.2.2), the ABR of the stub area, advertises the default route to the area under it with LSA type 3. Therefore, the default route is registered in the routing table of R3 with “O IA”.

Step4:Change to Totally Stubbed Area

Configure area 1 as the totality stub area. configure area 1 stub no-summary on R2.

R2

router ospf 100
 area 1 stub no-summary

Step5:Verify the default route

Look at the OSPF LSDB and routing table for R3 and verify that the default route is advertised from R2.

R3

R3#show ip ospf database

            OSPF Router with ID (192.168.3.3) (Process ID 100)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.2.2     192.168.2.2     113         0x80000003 0x009AAD 1
192.168.3.3     192.168.3.3     112         0x80000003 0x00893A 2

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.3    192.168.3.3     112         0x80000001 0x00E685

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         192.168.2.2     10          0x80000002 0x008946
R3#show ip route
-- omitted --

Gateway of last resort is 192.168.23.2 to network 0.0.0.0

C    192.168.23.0/24 is directly connected, Ethernet0/0
C    192.168.3.0/24 is directly connected, Loopback0
O*IA 0.0.0.0/0 [110/11] via 192.168.23.2, 00:00:43, Ethernet0/0

We can see that even in the Totally Stub area, the ABR, R2 (RID:192.168.2.2), generates the default route with LSA type 3. We can also see that unlike the normal stub area, in the case of the Totally Stub area, there is only LSA type 3, which represents the default route.

Step4:Change to NSSA

Configure area 1 as NSSA for both R2 and R3.

R2/R3

router ospf 100
 no area 1 stub
 area 1 nssa

Step5:Verify the default route

Verify the OSPF LSDB and routing table for R3.

R3

R3#show ip ospf database

            OSPF Router with ID (192.168.3.3) (Process ID 100)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.2.2     192.168.2.2     42          0x80000005 0x002418 1
192.168.3.3     192.168.3.3     42          0x80000005 0x000DAC 2

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.3    192.168.3.3     41          0x80000003 0x006AF7

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.2.0     192.168.2.2     52          0x80000002 0x004913
R3#show ip route
-- omitted --

Gateway of last resort is not set

C    192.168.23.0/24 is directly connected, Ethernet0/0
O IA 192.168.2.0/24 [110/11] via 192.168.23.2, 00:00:42, Ethernet0/0
C    192.168.3.0/24 is directly connected, Loopback0

R2 does not advertise a default route to area 1 of the NSSA.

Step6:Generate a default route in NSSA

In NSSA, the ABR does not automatically generate a default route. In NSSA, the default route is generated by explicitly using the area nssa default-information-originate command on the router where you want to generate the default route. In this section, we will configure R2 to generate a default route.

R2

router ospf 100
 area 1 nssa default-information-originate

Step7:Verify the default route

Look at the LSDB and routing table on R3 and verify the default route generated in the NSSA on R2.

R3

R3#show ip ospf database

            OSPF Router with ID (192.168.3.3) (Process ID 100)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.2.2     192.168.2.2     176         0x80000005 0x002418 1
192.168.3.3     192.168.3.3     175         0x80000005 0x000DAC 2

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.3    192.168.3.3     175         0x80000003 0x006AF7

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.2.0     192.168.2.2     186         0x80000002 0x004913

                Type-7 AS External Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Tag
0.0.0.0         192.168.2.2     35          0x80000001 0x00E65D 0
R3#show ip route
-- omitted --

Gateway of last resort is 192.168.23.2 to network 0.0.0.0

C    192.168.23.0/24 is directly connected, Ethernet0/0
O IA 192.168.2.0/24 [110/11] via 192.168.23.2, 00:02:54, Ethernet0/0
C    192.168.3.0/24 is directly connected, Loopback0
O*N2 0.0.0.0/0 [110/1] via 192.168.23.2, 00:00:37, Ethernet0/0

By configuring the area 1 nssa default-information-originate command on R2, we can see that the default route is generated with LSA type 7. Therefore, in the routing table on R3, the default route is registered in “O N2”.

Step8:Change to Totally NSSA

Change Area 1 to totally NSSA.

R2

router ospf 100
 no area 1 nssa
 area 1 nssa no-summary

In order to remove the default-information-originate option, we have removed the NSSA configuration itself.

Step9:Verify the default route

Look at the LSDB and routing table of R3 and verify the default route generated in the NSSA by R2.

R3

R3#show ip ospf database

            OSPF Router with ID (192.168.3.3) (Process ID 100)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.2.2     192.168.2.2     38          0x80000007 0x00201A 1
192.168.3.3     192.168.3.3     300         0x80000005 0x000DAC 2

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.23.3    192.168.3.3     300         0x80000003 0x006AF7

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
0.0.0.0         192.168.2.2     42          0x80000001 0x0013B5
R3#show ip route
-- omitted --

Gateway of last resort is 192.168.23.2 to network 0.0.0.0

C    192.168.23.0/24 is directly connected, Ethernet0/0
C    192.168.3.0/24 is directly connected, Loopback0
O*IA 0.0.0.0/0 [110/11] via 192.168.23.2, 00:00:38, Ethernet0/0

We can see that the Totally NSSA generates a default route with LSA type 3, just like a normal stub or Totally Stub. Therefore, the default route is registered in the routing table of R3 with “O IA”.

Step10:Communication Verification

Since the default route is registered in R3 and R2, communication from R3 to R1 is possible.

R3

R3#ping 172.16.1.1 source 192.168.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/12/20 ms
R3#ping 172.16.2.1 source 192.168.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/12/24 ms

How the OSPF works