Modify Single-Area OSPFv2 CCNA
Modify Single-Area OSPFv2 CCNA

Modify Single-Area OSPFv2

Modify Single-Area OSPFv2
5

Summary

This topic implement modifications to change the operation of single-area OSPFv2. Start learning CCNA 200-301 for free right now!!

Note: Welcome: This topic is part of Module 2 of the Cisco CCNA 3 course, for a better follow up of the course you can go to the CCNA 3 section to guide you through an order.

Cisco OSPF Cost Metric

Recall that a routing protocol uses a metric to determine the best path of a packet across a network. A metric gives indication of the overhead that is required to send packets across a certain interface. OSPF uses cost as a metric. A lower cost indicates a better path than a higher cost.

The Cisco cost of an interface is inversely proportional to the bandwidth of the interface. Therefore, a higher bandwidth indicates a lower cost. The formula used to calculate the OSPF cost is:

Cost = reference bandwidth / interface bandwidth

The default reference bandwidth is 108 (100,000,000); therefore, the formula is:

Cost = 100,000,000 bps / interface bandwidth in bps

Refer to the table for a breakdown of the cost calculation. Because the OSPF cost value must be an integer, FastEthernet, Gigabit Ethernet, and 10 Gigabit Ethernet (10 GigE) interfaces share the same cost. To correct this situation, you can:

  • Adjust the reference bandwidth with the auto-cost reference-bandwidth command on each OSPF router.
  • Manually set the OSPF cost value with the ip ospf cost command on necessary interfaces.

Default Cisco OSPF Costs

Default Cisco OSPF Costs
Default Cisco OSPF Costs

Adjust the Reference Bandwidth

The cost value must be an integer. If something less than an integer is calculated, OSPF rounds up to the nearest integer. Therefore, the OSPF cost assigned to a Gigabit Ethernet interface with the default reference bandwidth of 100,000,000 bps would equal 1, because the nearest integer for 0.1 is 0 instead of 1.

Cost = 100,000,000 bps / 1,000,000,000 = 1

For this reason, all interfaces faster than Fast Ethernet will have the same cost value of 1 as a Fast Ethernet interface. To assist OSPF in making the correct path determination, the reference bandwidth must be changed to a higher value to accommodate networks with links faster than 100 Mbps.

Changing the reference bandwidth does not actually affect the bandwidth capacity on the link; rather, it simply affects the calculation used to determine the metric. To adjust the reference bandwidth, use the auto-cost reference-bandwidth Mbps router configuration command.

Router(config-router)# auto-cost reference-bandwidth Mbps

This command must be configured on every router in the OSPF domain. Notice that the value is expressed in Mbps; therefore, to adjust the costs for Gigabit Ethernet, use the command auto-cost reference-bandwidth 1000. For 10 Gigabit Ethernet, use the command auto-cost reference-bandwidth 10000.

To return to the default reference bandwidth, use the auto-cost reference-bandwidth 100 command.

Whichever method is used, it is important to apply the configuration to all routers in the OSPF routing domain. The table shows the OSPF cost if the reference bandwidth is adjusted to accommodate 10 Gigabit Ethernet links. The reference bandwidth should be adjusted anytime there are links faster than FastEthernet (100 Mbps).

Table caption
Interface Type Reference
Bandwidth in bps
Default
Bandwidth in bps
Cost
10 Gigabit Ethernet
10 Gbps
10,000,000,000 ÷ 10,000,000,000 1
Gigabit Ethernet
1 Gbps
10,000,000,000 ÷ 1,000,000,000 10
Fast Ethernet
100 Mbps
10,000,000,000 ÷ 100,000,000 100
Ethernet
10 Mbps
10,000,000,000 ÷ 10,000,000 1000

