Configuring OSPF

Information About OSPF

OSPF is an Interior Gateway Protocol (IGP) designed expressly for IP networks, supporting IP subnetting and tagging of externally derived routing information. OSPF also allows packet authentication and uses IP multicast when sending and receiving packets. The Cisco implementation supports RFC 1253, OSPF management information base (MIB).

The Cisco implementation conforms to the OSPF Version 2 specifications with these key features:

  • Definition of stub areas is supported.

  • Routes learned through any IP routing protocol can be redistributed into another IP routing protocol. At the intradomain level, this means that OSPF can import routes learned through EIGRP and RIP. OSPF routes can also be exported into RIP.

  • Plain text and MD5 authentication among neighboring routers within an area is supported.

  • Configurable routing interface parameters include interface output cost, retransmission interval, interface transmit delay, router priority, router dead and hello intervals, and authentication key.

  • Virtual links are supported.

  • Not-so-stubby-areas (NSSAs) per RFC 1587are supported.

OSPF typically requires coordination among many internal routers, area border routers (ABRs) connected to multiple areas, and autonomous system boundary routers (ASBRs). The minimum configuration would use all default parameter values, no authentication, and interfaces assigned to areas. If you customize your environment, you must ensure coordinated configuration of all routers.

OSPF Nonstop Forwarding

The Device or switch stack supports two levels of nonstop forwarding (NSF):

OSPF NSF Awareness

When the neighboring router is NSF-capable, the Layer 3 Device continues to forward packets from the neighboring router during the interval between the primary Route Processor (RP) in a router crashing and the backup RP taking over, or while the primary RP is manually reloaded for a non-disruptive software upgrade.

This feature cannot be disabled.

OSPF NSF Capability

supports the OSPFv2 NSF IETF format in addition to the OSPFv2 NSF Cisco format that is supported in earlier releases. For information about this feature, see : NSF—OSPF (RFC 3623 OSPF Graceful Restart).

The also supports OSPF NSF-capable routing for IPv4 for better convergence and lower traffic loss following a stack's active switch change.


Note


OSPF NSF requires that all neighbor networking devices be NSF-aware. If an NSF-capable router discovers non-NSF aware neighbors on a network segment, it disables NSF capabilities for that segment. Other network segments where all devices are NSF-aware or NSF-capable continue to provide NSF capabilities.


Use the nsf OSPF routing configuration command to enable OSPF NSF routing. Use the show ip ospf privileged EXEC command to verify that it is enabled.

For more information, see Cisco Nonstop Forwarding:
http://www.cisco.com/en/US/docs/ios/ha/configuration/guide/ha-nonstp_fwdg.html

OSPF Area Parameters

You can optionally configure several OSPF area parameters. These parameters include authentication for password-based protection against unauthorized access to an area, stub areas, and not-so-stubby-areas (NSSAs). Stub areas are areas into which information on external routes is not sent. Instead, the area border router (ABR) generates a default external route into the stub area for destinations outside the autonomous system (AS). An NSSA does not flood all LSAs from the core into the area, but can import AS external routes within the area by redistribution.

Route summarization is the consolidation of advertised addresses into a single summary route to be advertised by other areas. If network numbers are contiguous, you can use the area range router configuration command to configure the ABR to advertise a summary route that covers all networks in the range.

Other OSPF Parameters

