|
Open shortest path first (OSPF) is an IGP developed by the OSPF working group of the Internet Engineering Task Force (IETF). Designed expressly for IP networks, OSPF supports IP subnetting and tagging of externally derived routing information. OSPF also allows packet authentication and uses IP multicast when sending/receiving packets.
We support RFC 1253, Open Shortest Path First (OSPF) MIB, August 1991. The OSPF MIB defines an IP routing protocol that provides management information related to OSPF and is supported by Cisco routers.
For protocol-independent features, see the chapter "Configuring IP Routing
Protocol-Independent Features" in this document.
To configure OSPF, complete the tasks in the following sections. Enabling OSPF is mandatory; the other tasks are optional, but might be required for your application.
In interface configuration mode, specify any of the following interface
parameters as needed for your network:
X.25 and Frame Relay provide an optional broadcast
capability that can be configured in the map to allow OSPF to run as a
broadcast network. See the x25 map and frame-relay map command descriptions
in the Wide-Area Networking Command Reference for more detail.
Configuring nonbroadcast, multiaccess networks as either broadcast or nonbroadcast assumes that there are virtual circuits from every router to every router or fully meshed network. This is not true for some cases, for example, because of cost constraints, or when you have only a partially meshed network. In these cases, you can configure the OSPF network type as a point-to-multipoint network. Routing between two routers not directly connected will go through the router that has virtual circuits to both routers. Note that you must not configure neighbors when using this feature.
An OSPF point-to-multipoint interface is defined as a numbered point-to-point interface having one or more neighbors. It creates multiple host routes. An OSPF point-to-multipoint network has the following benefits compared to nonbroadcast multiaccess and point-to-point networks:
Task | Command |
---|---|
Configure the OSPF network type for a specified interface. | ip ospf network {broadcast | non-broadcast | point-to-multipoint} |
See the "OSPF
Point-to-Multipoint Example" section at the end of this chapter for
an example of an OSPF point-to-multipoint network.
These parameters need only be configured in those devices that are themselves eligible to become the designated router or backup designated router (in other words, routers or access servers with a nonzero router priority value).
To configure routers that interconnect to nonbroadcast networks,
perform the following task in router configuration mode:
Task | Command |
---|---|
Configure routers or access servers interconnecting to nonbroadcast networks. | neighbor ip-address [priority number] [poll-interval seconds] |
You can specify the following neighbor parameters, as required:
Stub areas are areas into which information on external routes is not sent. Instead, there is a default external route generated by the area border router, into the stub area for destinations outside the autonomous system. To further reduce the number of link state advertisements sent into a stub area, you can configure no-summary on the ABR to prevent it from sending summary link advertisement (link state advertisements Type 3) into the stub area.
In router configuration mode, specify any of the following area parameters
as needed for your network:
NSSA allows importing of Type 7 AS external routes within NSSA area by redistribution. These Type 7 LSAs are translated into Type 5 LSAs by NSSA ABR which are flooded throughout the whole routing domain. Summarization and filtering are supported during the translation.
Use NSSA to simplify administration if you are an Internet service provider (ISP), or a network administrator that must connect a central site using OSPF to a remote site that is using a different routing protocol.
Prior to NSSA, the connection between the corporate site border router and the remote router could not be run as OSPF stub area because routes for the remote site cannot be redistributed into stub area. A simple protocol like RIP is usually run and handle the redistribution. This meant maintaining two routing protocols. With NSSA, you can extend OSPF to cover the remote connection by defining the area between the corporate router and the remote router as an NSSA.
In router configuration mode, specify the following area parameters
as needed to configure OSPF NSSA:
Task | Command |
---|---|
Define an area to be NSSA. | area area-id nssa [no-redistribution] [default-information-originate] |
In router configuration mode on the ABR, specify the following command
to control summarization and filtering of Type 7 LSA into Type 5 LSA:
Task | Command |
---|---|
(Optional) Control the summarization and filtering during the translation. | summary address prefix mask [not advertise] [tag tag] |
To specify an address range, perform the following task in router
configuration mode:
Task | Command |
---|---|
Specify an address range for which a single route will be advertised. | area area-id range address mask |
To have the software advertise one summary route for all redistributed
routes covered by a network address and mask, perform the following task
in router configuration mode:
Task | Command |
---|---|
Specify an address and mask that covers redistributed routes, so only one summary route is advertised. | summary-address address mask |
To establish a virtual link, perform the following task in router
configuration mode:
To display information about virtual links, use the show ip ospf
virtual-links EXEC command. To display the router ID of an OSPF router,
use the show ip ospf EXEC command.
To force the autonomous system boundary router to generate a default
route, perform the following task in router configuration mode:
See the discussion of redistribution of routes in the "Configuring
IP Routing Protocol-Independent Features" chapter.
To configure DNS name lookup, perform the following task in global
configuration mode:
Task | Command |
---|---|
Configure DNS name lookup. | ip ospf name-lookup |
If a loopback interface is configured with an IP address, the Cisco IOS software will use this IP address as its router ID, even if other interfaces have larger IP addresses. Since loopback interfaces never go down, greater stability in the routing table is achieved.
OSPF automatically prefers a loopback interface over any other kind, and it chooses the highest IP address among all loopback interfaces. If no loopback interfaces are present, the highest IP address in the router is chosen. You cannot tell OSPF to use any particular interface.
To configure an IP address on a loopback interface, perform the
following tasks, starting in global configuration mode:
Task | Command |
---|---|
Step 1 Create a loopback interface, which places you in interface configuration mode. | interface loopback 0 |
Step 2 Assign an IP address to this interface. | ip address address mask |
The OSPF metric is calculated as ref-bw divided by bandwidth,
with ref-bw equal to 108 by default, and bandwidth determined by the bandwidth
command. The calculation gives FDDI a metric of 1. If you have multiple
links with high bandwidth, you might want to specify a larger number to
differentiate the cost on those links. To do so, perform the following
task in router configuration mode:
Task | Command |
---|---|
Differentiate high bandwidth links. | ospf auto-cost reference-bandwidth ref-bw |
To configure OSPF on simplex Ethernet interfaces, perform the
following task in router configuration mode:
Task | Command |
---|---|
Suppress the sending of hello packets through the specified interface. | passive-interface type number |
Task | Command |
---|---|
Configure route calculation timers. | timers spf spf-delay spf-holdtime |
Prior to this feature, OSPF periodic hello and link state advertisements (LSAs) updates would be exchanged between routers that connected the on demand link, even when no changes occurred in the hello or LSA information.
With this feature, periodic hellos are suppressed and the periodic refreshes of LSAs are not flooded over the demand circuit. These packets bring up the link only when they are exchanged for the first time, or when a change occurs in the information they contain. This operation allows the underlying datalink layer to be closed when the network topology is stable.
This feature is useful when you want to connect telecommuters or branch offices to an OSPF backbone at a central site. In this case, OSPF for on demand circuits allows the benefits of OSPF over the entire domain, without excess connection costs. Periodic refreshes of hello updates, LSA updates, and other protocol overhead are prevented from enabling the on demand circuit when there is no "real" data to transmit.
Overhead protocols such as hellos and LSAs are transferred over the on demand circuit only upon initial setup and when they reflect a change in the topology. This means that critical changes to the topology that require new SPF calculations are transmitted in order to maintain network topology integrity. Periodic refreshes that do not include changes, however, are not transmitted across the link.
To configure OSPF for on demand circuits, perform the following
tasks, beginning in global configuration mode:
Task | Command |
---|---|
Step 1 Enable OSPF operation. | router ospf process-id |
Step 2 Configure OSPF on an on demand circuit. | ip ospf demand-circuit |
If the router is part of a point-to-point topology, then only one end of the demand circuit must be configured with this command. However, all routers must have this feature loaded.
If the router is part of a point-to-multipoint topology, only
the multipoint end must be configured with this command.
Task | Command |
---|---|
Send syslog message when a neighbor state changes. | ospf log-adj-changes |
Configure this command if you want to know about OSPF neighbor
changes without turning on the debugging command debug ip ospf adjacency.
The ospf log-adj-changes command provides a higher level view of changes
to the state of the peer relationship with less output.
To display various routing statistics, perform the following tasks
in EXEC mode:
hostname mollie ! interface serial 1 ip address 10.0.0.2 255.0.0.0 ip ospf network point-to-multipoint encapsulation frame-relay frame-relay map ip 10.0.0.1 201 broadcast frame-relay map ip 10.0.0.3 202 broadcast frame-relay map ip 10.0.0.4 203 broadcast ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0
hostname neon ! interface serial 0 ip address 10.0.0.1 255.0.0.0 ip ospf network point-to-multipoint encapsulation frame-relay frame-relay map ip 10.0.0.2 101 broadcast frame-relay map ip 10.0.0.4 102 broadcast ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0
hostname platty ! interface serial 3 ip address 10.0.0.4 255.0.0.0 ip ospf network point-to-multipoint encapsulation frame-relay clock rate 1000000 frame-relay map ip 10.0.0.1 401 broadcast frame-relay map ip 10.0.0.2 402 broadcast ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0
hostname jelly ! interface serial 2 ip address 10.0.0.3 255.0.0.0 ip ospf network point-to-multipoint encapsulation frame-relay clock rate 2000000 frame-relay map ip 10.0.0.2 301 broadcast ! router ospf 1 network 10.0.0.0 0.0.0.255 area 0
In the following example, a 30-bit subnet mask is used, leaving two bits of address space reserved for serial line host addresses. There is sufficient host address space for two host endpoints on a point-to-point serial link.
interface ethernet 0 ip address 131.107.1.1 255.255.255.0 ! 8 bits of host address space reserved for ethernets interface serial 0 ip address 131.107.254.1 255.255.255.252 ! 2 bits of address space reserved for serial lines ! Router is configured for OSPF and assigned AS 107 router ospf 107 ! Specifies network directly connected to the router network 131.107.0.0 0.0.255.255 area 0.0.0.0
Three examples follow:
interface ethernet 0 ip address 130.93.1.1 255.255.255.0 ip ospf cost 1 ! interface ethernet 1 ip address 130.94.1.1 255.255.255.0 ! router ospf 9000 network 130.93.0.0 0.0.255.255 area 0.0.0.0 redistribute rip metric 1 subnets ! router rip network 130.94.0.0 redistribute ospf 9000 default-metric 1
router ospf 109 network 131.108.20.0 0.0.0.255 area 10.9.50.0 network 131.108.0.0 0.0.255.255 area 2 network 131.109.10.0 0.0.0.255 area 3 network 0.0.0.0 255.255.255.255 area 0 ! ! Interface Ethernet0 is in area 10.9.50.0: interface ethernet 0 ip address 131.108.20.5 255.255.255.0 ! ! Interface Ethernet1 is in area 2: interface ethernet 1 ip address 131.108.1.5 255.255.255.0 ! ! Interface Ethernet2 is in area 2: interface ethernet 2 ip address 131.108.2.5 255.255.255.0 ! ! Interface Ethernet3 is in area 3: interface ethernet 3 ip address 131.109.10.5 255.255.255.0 ! ! Interface Ethernet4 is in area 0: interface ethernet 4 ip address 131.109.1.1 255.255.255.0 ! ! Interface Ethernet5 is in area 0: interface ethernet 5 ip address 10.1.0.1 255.255.0.0Each network area router configuration command is evaluated sequentially, so the order of these commands in the configuration is important. The Cisco IOS software sequentially evaluates the address/wildcard-mask pair for each interface. See the "OSPF Commands" chapter of the Network Protocols Command Reference, Part 1 for more information.
Consider the first network area command. Area ID 10.9.50.0 is configured for the interface on which subnet 131.108.20.0 is located. Assume that a match is determined for interface Ethernet 0. Interface Ethernet 0 is attached to Area 10.9.50.0 only.
The second network area command is evaluated next. For Area 2, the same process is then applied to all interfaces (except interface Ethernet 0). Assume that a match is determined for interface Ethernet 1. OSPF is then enabled for that interface and Ethernet 1 is attached to Area 2.
This process of attaching interfaces to OSPF areas continues for
all network area commands. Note that the last network area command in this
example is a special case. With this command, all available interfaces
(not explicitly attached to another area) are attached to Area 0.
In this configuration, five routers are configured in OSPF autonomous system 109:
Autonomous system 109 is connected to the outside world via the
BGP link to the external peer at IP address 11.0.0.6.
interface ethernet 1 ip address 131.108.1.1 255.255.255.0 router ospf 109 network 131.108.0.0 0.0.255.255 area 1
interface ethernet 2 ip address 131.108.1.2 255.255.255.0 router ospf 109 network 131.108.0.0 0.0.255.255 area 1
interface ethernet 3 ip address 131.108.1.3 255.255.255.0 interface serial 0 ip address 131.108.2.3 255.255.255.0 router ospf 109 network 131.108.1.0 0.0.0.255 area 1 network 131.108.2.0 0.0.0.255 area 0
interface ethernet 4 ip address 10.0.0.4 255.0.0.0 interface serial 1 ip address 131.108.2.4 255.255.255.0 router ospf 109 network 131.108.2.0 0.0.0.255 area 0 network 10.0.0.0 0.255.255.255 area 0
interface ethernet 5 ip address 10.0.0.5 255.0.0.0 interface serial 2 ip address 11.0.0.5 255.0.0.0 router ospf 109 network 10.0.0.0 0.255.255.255 area 0 redistribute bgp 109 metric 1 metric-type 1 router bgp 109 network 131.108.0.0 network 10.0.0.0 neighbor 11.0.0.6 remote-as 110
The basic configuration tasks in this example are as follows:
interface ethernet 0 ip address 192.42.110.201 255.255.255.0 ip ospf authentication-key abcdefgh ip ospf cost 10 ! interface ethernet 1 ip address 131.119.251.201 255.255.255.0 ip ospf authentication-key ijklmnop ip ospf cost 20 ip ospf retransmit-interval 10 ip ospf transmit-delay 2 ip ospf priority 4 ! interface ethernet 2 ip address 131.119.254.201 255.255.255.0 ip ospf authentication-key abcdefgh ip ospf cost 10 ! interface ethernet 3 ip address 36.56.0.201 255.255.0.0 ip ospf authentication-key ijklmnop ip ospf cost 20 ip ospf dead-interval 80OSPF is on network 131.119.0.0:
router ospf 201 network 36.0.0.0 0.255.255.255 area 36.0.0.0 network 192.42.110.0 0.0.0.255 area 192.42.110.0 network 131.119.0.0 0.0.255.255 area 0 area 0 authentication area 36.0.0.0 stub area 36.0.0.0 authentication area 36.0.0.0 default-cost 20 area 192.42.110.0 authentication area 36.0.0.0 range 36.0.0.0 255.0.0.0 area 192.42.110.0 range 192.42.110.0 255.255.255.0 area 0 range 131.119.251.0 255.255.255.0 area 0 range 131.119.254.0 255.255.255.0 redistribute igrp 200 metric-type 2 metric 1 tag 200 subnets redistribute rip metric-type 2 metric 1 tag 200IGRP autonomous system 200 is on 131.119.0.0:
router igrp 200 network 131.119.0.0 ! ! RIP for 192.42.110 ! router rip network 192.42.110.0 redistribute igrp 200 metric 1 redistribute ospf 201 metric 1
The following example redistributes all OSPF routes into IGRP:
router igrp 109 redistribute ospf 110The following example redistributes RIP routes with a hop count equal to 1 into OSPF. These routes will be redistributed into OSPF as external link state advertisements with a metric of 5, metric type of Type 1, and a tag equal to 1.
router ospf 109 redistribute rip route-map rip-to-ospf ! route-map rip-to-ospf permit match metric 1 set metric 5 set metric-type type1 set tag 1The following example redistributes OSPF learned routes with tag 7 as a RIP metric of 15:
router rip redistribute ospf 109 route-map 5 ! route-map 5 permit match tag 7 set metric 15The following example redistributes OSPF intra-area and interarea routes with next-hop routers on serial interface 0 into BGP with an INTER_AS metric of 5:
router bgp 109 redistribute ospf 109 route-map 10 ! route-map 10 permit match route-type internal match interface serial 0 set metric 5The following example redistributes two types of routes into the integrated IS-IS routing table (supporting both IP and CLNS). The first are OSPF external IP routes with tag 5; these are inserted into Level 2 IS-IS LSPs with a metric of 5. The second are ISO-IGRP derived CLNS prefix routes that match CLNS access list 2000. These will be redistributed into IS-IS as Level 2 LSPs with a metric of 30.
router isis redistribute ospf 109 route-map 2 redistribute iso-igrp nsfnet route-map 3 ! route-map 2 permit match route-type external match tag 5 set metric 5 set level level-2 ! route-map 3 permit match address 2000 set metric 30With the following configuration, OSPF external routes with tags 1, 2, 3, and 5 are redistributed into RIP with metrics of 1, 1, 5, and 5, respectively. The OSPF routes with a tag of 4 are not redistributed.
router rip redistribute ospf 109 route-map 1 ! route-map 1 permit match tag 1 2 set metric 1 ! route-map 1 permit match tag 3 set metric 5 ! route-map 1 deny match tag 4 ! route map 1 permit match tag 5 set metric 5The following configuration sets the condition that if there is an OSPF route to network 140.222.0.0, generate the default network 0.0.0.0 into RIP with a metric of 1:
router rip redistribute ospf 109 route-map default ! route-map default permit match ip address 1 set metric 1 ! access-list 1 permit 140.222.0.0 0.0.255.255 access-list 2 permit 0.0.0.0 0.0.0.0In the following configuration, a RIP learned route for network 160.89.0.0 and an ISO-IGRP learned route with prefix 49.0001.0002 will be redistributed into an IS-IS Level 2 LSP with a metric of 5:
router isis redistribute rip route-map 1 redistribute iso-igrp remote route-map 1 ! route-map 1 permit match ip address 1 match clns address 2 set metric 5 set level level-2 ! access-list 1 permit 160.89.0.0 0.0.255.255 clns filter-set 2 permit 49.0001.0002...The following configuration example illustrates how a route map is referenced by the default-information router configuration command. This is called conditional default origination. OSPF will originate the default route (network 0.0.0.0) with a Type 2 metric of 5 if 140.222.0.0, with network 0.0.0.0 in the routing table.
route-map ospf-default permit match ip address 1 set metric 5 set metric-type type-2 ! access-list 1 140.222.0.0 0.0.255.255 ! router ospf 109 default-information originate route-map ospf-default