Use the show ip ospf interface g0/0/0 command to verify the current OSPFv2 cost assigned to the R1 GigabitEthernet 0/0/0 interface. Notice how it displays a cost of 1. Then, after adjusting the reference bandwidth, the cost is now 10. This will allow for scaling to 10 Gigabit Ethernet interfaces in the future without having adjust the reference bandwidth again.

Note: The auto-cost reference-bandwidth command must be configured consistently on all routers in the OSPF domain to ensure accurate route calculations.

R1# show ip ospf interface gigabitethernet0/0/0
GigabitEthernet0/0/0 is up, line protocol is up 
  Internet Address 10.1.1.5/30, Area 0, Attached via Interface Enable
  Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1
(output omitted)
R1# config t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)# router ospf 10
R1(config-router)# auto-cost reference-bandwidth 10000
% OSPF: Reference bandwidth is changed.
        Please ensure reference bandwidth is consistent across all routers.
R1(config-router)# do show ip ospf interface gigabitethernet0/0/0
GigabitEthernet0/0 is up, line protocol is up
  Internet address is 172.16.1.1/24, Area 0
  Process ID 10, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
(output omitted)

OSPF Accumulates Costs

The cost of an OSPF route is the accumulated value from one router to the destination network. Assuming the auto-cost reference-bandwidth 10000 command has been configured on all three routers, the cost of the links between each router is now 10. The loopback interfaces have a default cost of 1, as shown in the figure.

OSPF Accumulates Costs
OSPF Accumulates Costs

Therefore, we can calculate the cost for each router to reach each network. For example, the total cost for R1 to reach the 10.10.2.0/24 network is 11. This is because the link to R2 cost = 10 and the loopback default cost = 1. 10 + 1 = 11.

The routing table of R1 in Figure 2 confirms that the metric to reach the R2 LAN is a cost of 11.

R1# show ip route | include 10.10.2.0
O        10.10.2.0/24 [110/11] via 10.1.1.6, 01:05:02, GigabitEthernet0/0/0
R1# show ip route 10.10.2.0
Routing entry for 10.10.2.0/24
  Known via "ospf 10", distance 110, metric 11, type intra area
  Last update from 10.1.1.6 on GigabitEthernet0/0/0, 01:05:13 ago
  Routing Descriptor Blocks:
  * 10.1.1.6, from 2.2.2.2, 01:05:13 ago, via GigabitEthernet0/0/0
      Route metric is 11, traffic share count is 1
R1#

Manually Set OSPF Cost Value

OSPF cost values can be manipulated to influence the route chosen by OSPF. For example, in the current configuration, R1 is load balancing to the 10.1.1.8/30 network. It will send some traffic to R2 and some traffic to R3. You can see this in the routing table.

R1# show ip route ospf | begin 10
      10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
O        10.1.1.8/30 [110/20] via 10.1.1.13, 00:54:50, GigabitEthernet0/0/1
                     [110/20] via 10.1.1.6, 00:55:14, GigabitEthernet0/0/0
(output omitted)
R1#

Note: Changing the cost of link may have undesired consequences. Therefore, adjusting interface cost values should only be configured when the outcome is fully understood.

The administrator may want traffic to go through R2 and use R3 as a backup route in case the link between R1 and R2 goes down.

Another reason to change the cost value is because other vendors may calculate OSPF in a different manner. By manipulating the cost value, the administrator can make sure the route costs shared between OSPF multivendor routers are accurately reflected in routing tables.

To change the cost value reported by the local OSPF router to other OSPF routers, use the interface configuration command ip ospf cost value. In the figure, we need to change cost of the loopback interfaces to 10 to simulate Gigabit Ethernet speeds. In addition, we will change the cost of the link between R2 and R3 to 30 so that this link is used as a backup link.

Manually Set OSPF Cost Value
Manually Set OSPF Cost Value

The following example is the configuration for R1.

R1(config)# interface g0/0/1
R1(config-if)# ip ospf cost 30
R1(config-if)# interface lo0
R1(config-if)# ip ospf cost 10
R1(config-if)# end
R1#