You can optionally configure other OSPF parameters in router configuration mode.

  • Route summarization: When redistributing routes from other protocols. Each route is advertised individually in an external LSA. To help decrease the size of the OSPF link state database, you can use the summary-address router configuration command to advertise a single router for all the redistributed routes included in a specified network address and mask.

  • Virtual links: In OSPF, all areas must be connected to a backbone area. You can establish a virtual link in case of a backbone-continuity break by configuring two Area Border Routers as endpoints of a virtual link. Configuration information includes the identity of the other virtual endpoint (the other ABR) and the nonbackbone link that the two routers have in common (the transit area). Virtual links cannot be configured through a stub area.

  • Default route: When you specifically configure redistribution of routes into an OSPF routing domain, the route automatically becomes an autonomous system boundary router (ASBR). You can force the ASBR to generate a default route into the OSPF routing domain.

  • Domain Name Server (DNS) names for use in all OSPF show privileged EXEC command displays makes it easier to identify a router than displaying it by router ID or neighbor ID.

  • Default Metrics: OSPF calculates the OSPF metric for an interface according to the bandwidth of the interface. The metric is calculated as ref-bw divided by bandwidth, where ref is 10 by default, and bandwidth (bw ) is specified by the bandwidth interface configuration command. For multiple links with high bandwidth, you can specify a larger number to differentiate the cost on those links.

  • Administrative distance is a rating of the trustworthiness of a routing information source, an integer between 0 and 255, with a higher value meaning a lower trust rating. An administrative distance of 255 means the routing information source cannot be trusted at all and should be ignored. OSPF uses three different administrative distances: routes within an area (interarea), routes to another area (interarea), and routes from another routing domain learned through redistribution (external). You can change any of the distance values.

  • Passive interfaces: Because interfaces between two devices on an Ethernet represent only one network segment, to prevent OSPF from sending hello packets for the sending interface, you must configure the sending device to be a passive interface. Both devices can identify each other through the hello packet for the receiving interface.

  • Route calculation timers: You can configure the delay time between when OSPF receives a topology change and when it starts the shortest path first (SPF) calculation and the hold time between two SPF calculations.

  • Log neighbor changes: You can configure the router to send a syslog message when an OSPF neighbor state changes, providing a high-level view of changes in the router.

LSA Group Pacing

The OSPF LSA group pacing feature allows the router to group OSPF LSAs and pace the refreshing, check-summing, and aging functions for more efficient router use. This feature is enabled by default with a 4-minute default pacing interval, and you will not usually need to modify this parameter. The optimum group pacing interval is inversely proportional to the number of LSAs the router is refreshing, check-summing, and aging. For example, if you have approximately 10,000 LSAs in the database, decreasing the pacing interval would benefit you. If you have a very small database (40 to 100 LSAs), increasing the pacing interval to 10 to 20 minutes might benefit you slightly.

Loopback Interfaces

OSPF uses the highest IP address configured on the interfaces as its router ID. If this interface is down or removed, the OSPF process must recalculate a new router ID and resend all its routing information out its interfaces. If a loopback interface is configured with an IP address, OSPF uses this IP address as its router ID, even if other interfaces have higher IP addresses. Because loopback interfaces never fail, this provides greater stability. OSPF automatically prefers a loopback interface over other interfaces, and it chooses the highest IP address among all loopback interfaces.

How to Configure OSPF

Default OSPF Configuration

Table 1. Default OSPF Configuration

Feature

Default Setting

Interface parameters

Cost:

Retransmit interval: 5 seconds.

Transmit delay: 1 second.

Priority: 1.

Hello interval: 10 seconds.

Dead interval: 4 times the hello interval.

No authentication.

No password specified.

MD5 authentication disabled.

Area

Authentication type: 0 (no authentication).

Default cost: 1.

Range: Disabled.

Stub: No stub area defined.

NSSA: No NSSA area defined.

Auto cost

100 Mb/s.

Default-information originate

Disabled. When enabled, the default metric setting is 10, and the external route type default is Type 2.

Default metric

Built-in, automatic metric translation, as appropriate for each routing protocol.

Distance OSPF

dist1 (all routes within an area): 110.
dist2 (all routes from one area to another): 110.
and dist3 (routes from other routing domains): 110.

OSPF database filter

Disabled. All outgoing link-state advertisements (LSAs) are flooded to the interface.

IP OSPF name lookup

Disabled.

Log adjacency changes

Enabled.

Neighbor

None specified.

Neighbor database filter

Disabled. All outgoing LSAs are flooded to the neighbor.

Network area

Disabled.

Router ID

No OSPF routing process defined.

