How to generate a default route in OSPF

OSPF can also generate default route like other routing protocols such as RIP and EIGRP. As shown in the following figure, default route is often used to route packets destined for the Internet.

Figure Example of using the default route
Figure Example of using the default route

In addition to routing to the Internet, default route is also generated to ensure reachability from the stub area to the external network. To generate default route in OSPF, the following methods are available

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

In the following sections, we will explain how to generate default route in OSPF.

default-information originate command

In RIP and EIGRP, the default route can be generated by configuring it as a static route and redistributing it. However, with OSPF, the default route cannot be generated in this way. When static routes are redistributed to OSPF, the default route is not subject to redistribution. To generate a default route in OSPF, use the default-information originate command. The command syntax is as follows

default-information originate command

(config)#router ospf <process>
(config-router)#default-information originate [always] [metric <metric>] [metric-type {1|2}]

The default-information originate command causes the router to generate a default route with LSA type 5. Also, the metric type is 2 and the metric is 1. The metric value and metric type can be changed by specifying options.

However, there is a condition for generating a default route. The condition is that the default route must already exist in the routing table. To generate an OSPF default route even when there is no default route in the routing table, add the “always” option.

default-information originate command
  • Generate with LSA type 5 and advertise it to other OSPF routers
  • The default route must already exist in the routing table.

Example of default-information originate

Verify the default-information originate configuration in the following network diagram.

 Figure default-information originate sample network diagram
Figure default-information originate sample network diagram

Configure R2 in this network diagram as follows to generate the default route.

R2 Generate default route

router ospf 1
 network area 0
 network area 0
 default-information originate
ip route

After configuring the default route statically, the default-information originate command will cause R2 to generate LSA type 5, which represents the default route. the LSA type 5 of R2 is as follows

R2 show ip ospf database external

R2#show ip ospf database external 

            OSPF Router with ID ( (Process ID 1)

                Type-5 AS External Link States

  LS age: 88
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: (External Network Number )
  Advertising Router:
  LS Seq Number: 80000002
  Checksum: 0xFCAC
  Length: 36
  Network Mask: /0
        Metric Type: 2 (Larger than any link state path)
        TOS: 0 
        Metric: 1 
        Forward Address:
        External Route Tag: 1

Then, the default route with R2 as the next hop will appear in the routing table of R1. Since it is an external route and metric type 2, it will be coded “O E2”.

R1 show ip route

R1#show ip route 
-- omitted --

Gateway of last resort is to network is subnetted, 1 subnets
C is directly connected, Serial1/0 is subnetted, 2 subnets
C is directly connected, Loopback0
O [110/65] via, 00:03:56, Serial1/0
O*E2 [110/1] via, 00:03:56, Serial1/0

Figure Generating a default route using the default-information originate command

Generate default route by stub area

The ABR of the stub area will generate a default route. ABRs in the Totally Stub area and Totally NSSA also automatically generate default routes. The default route generated by ABR in stub, Totally Stub, and Totally NSSA is LSA type 3.

Note that NSSA’s ABR does not automatically generate the default route; you must explicitly configure the area nssa default-information originate command in order for NSSA to generate the default route. And in this case, the default route will be generated with LSA type 7.

The following figure shows the generation of a default route in a stub area.

Figure Default route generation in stub/totaly stub/totaly NSSA/NSSA

How the OSPF works