Assuming OSPF costs for R2 and R3 have been configured to match the topology in the above figure, the OSPF routes for R1 would have the following cost values. Notice that R1 is no longer load balancing to the 10.1.1.8/30 network. In fact, all routes go through R2 via 10.1.1.6, as desired by the network administrator.

R1# show ip route ospf | begin 10
      10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
O        10.1.1.8/30 [110/20] via 10.1.1.6, 01:18:25, GigabitEthernet0/0/0
O        10.10.2.0/24 [110/20] via 10.1.1.6, 00:04:31, GigabitEthernet0/0/0
O        10.10.3.0/24 [110/30] via 10.1.1.6, 00:03:21, GigabitEthernet0/0/0
R1#

Note: Although using the ip ospf cost command is the recommended method to manipulate the OSPF cost values, an administrator could also do this by using the interface configuration bandwidth kbps command. However, that would only work if all the routers are Cisco routers.

Test Failover to Backup Route

What happens if the link between R1 and R2 goes down? We can simulate that by shutting down the Gigabit Ethernet 0/0/0 interface and verifying the routing table is updated to use R3 as the next-hop router. Notice that R1 can now reach the 10.1.1.4/30 network via 10.1.1.13 through R3 with a cost value of 50.

R1(config)# interface g0/0/0
R1(config-if)# shutdown
*Jun  7 03:41:34.866: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on GigabitEthernet0/0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Jun  7 03:41:36.865: %LINK-5-CHANGED: Interface GigabitEthernet0/0/0, changed state to administratively down
*Jun  7 03:41:37.865: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0, changed state to down
R1(config-if)# end
R1# show ip route ospf | begin 10
      10.0.0.0/8 is variably subnetted, 8 subnets, 3 masks
O        10.1.1.4/30 [110/50] via 10.1.1.13, 00:00:14, GigabitEthernet0/0/1
O        10.1.1.8/30 [110/40] via 10.1.1.13, 00:00:14, GigabitEthernet0/0/1
O        10.10.2.0/24 [110/50] via 10.1.1.13, 00:00:14, GigabitEthernet0/0/1
O        10.10.3.0/24 [110/40] via 10.1.1.13, 00:00:14, GigabitEthernet0/0/1
R1#

Syntax Checker – Modify the Cost Values for R2 and R3

Use the Syntax Checker to modify the cost values for R2 and R3.

You are logged into R2.

  • Use the interface name lo0 to set the cost value for the loopback interface to 10.
  • Return to global configuration mode.
  • Verify the routing table entries with show ip route ospf.
R2(config)#interface lo0
R2(config-if)#ip ospf cost 10
R2(config-if)#end
R2#show ip route ospf
(output omitted)
Gateway of last resort is not set
      10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
O        10.1.1.12/30 \[110/20\] via 10.1.1.10, 00:01:13, GigabitEthernet0/0/1
O        10.10.1.0/24 \[110/20\] via 10.1.1.5, 00:00:32, GigabitEthernet0/0/0
O        10.10.3.0/24 \[110/11\] via 10.1.1.10, 00:00:49, GigabitEthernet0/0/1
R2#

The cost value to the R3 LAN is 11 because the loopback is still reporting a default cost of 1.

You are now logged into R3.

  • Use the interface name lo0 and set the cost value for the loopback interface to 10.
  • Use the interface name g0/0/0 and set the cost value of the link to R1 as 30.
  • Return to privileged EXEC mode.
  • Verify the routing table entries with show ip route ospf.
R3(config)#interface lo0
R3(config-if)#ip ospf cost 10
R3(config-if)#interface g0/0/0
R3(config-if)#ip ospf cost 30
R3(config-if)#end
R3#show ip route ospf
(output omitted)
Gateway of last resort is not set
      10.0.0.0/8 is variably subnetted, 9 subnets, 3 masks
