Cisco device uses “default-information originate” statement to generate a default route in OSPF domain. There are two ways to originate default route by using this command:
1) When you configure “default-information originate” under OSPF process without any argument after this statement, OSPF process will first check,if any default route is already present in routing table. If a default route is already present in routing table via static or any dynamic protocol, OSPF originate default route. If default route does not exist in routing table, OSPF will not originate default route.
2) This behavior can be modified by adding “always” argument to the “default-infomation originate” statement, which essentially skips the checking for a default route already being installed in the table.
This article will discuss about conditional route origination in OSPF domain. Conditional default route in OSPF originate by using route-map in default-information command under router OSPF process. The route map configured in the default-information originates command check the existing IP prefixes in the IP routing table.
Configuration Steps:
1) prefix-list or access-list: To originate default route only when necessary prefixes are present in routing table.First you need to match these prefixes by configuring prefix-list or access-list.
Example:
Prefix-list configuration:
Router (config)#ip prefix-list Default_route sequence 10 permit 192.168.1.0/24
Access-list configuration:
Router(config)#ip access-list standard Default_route
Router(config-std-nacl)# permit 192.168.1.0 0.0.0.255
2) Attach prefix-list or access-list in route map:
Example:
Router(config)#route-map Ospf_default permit 10
Router(config-route-map)#match ip address prefix-list Default_route
Router(config-route-map)#exit
3) Configure “default-information originate always route-map” statement:
Example:
Router(config)#router ospf 100
Router(config-router)#default-information originate always route-map Ospf_default
Background:
In the below topology R1 is connected to two ISP using serial interface. The router R1 and R2 runs OSPF in Area 0, where R1 is advertising default route to R2 only when both serial links are up. Once both link goes down R1 should withdraw default route from OSPF domain.
Topology Diagram:
Configuring R1:
R1(config)#ip prefix-list default_route sequence 10 permit 192.168.1.0/24
R1(config)#ip prefix-list default_route sequence 20 permit 192.168.2.0/24
R1(config)#route-map ospf_default permit 10
R1(config-route-map)#match ip add prefix-list default_route
R1(config-route-map)#exit
R1(config)#router ospf 100
R1(config-router)#default-information originate always route-map ospf_default
R1(config-router)#exit
R1 advertise a default route to OSPF domain, as both ISP links are up.
Verifying default route on R2
R2#sh ip ospf database | in 0.0.0.0
0.0.0.0 192.168.2.1 371 0x80000001 0x0018CA 100
R2#sh ip route ospf
O*E2 0.0.0.0/0 [110/1] via 10.1.1.1, 00:06:22, FastEthernet0/0
We need at least one prefix match in list present in R1’s routing table to advertise default route in OSPF domain.
Disabling one link towards ISP1:
R1(config)#int s0/0
R1(config-if)#sh
*Mar 1 00:17:09.971: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down
*Mar 1 00:17:10.971: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
Verification on R2:
R2#sh ip route ospf
O*E2 0.0.0.0/0 [110/1] via 10.1.1.1, 00:10:30, FastEthernet0/0
Disabling remaining link towards ISP2:
Verification on R2:
R1(config-if)#int s0/1
R1(config-if)#sh
R1(config-if)#
*Mar 1 00:18:39.131: %SYS-5-CONFIG_I: Configured from console by console
*Mar 1 00:18:39.731: %LINK-5-CHANGED: Interface Serial0/1, changed state to administratively down
Turned on debug in R2 to get closer view of default route deletion
R2#debug ip routing
IP routing debugging is on
*Mar 1 00:19:25.799: RT: del 0.0.0.0 via 10.1.1.1, ospf metric [110/1]
*Mar 1 00:19:25.803: RT: delete network route to 0.0.0.0
*Mar 1 00:19:25.803: RT: NET-RED 0.0.0.0/0
*Mar 1 00:19:25.803: RT: NET-RED 0.0.0.0/0
R2#sh ip route ospf
R2#
From the above output it is clear that when the both links connected to ISP goes down, router R1 stop generation of default route to OSPF domain.
Original Reference Guide from https://supportforums.cisco.com/docs/DOC-27659
More Notes:
Types of OSPF Areas
Normal Areas: These areas can either be standard areas or transit (backbone) areas. Standard areas are defined as areas that can accept intra-area, inter-area and external routes. The backbone area is the central area to which all other areas in OSPF connect.
Note: Intra-area routes refer to updates that are passed within the area. Inter-area routes refer to updates that are passed between areas. External routes refer to updates passed from another routing protocol into the OSPF domain by the Autonomous System Boundary Router (ASBR).
Stub Areas: These areas do not accept routes belonging to external autonomous systems (AS); however, these areas have inter-area and intra-area routes. In order to reach the outside networks, the routers in the stub area use a default route which is injected into the area by the Area Border Router (ABR). A stub area is typically configured in situations where the branch office need not know about all the routes to every other office, instead it could use a default route to the central office and get to other places from there. Hence the memory requirements of the leaf node routers is reduced, and so is the size of the OSPF database.
To define an area as a stub area, use the OSPF router configuration command, area <area id> stub
Totally Stub Areas: These areas do not allow routes other than intra-area and the default routes to be propagated within the area. The ABR injects a default route into the area and all the routers belonging to this area use the default route to send any traffic outside the area.
To define a totally stub area, use the OSPF router configuration command, area <area id> stub no-summary, on the ABR.
NSSA: This type of area allows the flexibility of importing a few external routes into the area while still trying to retain the stub characteristic. Assume that one of the routers in the stub area is connected to an external AS running a different routing protocol, it now becomes the ASBR, and hence the area can no more be called a stub area. However, if the area is configured as a NSSA, then the ASBR generates a NSSA external link-state advertisement (LSA) (Type-7) which can be flooded throughout the NSSA area. These Type-7 LSAs are converted into Type-5 LSAs at the NSSA ABR and flooded throughout the OSPF domain
In order to define a NSSA, use the OSPF router configuration command, area <area id> nssa.
More DETAILS of How OSPF Generate Default Routes you can visit: https://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094a74.shtml
More Related Networking Tips:
How to Configure OSPF in a Single Area?
How to Configure OSPF in the Cisco IOS?
How to Troubleshoot and Verifying OSPF Configuration?