How to configure OSPF Default Route

With OSPF it is no problem to configure a default route. There are a couple of options if you want to do this. Here’s an example:

R1 R2 OSPF Area 0

R1(config)#router ospf 1  
R1(config-router)#default-information originate ?
  always       Always advertise default route
  metric       OSPF default metric
  metric-type  OSPF metric type for default routes
  route-map    Route-map reference
  <cr>

There are a number of things. We can change the metric or metric type but the most important thing most people forget is the always keyword.

If you use the default-information originate you can advertise a default route in OSPF. OSPF won’t advertise a default route if you don’t already have it in your routing table. If you add the always keyword it will advertise the default route even if you don’t have it in the routing table. Once you have advertised the default route it will look like this on other routers:

R2#show ip ospf database | begin Type-5
		Type-5 AS External Link States

Link ID         ADV Router      Age         Seq#       Checksum Tag
0.0.0.0         172.16.3.1      59          0x80000001 0x008D64 1
R2#show ip route ospf 
O*E2 0.0.0.0/0 [110/1] via 192.168.12.1, 00:00:24, FastEthernet0/0

It will show up as a LSA type 5 external route.

Configurations

Want to take a look for yourself? Here you will find the final configuration of each device.

R1

hostname R1
!
interface FastEthernet0/1
 ip address 192.168.12.1 255.255.255.0
!
router ospf 1
 network 192.168.12.0
 default-information originate always
!
end

R2

hostname R2
!
interface FastEthernet0/1
 ip address 192.168.12.2 255.255.255.0
!
router ospf 1
 network 192.168.12.0
!
end


I hope this is helpful to you, if you have any questions just leave a comment.

Tags:


Forum Replies

  1. What is the use case for this…?

    BR,Srini

  2. A good example would be a small network where one router has an Internet connection. You can advertise the default route to all routers in the network.

  3. Rene,
    Great lesson I have a question in my lab I have 3 routers
    R1---- 192.168 1.0---- R2
    R2-----192.168.2.0 ----R3

    I am advertising default route on R2 but I can not ping 192.168.2.3 from R1.
    R1 can see a default route O*E2 0.0.0.0/0 [110/1] via 192.168.1.2, 00:08:46, FastEthernet0/0.

    Please let me know.
    Thanks

    Hamood

  4. Hi Hamood,

    R1 knows the default route so we can assume that the packet makes it from R1 to R2. Since 192.168.2.0 is directly connected to R2, it knows how to reach R3 (192.168.2.3). What about the return traffic?

    Does R3 also have the default route in its routing table or is there anything preventing it from responding to R1?

    Rene

  5. Hi Rene

    I have a couple of questions. Why this is sent as a Type 5 LSA even when the R1 and R2 routers are in same area. I guess since this is a Type 5 LSA it shows as an O*E2 ( External with Metric 2, so the actual cost of R1 to R2)

    Thanks
    Palani

31 more replies! Ask a question or join the discussion by visiting our Community Forum