O        10.1.1.4/30 \[110/20\] via 10.1.1.9, 01:48:54, GigabitEthernet0/0/1
O        10.10.1.0/24 \[110/30\] via 10.1.1.9, 00:00:06, GigabitEthernet0/0/1
O        10.10.2.0/24 \[110/20\] via 10.1.1.9, 00:35:24, GigabitEthernet0/0/1
R3#

You have successfully modified the OSPF cost values for R2 and R3.

Hello Packet Intervals

As shown in the figure, OSPFv2 Hello packets are transmitted to multicast address 224.0.0.5 (all OSPF routers) every 10 seconds. This is the default timer value on multiaccess and point-to-point networks.

Note: Hello packets are not sent on the simulated the LAN interfaces because those interfaces were set to passive by using the router configuration passive-interface command.

The Dead interval is the period that the router waits to receive a Hello packet before declaring the neighbor down. If the Dead interval expires before the routers receive a Hello packet, OSPF removes that neighbor from its link-state database (LSDB). The router floods the LSDB with information about the down neighbor out all OSPF-enabled interfaces. Cisco uses a default of 4 times the Hello interval. This is 40 seconds on multiaccess and point-to-point networks.

Note: On non-broadcast multiaccess (NBMA) networks, the default Hello interval is 30 seconds and the default dead interval is 120 seconds. NBMA networks are beyond the scope of this module.

Hello Packet Intervals
Hello Packet Intervals

Verify Hello and Dead Intervals

The OSPF Hello and Dead intervals are configurable on a per-interface basis. The OSPF intervals must match or a neighbor adjacency does not occur. To verify the currently configured OSPFv2 interface intervals, use the show ip ospf interface command, as shown in the example. The Gigabit Ethernet 0/0/0 Hello and Dead intervals are set to the default 10 seconds and 40 seconds respectively.

R1# show ip ospf interface g0/0/0
GigabitEthernet0/0/0 is up, line protocol is up 
  Internet Address 10.1.1.5/30, Area 0, Attached via Interface Enable
  Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 10
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           10        no          no            Base
  Enabled by interface config, including secondary ip addresses
  Transmit Delay is 1 sec, State POINT_TO_POINT
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:06
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Index 1/2/2, flood queue length 0
  Next 0x0(0)/0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1 
    Adjacent with neighbor 2.2.2.2
  Suppress hello for 0 neighbor(s)
R1#

Use the show ip ospf neighbor command to see the Dead Time counting down from 40 seconds, as shown in the following example. By default, this value is refreshed every 10 seconds when R1 receives a Hello from the neighbor.

R1# show ip ospf neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/  -        00:00:35    10.1.1.13       GigabitEthernet0/0/1
2.2.2.2           0   FULL/  -       00:00:31    10.1.1.6        GigabitEthernet0/0/0
R1#

Modify OSPFv2 Intervals

It may be desirable to change the OSPF timers so that routers detect network failures in less time. Doing this increases traffic, but sometimes the need for quick convergence is more important than the extra traffic it creates.

Note: The default Hello and Dead intervals are based on best practices and should only be altered in rare situations.

OSPFv2 Hello and Dead intervals can be modified manually using the following interface configuration mode commands:

Router(config-if)# ip ospf hello-interval seconds
Router(config-if)# ip ospf dead-interval seconds

Use the no ip ospf hello-interval and no ip ospf dead-interval commands to reset the intervals to their default.

In the example, the Hello interval for the link between R1 and R2 is changed to 5 seconds. Immediately after changing the Hello interval, the Cisco IOS automatically modifies the Dead interval to four times the Hello interval. However, you can document the new dead interval in the configuration by manually setting it to 20 seconds, as shown.

