Configure and verify single area OSPFv2
In Day 14, “OSPF Operation,” we reviewed the basic implementation of multiarea OSPF. Today we review the basic implementation of OSPFv2 for single-area network designs. We review the commands to configure and verify the implementation.
To review the single-area OSPFv2 configuration commands, we use the topology in Figure 13-1 and the addressing scheme in Table 13-1.
Table 13-1 Addressing Scheme for OSPFv2
Device |
Interface |
IP Address |
Subnet Mask |
R1 |
G0/0 |
172.16.1.1 |
255.255.255.0 |
|
S0/0/0 |
172.16.3.1 |
255.255.255.252 |
|
S0/0/1 |
192.168.10.5 |
255.255.255.252 |
R2 |
G0/0 |
172.16.2.1 |
255.255.255.0 |
|
S0/0/0 |
172.16.3.2 |
255.255.255.252 |
|
S0/0/1 |
192.168.10.9 |
255.255.255.252 |
R3 |
G0/0 |
192.168.1.1 |
255.255.255.0 |
|
S0/0/0 |
192.168.10.6 |
255.255.255.252 |
|
S0/0/1 |
192.168.10.10 |
255.255.255.252 |
OSPF is enabled with the router ospf process-id global configuration command:
R1(config)# router ospf process-id
process-id is a number between 1 and 65535 and is chosen by the network administrator. The process ID is locally significant. It does not have to match other OSPF routers to establish adjacencies with those neighbors. This differs from Enhanced Interior Gateway Routing Protocol (EIGRP). The EIGRP process ID and autonomous system number must match before two EIGRP neighbors can become adjacent.
For our review, we enable OSPF on all three routers using the same process ID, 10.
The router ID plays an important role in OSPF, uniquely identifying each router in the OSPF routing domain. Cisco routers derive the router ID as follows:
Step 1. The router uses the IP address configured with the OSPF router-id command.
Step 2. If the router ID is not configured, the router chooses the highest IP address of any of its loopback interfaces.
Step 3. If no loopback interfaces are configured, the router chooses the highest active IP address of any of its physical interfaces.
The router ID can be viewed with several commands, including show ip ospf interfaces, show ip protocols, and show ip ospf.
Because the network administrator can control the OSPF router-id command and because loop-back interfaces clutter the routing table, it is a best practice to configure the router-id command. The router-id command accepts an IPv4 address as its only argument. Example 13-1 shows the router ID configurations for the routers in our topology.
R1(config-router)# router-id 1.1.1.1 R2(config-router)# router-id 2.2.2.2 R3(config-router)# router-id 3.3.3.3
The router ID is selected when OSPF is configured with its first OSPF network command, so the router-id command should already be configured. However, you can force OSPF to release its current ID and use the configured router ID by clearing the OSPF routing process:
Router# clear ip ospf process
The network command is used in router configuration mode:
Router(config-router)# network network-address wildcard-mask area area-id
The OSPF network command uses a combination of network-address and wildcard-mask. The network address, along with the wildcard mask, specifies the interface or range of interfaces that will be enabled for OSPF using this network command.
The wildcard mask is customarily configured as the inverse of a subnet mask. For example, R1’s Serial 0/0/0 interface is on the 172.16.3.0/30 network. The subnet mask for this interface is /30, or 255.255.255.252. The inverse of the subnet mask results in the wildcard mask 0.0.0.3.
area area-id refers to the OSPF area. An OSPF area is a group of routers that share link-state information. All OSPF routers in the same area must have the same link-state information in their link-state databases. Therefore, all the routers within the same OSPF area must be configured with the same area ID on all routers. By convention, the area ID is 0.
As an alternative, OSPFv2 can be enabled using the network intf-ip-address 0.0.0.0 area area-id router configuration mode command.
Example 13-2 shows the network commands for all three routers, enabling OSPF on all interfaces. For R1, the alternative interface IP address and quad zero wildcard mask is configured.
R1(config)# router ospf 10 R1(config-router)# network 172.16.1.1 0.0.0.0 area 0 R1(config-router)# network 172.16.3.1 0.0.0.0 area 0 R1(config-router)# network 192.168.10.5 0.0.0.0 area 0
R2(config)# router ospf 10 R2(config-router)# network 172.16.2.0 0.0.0.255 area 0 R2(config-router)# network 172.16.3.0 0.0.0.3 area 0 R2(config-router)# network 192.168.10.8 0.0.0.3 area 0
R3(config)# router ospf 10 R3(config-router)# network 192.168.1.0 0.0.0.255 area 0 R3(config-router)# network 192.168.10.4 0.0.0.3 area 0 R3(config-router)# network 192.168.10.8 0.0.0.3 area 0
By default, OSPF messages are forwarded out all OSPF-enabled interfaces. However, these messages really need to be sent out only interfaces that connect to other OSPF-enabled routers. Sending out unneeded messages on a LAN affects the network in three ways:
Inefficient use of bandwidth: Available bandwidth is consumed by transporting unnecessary messages.
Inefficient use of resources: All devices on the LAN must process the message.
Increased security risk: OSPF messages can be intercepted, and routing updates can be modified, corrupting the routing table.
Use the passive-interface command to prevent OSPF updates from being sent out unnecessary interfaces. For our topology in Figure 13-1, each router’s GigabitEthernet 0/0 interface should be set to passive with the following command:
Router(config)# passive-interface gigabitethernet 0/0
As an alternative, you can make all interfaces passive by using the passive-interface default command. Then you can reenable interfaces that should not be passive by using the no passive-interface interface command.
Cisco IOS Software uses the cumulative bandwidths of the outgoing interfaces from the router to the destination network as the cost value. At each router, the cost for an interface is calculated using the following formula:
Cisco IOS Cost for OSPF = 108/bandwidth in bps
In this calculation, the value 108 is known as the reference bandwidth. Table 13-2 shows the default OSPF costs using the default reference bandwidth for several types of interfaces.
Table 13-2 Cisco Default OSPF Cost Values
Interface Type |
108/bps = Cost |
Cost |
10 Gigabit Ethernet (10 Gbps) |
108/10,000,000,000 bps = 1 |
1 |
Gigabit Ethernet (1 Gbps) |
108/1,000,000,000 bps = 1 |
1 |
Fast Ethernet (100 Mbps) |
108/100,000,000 bps = 1 |
1 |
Ethernet (10 Mbps) |
108/10,000,000 bps = 10 |
10 |
T1 (1.544 Mbps) |
108/1,544,000 bps = 64 |
64 |
128 kbps |
108/128,000 bps = 781 |
781 |
64 kbps |
108/64,000 bps = 1562 |
1562 |
In Table 13-2, 10GigE, Gigabit Ethernet, and Fast Ethernet all have the same cost. That is because the OSPF cost value must be an integer. This was not an issue before the introduction of gigabit and higher data rates.
However, today’s networks are certainly running at gigabit speeds. Therefore, as a matter of policy, you should change the reference bandwidth to accommodate networks with links faster than 100,000,000 bps (100 Mbps). Use the following command to change the reference bandwidth:
Router(config-router)# auto-cost reference-bandwidth Mbps
Because the value entered is in megabits per second, changing the reference bandwidth to 10000 ensures that all OSPF routers are ready to accurately calculate the cost for 10GigE networks. When used, this command should be entered on all routers so that the OSPF routing metric remains consistent. In fact, the Cisco IOS replies with the follow syslog message when you configure the auto-cost reference-bandwidth command:
% OSPF: Reference bandwidth is changed. Please ensure reference bandwidth is consistent across all routers.
For our topology in Figure 13-1, we enter the commands shown in Example 13-3.
R1(config-router)# auto-cost reference-bandwidth 10000
R2(config-router)# auto-cost reference-bandwidth 10000
R3(config-router)# auto-cost reference-bandwidth 10000
Table 13-3 shows the modified cost values with the new reference bandwidth of 10,000,000,000 bps, or 1010.
Table 13-3 OSPF Cost Values with Modified Reference Bandwidth = 10000
Interface Type |
1010/bps = Cost |
Cost |
10 Gigabit Ethernet (10 Gbps) |
1010/10,000,000,000 bps = 1 |
1 |
Gigabit Ethernet (1 Gbps) |
1010/1,000,000,000 bps = 1 |
10 |
Fast Ethernet (100 Mbps) |
1010/100,000,000 bps = 1 |
100 |
Ethernet (10 Mbps) |
1010/10,000,000 bps = 10 |
1000 |
T1 (1.544 Mbps) |
1010/1,544,000 bps = 64 |
6477 |
128 kbps |
1010/128,000 bps = 781 |
78125 |
64 kbps |
1010/64,000 bps = 1562 |
156250 (see the Note) |
But we are not done: We still have one more adjustment to make to ensure that OSPF is using accurate costs. On Cisco routers, the default bandwidth on most serial interfaces is set to T1 speed, or 1.544 Mbps. But in our topology in Figure 13-1, we have the following actual speeds:
The link between R1 and R2 is running at 1544 kbps (default value).
The link between R2 and R3 is running at 1024 kbps.
The link between R1 and R3 is running at 64 kbps.
You can modify the OSPF metric in two ways:
Use the bandwidth command to modify the bandwidth value the Cisco IOS Software uses in calculating the OSPF cost metric.
Use the ip ospf cost command, which enables you to directly specify the cost of an interface.
An advantage of configuring a cost over setting the interface bandwidth is that the router does not have to calculate the metric when the cost is manually configured. Also, the ip ospf cost command is useful in multivendor environments, where non-Cisco routers can use a metric other than bandwidth to calculate the OSPF costs.
Table 13-4 shows the two alternatives that can be used in modifying the costs of the serial links in the topology in Figure 13-1. The right side of the figure shows the ip ospf cost command equivalents of the bandwidth commands on the left.
Table 13-4 Comparing the bandwidth and ip ospf cost Commands
Adjusting the Interface Bandwidth |
= |
Manually Setting the OSPF Cost |
|
= |
|
|
= |
|
|
= |
|
|
= |
|
To verify any routing configuration, you will most likely depend on the show ip interface brief, show ip route, and show ip protocols commands. All the expected interfaces should be up and up, and they should be configured with the correct IP addresses. The routing table should have all the expected routes. The protocol status should show routing for all expected networks, and it should also show all expected routing sources. Example 13-4 shows R1’s output from these three basic commands.
R1# show ip route <output omitted> Gateway of last resort is not set 172.16.0.0/16 is variably subnetted, 5 subnets, 3 masks C 172.16.1.0/24 is directly connected, GigabitEthernet0/0 L 172.16.1.1/32 is directly connected, GigabitEthernet0/0 O 172.16.2.0/24 [110/6576] via 172.16.3.2, 00:04:57, Serial0/0/0 C 172.16.3.0/30 is directly connected, Serial0/0/0 L 172.16.3.1/32 is directly connected, Serial0/0/0 O 192.168.1.0/24 [110/16341] via 172.16.3.2, 00:00:41, Serial0/0/0 192.168.10.0/24 is variably subnetted, 3 subnets, 2 masks C 192.168.10.4/30 is directly connected, Serial0/0/1 L 192.168.10.5/32 is directly connected, Serial0/0/1 O 192.168.10.8/30 [110/16241] via 172.16.3.2, 00:00:41, Serial0/0/0 R1# show ip interface brief Interface IP-Address OK? Method Status Protocol Embedded-Service-Engine0/0 unassigned YES unset administratively down down GigabitEthernet0/0 172.16.1.1 YES manual up up GigabitEthernet0/1 unassigned YES unset administratively down down Serial0/0/0 172.16.3.1 YES manual up up Serial0/0/1 192.168.10.5 YES manual up up R1# show ip protocols *** IP Routing is NSF aware *** Routing Protocol is “ospf 10” Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 1.1.1.1 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Maximum path: 4 Routing for Networks: 172.16.1.0 0.0.0.255 area 0 172.16.3.0 0.0.0.3 area 0 192.168.10.4 0.0.0.3 area 0 Passive Interface(s): GigabitEthernet0/0 Routing Information Sources: Gateway Distance Last Update 3.3.3.3 110 00:09:00 2.2.2.2 110 00:09:00 Distance: (default is 110)
You can verify that expected neighbors have established adjacency with the show ip ospf neighbor command. Example 13-5 shows the neighbor tables for all three routers.
R1# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 3.3.3.3 0 FULL/ - 00:00:37 192.168.10.6 Serial0/0/1 2.2.2.2 0 FULL/ - 00:00:37 172.16.3.2 Serial0/0/0
R2# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 3.3.3.3 0 FULL/ - 00:00:38 192.168.10.10 Serial0/0/1 1.1.1.1 0 FULL/ - 00:00:37 172.16.3.1 Serial0/0/0
R3# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 2.2.2.2 0 FULL/ - 00:00:37 192.168.10.9 Serial0/0/1 1.1.1.1 0 FULL/ - 00:00:30 192.168.10.5 Serial0/0/0
For each neighbor, the show ip ospf neighbor command displays the following output:
Neighbor ID: The router ID of the neighboring router.
Pri: The OSPF priority of the interface. Example 13-5 shows 0 for this column because point-to-point links do not elect a DR or BDR.
State: The OSPF state of the interface. FULL state means that the router’s interface is fully adjacent with its neighbor, and they have identical OSPF link-state databases.
Dead Time: The amount of time remaining that the router will wait to receive an OSPF hello packet from the neighbor before declaring the neighbor down. This value is reset when the interface receives a hello packet.
Address: The IP address of the neighbor’s interface to which this router is directly connected.
Interface: The interface on which this router has formed adjacency with the neighbor.
The show ip ospf command in Example 13-6 for R1 can also be used to examine the OSPF process ID and router ID. In addition, this command displays the OSPF area information and the last time that the SPF algorithm was calculated.
R1# show ip ospf Routing Process “ospf 10” with ID 1.1.1.1 Start time: 00:29:52.316, Time elapsed: 00:45:15.760 Supports only single TOS(TOS0) routes Supports opaque LSA Supports Link-local Signaling (LLS) Supports area transit capability Supports NSSA (compatible with RFC 3101) Event-log enabled, Maximum number of events: 1000, Mode: cyclic Router is not originating router-LSAs with maximum metric Initial SPF schedule delay 5000 msecs Minimum hold time between two consecutive SPFs 10000 msecs Maximum wait time between two consecutive SPFs 10000 msecs Incremental-SPF disabled Minimum LSA interval 5 secs Minimum LSA arrival 1000 msecs LSA group pacing timer 240 secs Interface flood pacing timer 33 msecs Retransmission pacing timer 66 msecs Number of external LSA 0. Checksum Sum 0x000000 Number of opaque AS LSA 0. Checksum Sum 0x000000 Number of DCbitless external and opaque AS LSA 0 Number of DoNotAge external and opaque AS LSA 0 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Number of areas transit capable is 0 External flood list length 0 IETF NSF helper support enabled Cisco NSF helper support enabled Reference bandwidth unit is 10000 mbps Area BACKBONE(0) Number of interfaces in this area is 3 Area has no authentication SPF algorithm last executed 00:18:32.788 ago SPF algorithm executed 7 times Area ranges are Number of LSA 3. Checksum Sum 0x01BB59 Number of opaque link LSA 0. Checksum Sum 0x000000 Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0
The quickest way to verify OSPF interface settings is to use the show ip ospf interface brief command. As shown in the output for R1 in Example 13-7, this command provides a detailed list for every OSPF-enabled interface. The command is also useful for quickly viewing the cost of each interface and determining whether the network statements were correctly configured.
R1# show ip ospf interface brief Interface PID Area IP Address/Mask Cost State Nbrs F/C Se0/0/1 10 0 192.168.10.5/30 65535 P2P 1/1 Se0/0/0 10 0 172.16.3.1/30 6476 P2P 1/1 Gi0/0 10 0 172.16.1.1/24 100 DR 0/0
For today’s exam topics, refer to the following resources for more study.
Resource |
Module or Chapter |
Enterprise Networking, Security, and Automation |
2 |
CCNA 200-301 Official Cert Guide, Volume 1 |
20 |
Portable Command Guide |
16 |
3.144.254.111