Cisco

OSPF default-information originate

OSPF default-information originate
In: Cisco

This blog post shows how to inject a default route into a normal OSPF area. In order for OSPF to generate a default route, you should use the default-information originate IOS command on the router.

You might ask, why can't we just re-distribute a static default route into OSPF. Well, unlike EIGRP or RIP, we cannot create a default route into OSPF by simply redistributing a static route. OSPF doesn't advertise 'routes' as such instead it uses LSAs that keep track of links rather than the routes.

Diagram

In the sample network below, assuming 'building-01' is the only exit point to the Internet, we want to advertise a default route into other OSPF routers. The initial OSPF and interface configurations are shown below.

!! building-01 !!

interface Loopback0
 ip address 1.1.1.1 255.255.255.255
 
interface GigabitEthernet0/0
 ip address 192.168.10.6 255.255.255.252
 ip ospf 1 area 0
 
interface GigabitEthernet0/3
 ip address 10.10.20.32 255.255.0.0
 
router ospf 1
 router-id 1.1.1.1
 
ip route 0.0.0.0 0.0.0.0 10.10.0.1
!! exchange !!

interface Loopback0
 ip address 2.2.2.2 255.255.255.255

interface GigabitEthernet0/1
 ip address 192.168.10.5 255.255.255.252
 ip ospf 1 area 0

interface GigabitEthernet0/2
 ip address 192.168.10.1 255.255.255.252
 ip ospf 1 area 0

router ospf 1
 router-id 2.2.2.2
!! building-02 !!

interface Loopback0
 ip address 3.3.3.3 255.255.255.255

interface GigabitEthernet0/0
 ip address 192.168.10.2 255.255.255.252
 ip ospf 1 area 0

router ospf 1
 router-id 3.3.3.3

Default Route

The next step is to advertise a default route from building-01 to neighbouring OSPF routers. Once the default-information originate command is added, the router will originate a Type-5 LSA with a link ID of 0.0.0.0 and send it to the neighbouring OSPF routers.

The default route is advertised as IP prefix 0.0.0.0/0 in the OSPF process. Of course, we can't configure this prefix on an interface, so, it is inserted into OSPF as an external route.  

Please note that the router which originates the default route must have a default route in its routing table, in our case building-01. If the router doesn't have a default route then the 'always' keyword should be used which is explained at the end of this blog post.

!! building-01 !!

Gateway of last resort is 10.10.0.1 to network 0.0.0.0
S*    0.0.0.0/0 [1/0] via 10.10.0.1

router ospf 1
 router-id 1.1.1.1
 default-information originate

Once default-information originate is configured, both exchange and building-02 routers have the default route in their routing table as shown below.

building-02#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
       i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is 192.168.10.1 to network 0.0.0.0

O*E2  0.0.0.0/0 [110/1] via 192.168.10.1, 21:28:03, GigabitEthernet0/0
      3.0.0.0/32 is subnetted, 1 subnets
C        3.3.3.3 is directly connected, Loopback0
      192.168.10.0/24 is variably subnetted, 3 subnets, 2 masks
C        192.168.10.0/30 is directly connected, GigabitEthernet0/0
L        192.168.10.2/32 is directly connected, GigabitEthernet0/0
O        192.168.10.4/30 
           [110/2] via 192.168.10.1, 21:45:55, GigabitEthernet0/0
building-02#show ip ospf database 

            OSPF Router with ID (3.3.3.3) (Process ID 1)

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         1332        0x80000029 0x007D90 1
2.2.2.2         2.2.2.2         1883        0x80000029 0x009679 2
3.3.3.3         3.3.3.3         1581        0x80000027 0x007892 1

                Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
192.168.10.1    2.2.2.2         1883        0x80000027 0x00B5D0
192.168.10.6    1.1.1.1         57          0x80000028 0x004B41

                Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
0.0.0.0         1.1.1.1         1332        0x80000027 0x00D0B7 1

default-information originate 'always'

default-information originate 'always' command will originate a default route to neighbouring OSPF routers even if the default route is not present in the advertising router's (building-01) routing table.

For example, let's remove the default static route from building-01 and check the routing table on building-02.

building-01(config)#no ip route 0.0.0.0 0.0.0.0 10.10.0.1
building-02#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
       i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

      3.0.0.0/32 is subnetted, 1 subnets
C        3.3.3.3 is directly connected, Loopback0
      192.168.10.0/24 is variably subnetted, 3 subnets, 2 masks
C        192.168.10.0/30 is directly connected, GigabitEthernet0/0
L        192.168.10.2/32 is directly connected, GigabitEthernet0/0
O        192.168.10.4/30 
           [110/2] via 192.168.10.1, 21:53:06, GigabitEthernet0/0

As you can see above, the default route is no longer present in building-02's routing table. We can overcome this by adding the 'always' keyword to the command as shown below.

building-01(config-router)#default-information originate always 
building-02#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
       i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is 192.168.10.1 to network 0.0.0.0

O*E2  0.0.0.0/0 [110/1] via 192.168.10.1, 00:00:05, GigabitEthernet0/0
      3.0.0.0/32 is subnetted, 1 subnets
C        3.3.3.3 is directly connected, Loopback0
      192.168.10.0/24 is variably subnetted, 3 subnets, 2 masks
C        192.168.10.0/30 is directly connected, GigabitEthernet0/0
L        192.168.10.2/32 is directly connected, GigabitEthernet0/0
O        192.168.10.4/30 
           [110/2] via 192.168.10.1, 21:54:06, GigabitEthernet0/0

References

Cisco IOS Cookbook, 2nd Edition
Creating a Default Route in OSPF Problem You want to propagate a default route within an OSPF network. Solution To propagate a default route with OSPF, use the default-information originate … - Selection from Cisco IOS Cookbook, 2nd Edition [Book]
Written by
Suresh Vina
Tech enthusiast sharing Networking, Cloud & Automation insights. Join me in a welcoming space to learn & grow with simplicity and practicality.
Comments
More from Packetswitch
Table of Contents
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Packetswitch.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.