Summary address

Disabled.

Timers LSA group pacing

240 seconds.

Timers shortest path first (spf)

spf delay: 50 miliseconds; spf-holdtime: 200 miliseconds.

Virtual link

No area ID or router ID defined.

Hello interval: 10 seconds.

Retransmit interval: 5 seconds.

Transmit delay: 1 second.

Dead interval: 40 seconds.

Authentication key: no key predefined.

Message-digest key (MD5): no key predefined.

Configuring Basic OSPF Parameters

To enable OSPF, create an OSPF routing process, specify the range of IP addresses to associate with the routing process, and assign area IDs to be associated with that range.

Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

router ospf process-id

Example:


Device(config)# router ospf 15

Enables OSPF routing, and enter router configuration mode. The process ID is an internally used identification parameter that is locally assigned and can be any positive integer. Each OSPF routing process has a unique value.

Note

 

OSPF for Routed Access supports only one OSPFv2 and one OSPFv3 instance with a maximum number of 1000 dynamically learned routes.

Step 3

network address wildcard-mask area area-id

Example:


Device(config)# network 10.1.1.1 255.240.0.0 area 20

Define an interface on which OSPF runs and the area ID for that interface. You can use the wildcard-mask to use a single command to define one or more multiple interfaces to be associated with a specific OSPF area. The area ID can be a decimal value or an IP address.

Step 4

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 5

show ip protocols

Example:


Device# show ip protocols

Verifies your entries.

Step 6

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Configuring OSPF Interfaces

You can use the ip ospf interface configuration commands to modify interface-specific OSPF parameters. You are not required to modify any of these parameters, but some interface parameters (hello interval, dead interval, and authentication key) must be consistent across all routers in an attached network. If you modify these parameters, be sure all routers in the network have compatible values.


Note


The ip ospf interface configuration commands are all optional.


Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

interface interface-id

Example:


Device(config)# interface gigabitethernet 1/0/1

Enters interface configuration mode, and specifies the Layer 3 interface to configure.

Step 3

ip ospf cost

Example:


Device(config-if)# ip ospf 8

(Optional) Explicitly specifies the cost of sending a packet on the interface.

Step 4

ip ospf retransmit-interval seconds

Example:


Device(config-if)# ip ospf transmit-interval 10

(Optional) Specifies the number of seconds between link state advertisement transmissions. The range is 1 to 65535 seconds. The default is 5 seconds.

Step 5

ip ospf transmit-delay seconds

Example:


Device(config-if)# ip ospf transmit-delay 2

(Optional) Sets the estimated number of seconds to wait before sending a link state update packet. The range is 1 to 65535 seconds. The default is 1 second.

Step 6

ip ospf priority number

Example:


Device(config-if)# ip ospf priority 5

(Optional) Sets priority to help find the OSPF designated router for a network. The range is from 0 to 255. The default is 1.

Step 7

ip ospf hello-interval seconds

Example:


Device(config-if)# ip ospf hello-interval 12

(Optional) Sets the number of seconds between hello packets sent on an OSPF interface. The value must be the same for all nodes on a network. The range is 1 to 65535 seconds. The default is 10 seconds.

Step 8

ip ospf dead-interval seconds

Example:


Device(config-if)# ip ospf dead-interval 8

(Optional) Sets the number of seconds after the last device hello packet was seen before its neighbors declare the OSPF router to be down. The value must be the same for all nodes on a network. The range is 1 to 65535 seconds. The default is 4 times the hello interval.

Step 9

ip ospf authentication-key key

Example:


Device(config-if)# ip ospf authentication-key password

(Optional) Assign a password to be used by neighboring OSPF routers. The password can be any string of keyboard-entered characters up to 8 bytes in length. All neighboring routers on the same network must have the same password to exchange OSPF information.

Step 10

ip ospf message digest-key keyid md5 key

Example:


Device(config-if)# ip ospf message digest-key 16 md5 your1pass

