IOS Configuration: OSPF
Basic Configuration
Enabling OSPF:
Router(config)# router ospf <process number>
Setting a Router ID
If no router ID has been administratively declared, a router will choose the highest loopback IP address. If no loopback addresses are present, the highest IP address of the first active interface will be used.
A router ID can be manually specified:
Router(config-router)# router-id <IP address>
Best practice dictates the creation of a loopback address to be used as the router ID for stability and continuity:
Router(config)# interface loopback 0
Router(config-if)# ip address <IP address> <subnet mask>
Default Link Cost
Link cost is a 16-bit value (0-65535); default cost is calculated as 100Mbps/interface bandwidth. (Interfaces 100Mbps and faster are assigned a cost of 1.)
OSPF cost can be manually specified per interface:
Router(config-if)# ip ospf cost <cost>
An alternative to defining static costs per interface is to change the numerator bandwidth (default 100Mbps):
Router(config-router)# ospf auto-cost reference-bandwidth <reference speed>
Reference speed is a 32-bit value (1-4294967). If the reference speed is modified, the same modification should be performed on all routers within the area to avoid inconsistent metric calculations.
Designated Router Election Priority
Default DR election priority is 1, and a router with a priority of 0 will not become a DR. Priority range is 0-255.
Router(config-if)# ip ospf priority <priority>
Area Configuration
Assigning subnets to an OSPF area:
Router(config-router)# network <network> <wildcard mask> area <area ID>
A single interface can be specified by supplying its IP address and a null wildcard mask: network 192.168.0.1 0.0.0.0 area 0
Summarization
area range is used on an ABR to summarize multiple networks into a single type 3 LSA.
Router(config-router)# area <area> range <network> <mask>
summary-address is used on an ASBR to define summarization boundaries for external routes redistributed into OSPF.
Router(config-router)# summary-address <address> <mask> [not-advertise] [tag <tag>]
Defining Stub Areas
Areas are designated as stubs when the chosen exit ABR is unimportant (or there is only one).
Router(config-router)# area <area> stub
All routers within a stub area must be configured as such. A stub router will not form an adjacency with a non-stub router in the same area.
The addition of the no-summary parameter further limits a stub area by creating a totally subby area (a Cisco-proprietary concept). Totally stubby areas do not receive type 3 or 5 LSAs from other areas.
Router(config-router)# area <area> stub no-summary
Only ABRs need to be configured with no-summary appended to the stub command. To direct packets outside the stub area, routers rely on a default route advertised by the ABR(s).
Defining a not-so-stubby area (NSSA):
Router(config)# area <area> nssa [no-summary]
area default-cost is used to define the cost of the default route injected by an ABR into a stub area. The default is (cost to the ABR + 1). This command can be used to prefer one stub exit over others.
Router(config-router)# area <area> default-cost <cost>
Configuration of the default cost is done only on the ABR(s).
Manual Network Type Configuration
Nonbroadcast Network
Because NBMA is the default network type for a nonbroadcast interface, the only necessary configuration is to define neighbors.
DR priorities should be specified to ensure only candidates positioned well in the topology are elected DR and BDR.
Router(config-if)# neighbor <IP address> [priority <priority>] [poll-interval <seconds>]
[cost <cost>]
priority- This can be used to specify a higher priority than what has been configured on the neighbor (but not lower)poll interval- The rate at which hellos are sent to inactive neighbors (default 120 seconds)cost- Cost to reach the neighbor
NBMA configuration:
Router(config-if)# ip address 10.0.0.60 255.255.255.0
Router(config-if)# encapsulation frame-relay
Router(config)# router ospf 1
Router(config-router)# network 10.0.0.0 0.0.0.255 area 0
Router(config-router)# neighbor 10.0.0.40
Router(config-router)# neighbor 10.0.0.50
Point-to-multipoint Network
Point-to-multipoint automatically establishes adjacencies along PVCs.
Point-to-multipoint assumes broadcast capability by default; nonbroadcast can be specified, and neighbors must then be defined manually.
Router(config-if)# ip address 10.1.1.1 255.255.255.0
Router(config-if)# encapsulation frame-relay
Router(config-if)# ip ospf network point-to-multipoint [nonbroadcast]
Router(config)# router ip ospf 1
Router(config-router)# network 10.1.1.1 0.0.0.255 area 0
Broadcast Network
Router(config-if)# ip address 10.1.1.1 255.255.255.0
Router(config-if)# ip ospf network broadcast
Router(config)# router ip ospf 1
Router(config-router)# network 10.1.1.1 0.0.0.255 area 0
Point-to-point on Subinterfaces
Router(config)# interface serial0
Router(config-if)# no ip address
Router(config-if)# encapsulation frame-relay
Router(config)# interface serial0.1 point-to-point
Router(config-if)# ip address 10.1.1.1 255.255.255.0
Router(config-if)# frame-relay interface-dlci 51
Router(config)# interface serial0.2 point-to-point
Router(config-if)# ip address 10.1.2.1 255.255.255.0
Router(config-if)# frame-relay interface-dlci 52
Router(config)# router ip ospf 1
Router(config-router)# network 10.1.1.1 0.0.0.255 area 0
Virtual Links
Virtual links are created when an outlying area does not have a direct connection to the backbone (area 0).
Router(config-router)# area <area> virtual-link <router ID>
The router ID specifies the remote endpoint of the virtual link.
Verifying OSPF Configuration
show ip ospf- OSPF process detailsshow ip ospf border-routersshow ip ospf database- Contents of the topology databaseshow ip ospf interface- Interfaces participating in OSPFshow ip ospf neighbor- Neighbor informationshow ip ospf virtual-linksshow ip protocols- Displays all active routing protocolsshow ip route
Debugging commands:
debug ip ospf eventsdebug ip packet