As displayed by the highlighted OSPFv2 adjacency message, when the Dead Timer on R1 expires, R1 and R2 lose adjacency. The reason is because the R1 and R2 must be configured with the same Hello interval. Use the show ip ospf neighbor command on R1 to verify the neighbor adjacencies. Notice that the only neighbor listed is the 3.3.3.3 (R3) router and that R1 is no longer adjacent with the 2.2.2.2 (R2) neighbor.

R1(config)# interface g0/0/0
R1(config-if)# ip ospf hello-interval 5
R1(config-if)# ip ospf dead-interval 20
R1(config-if)# 
*Jun  7 04:56:07.571: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on GigabitEthernet0/0/0 from FULL to DOWN,
Neighbor Down: Dead timer expired
R1(config-if)# end
R1# show ip ospf neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/  -        00:00:37    10.1.1.13       GigabitEthernet0/0/1
R1#

To restore adjacency between R1 and R2, the R2 Gigabit Ethernet 0/0/0 interface Hello interval is set to 5 seconds, as shown in the following example. Almost immediately, the IOS displays a message that adjacency has been established with a state of FULL. Verify the interface intervals using the show ip ospf interface command. Notice that the Hello time is 5 seconds and that the Dead Time was automatically set to 20 seconds instead of the default 40 seconds.

R2(config)# interface g0/0/0
R2(config-if)# ip ospf hello-interval 5
*Jun  7 15:08:30.211: %OSPF-5-ADJCHG: Process 10, Nbr 1.1.1.1 on GigabitEthernet0/0/0 from LOADING to
FULL, Loading Done
R2(config-if)# end
R2# show ip ospf interface g0/0/0 | include Timer
  Timer intervals configured, Hello 5, Dead 20, Wait 20, Retransmit 5
R2# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/  -        00:00:38    10.1.1.10       GigabitEthernet0/0/1
1.1.1.1           0   FULL/  -        00:00:17    10.1.1.5        GigabitEthernet0/0/0
R2#

Syntax Checker – Modifying Hello and Dead Intervals on R3

The Hello and Dead intervals are set to 5 and 20, respectively, on R1 and R2. Use the Syntax Checker to modify the Hello and Dead intervals on R3 and verify adjacencies are re-established with R1 and R2.

You are logged into R3. Enter the show ip ospf neighbor command to see that no adjacencies currently exist with R1 and R2.

R3#show ip ospf neighbor
R3#

No results are returned for the adjacent neighbors.

You are now in global configuration mode.

  • Use g0/0/0 as the interface name and configure the Hello interval to match R1.
  • Use g0/0/1 as the interface name and configure the Hello interval to match R2.
  • Return to privileged EXEC mode.
  • Verify neighbor adjacencies are re-established with the show ip ospf neighbor command.
R3(config)#interface g0/0/0
R3(config-if)#ip ospf hello-interval 5
\*Jun  7 05:11:34.423: %OSPF-5-ADJCHG: Process 10, Nbr 1.1.1.1 on GigabitEthernet0/0/0 
from LOADING to FULL, Loading Done
R3(config-if)#interface g0/0/1
R3(config-if)#ip ospf hello-interval 5
\*Jun  7 05:11:43.081: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on GigabitEthernet0/0/1 
from LOADING to FULL, Loading Done
R3(config-if)#end
R3#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:19    10.1.1.9        GigabitEthernet0/0/1
1.1.1.1           0   FULL/  -        00:00:19    10.1.1.14       GigabitEthernet0/0/0
R3#

You have successfully modified the OSPF Hello and Dead intervals on R3.

Packet Tracer – Modify Single-Area OSPFv2

In this Packet Tracer activity, you will complete the following:

  • Adjust the reference bandwidth to account for gigabit and faster speeds
  • Modify the OSPF cost value
  • Modify the OSPF Hello timers
  • Verify the modifications are accurately reflected in the routers.

Glossary: If you have doubts about any special term, you can consult this computer network dictionary.

Ready to go! Keep visiting our networking course blog, give Like to our fanpage; and you will find more tools and concepts that will make you a networking professional.