(Optional) Enables MDS authentication.

  • keyid —An identifier from 1 to 255.

  • key —An alphanumeric password of up to 16 bytes.

Step 11

ip ospf database-filter all out

Example:


Device(config-if)# ip ospf database-filter all out

(Optional) Block flooding of OSPF LSA packets to the interface. By default, OSPF floods new LSAs over all interfaces in the same area, except the interface on which the LSA arrives.

Step 12

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 13

show ip ospf interface [interface-name]

Example:


Device# show ip ospf interface

Displays OSPF-related interface information.

Step 14

show ip ospf neighbor detail

Example:


Device# show ip ospf neighbor detail

Displays NSF awareness status of neighbor switch. The output matches one of these examples:

  • Options is 0x52

    LLS Options is 0x1 (LR)

    When both of these lines appear, the neighbor switch is NSF aware.

  • Options is 0x42 —This means the neighbor switch is not NSF aware.

Step 15

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Configuring OSPF Area Parameters

Before you begin


Note


The OSPF area router configuration commands are all optional.


Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

router ospf process-id

Example:


Device(config)# router ospf 109

Enables OSPF routing, and enter router configuration mode.

Step 3

area area-id authentication

Example:


Device(config-router)# area 1 authentication

(Optional) Allow password-based protection against unauthorized access to the identified area. The identifier can be either a decimal value or an IP address.

Step 4

area area-id authentication message-digest

Example:


Device(config-router)# area 1 authentication message-digest

(Optional) Enables MD5 authentication on the area.

Step 5

area area-id stub [no-summary]

Example:


Device(config-router)# area 1 stub

(Optional) Define an area as a stub area. The no-summary keyword prevents an ABR from sending summary link advertisements into the stub area.

Step 6

area area-id nssa [no-redistribution] [default-information-originate] [no-summary]

Example:


Device(config-router)# area 1 nssa default-information-originate

(Optional) Defines an area as a not-so-stubby-area. Every router within the same area must agree that the area is NSSA. Select one of these keywords:

  • no-redistribution —Select when the router is an NSSA ABR and you want the redistribute command to import routes into normal areas, but not into the NSSA.

  • default-information-originate —Select on an ABR to allow importing type 7 LSAs into the NSSA.

  • no-redistribution —Select to not send summary LSAs into the NSSA.

Step 7

area area-id range address mask

Example:


Device(config-router)# area 1 range 255.240.0.0

(Optional) Specifies an address range for which a single route is advertised. Use this command only with area border routers.

Step 8

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 9

show ip ospf [process-id]

Example:


Device# show ip ospf

Displays information about the OSPF routing process in general or for a specific process ID to verify configuration.

Step 10

show ip ospf [process-id [area-id]] database

Example:


Device# show ip osfp database

Displays lists of information related to the OSPF database for a specific router.

Step 11

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Configuring Other OSPF Parameters

Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

router ospf process-id

Example:


Device(config)# router ospf 10

Enables OSPF routing, and enter router configuration mode.

Step 3

summary-address address mask

Example:


Device(config)# summary-address 10.1.1.1 255.255.255.0

(Optional) Specifies an address and IP subnet mask for redistributed routes so that only one summary route is advertised.

Step 4

area area-id virtual-link router-id [hello-interval seconds] [retransmit-interval seconds] [trans] [[authentication-key key] | message-digest-key keyid md5 key]]

Example:


Device(config)# area 2 virtual-link 192.168.255.1 hello-interval 5

(Optional) Establishes a virtual link and set its parameters.

Step 5

default-information originate [always] [metric metric-value] [metric-type type-value] [route-map map-name]

Example:


Device(config)# default-information originate metric 100 metric-type 1

(Optional) Forces the ASBR to generate a default route into the OSPF routing domain. Parameters are all optional.

Step 6

ip ospf name-lookup

Example:


Device(config)# ip ospf name-lookup

(Optional) Configures DNS name lookup. The default is disabled.

Step 7

ip auto-cost reference-bandwidth ref-bw

Example:


Device(config)# ip auto-cost reference-bandwidth 5

(Optional) Specifies an address range for which a single route will be advertised. Use this command only with area border routers.

Step 8

distance ospf {[inter-area dist1] [inter-area dist2] [external dist3]}

Example:


Device(config)# distance ospf inter-area 150

(Optional) Changes the OSPF distance values. The default distance for each type of route is 110. The range is 1 to 255.

Step 9

passive-interface type number

Example:


Device(config)# passive-interface gigabitethernet 1/0/6

(Optional) Suppresses the sending of hello packets through the specified interface.

Step 10

timers throttle spf spf-delay spf-holdtime spf-wait

Example:


Device(config)# timers throttle spf 200 100 100

(Optional) Configures route calculation timers.

  • spf-delay —Delay between receiving a change to SPF calculation. The range is from 1 to 600000 in miliseconds.

  • spf-holdtime —Delay between first and second SPF calculation. The range is from 1 to 600000 in milliseconds.

  • spf-wait —Maximum wait time in milliseconds for SPF calculations. The range is from 1 to 600000 in milliseconds.

Step 11

ospf log-adj-changes

Example:


Device(config)# ospf log-adj-changes

(Optional) Sends syslog message when a neighbor state changes.

Step 12

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 13

show ip ospf [process-id [area-id]] database

Example:


Device# show ip ospf database

Displays lists of information related to the OSPF database for a specific router.

Step 14

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Changing LSA Group Pacing

Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

router ospf process-id

Example:


Device(config)# router ospf 25

Enables OSPF routing, and enter router configuration mode.

Step 3

timers lsa-group-pacing seconds

Example:


Device(config-router)# timers lsa-group-pacing 15

Changes the group pacing of LSAs.

Step 4

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 5

show running-config

Example:


Device# show running-config 

Verifies your entries.

Step 6

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Configuring a Loopback Interface

Procedure

  Command or Action Purpose

Step 1

configure terminal

Example:


Device# configure terminal

Enters the global configuration mode.

Step 2

interface loopback 0

Example:


Device(config)# interface loopback 0

Creates a loopback interface, and enter interface configuration mode.

Step 3

ip address address mask

Example:


Device(config-if)# ip address 10.1.1.5 255.255.240.0

Assign an IP address to this interface.

Step 4

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 5

show ip interface

Example:


Device# show ip interface

Verifies your entries.

Step 6

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Monitoring OSPF

You can display specific statistics such as the contents of IP routing tables, caches, and databases.

Table 2. Show IP OSPF Statistics Commands

show ip ospf [process-id]

Displays general information about OSPF routing processes.

show ip ospf [process-id] database [router] [link-state-id]

show ip ospf [process-id] database [router] [self-originate]

show ip ospf [process-id] database [router] [adv-router [ip-address]]

show ip ospf [process-id] database [network] [link-state-id]

show ip ospf [process-id] database [summary] [link-state-id]

show ip ospf [process-id] database [asbr-summary] [link-state-id]

show ip ospf [process-id] database [external] [link-state-id]

show ip ospf [process-id area-id] database [database-summary]

Displays lists of information related to the OSPF database.

show ip ospf border-routes

Displays the internal OSPF routing ABR and ASBR table entries.

show ip ospf interface [interface-name]

Displays OSPF-related interface information.

show ip ospf neighbor [interface-name] [neighbor-id] detail

Displays OSPF interface neighbor information.

show ip ospf virtual-links

Displays OSPF-related virtual links information.

Configuration Examples for OSPF

Example: Configuring Basic OSPF Parameters

This example shows how to configure an OSPF routing process and assign it a process number of 109:


Device(config)# router ospf 109
Device(config-router)# network 131.108.0.0 255.255.255.0 area 24

Feature Information for OSPF

Table 3. Feature Information for OSPF

Feature Name

Release

Feature Information

OSPF (Open Shortest Path First)

Cisco IOS XE Everest 16.6.1

This feature was introduced