Sunday, March 25, 2012

Comprehensive OSPF Cost Example


Advertisement

Advertisement
The Open Shortest Path First routing protocol is a critical piece of knowledge for any networking professional working in an enterprise environment. Most major networking certifications covering routing and switching including the Cisco Certified Network Associate (CCNA), Cisco Certified Network Professional (CCNP), and Cisco Certified Internetwork Expert (CCIE) extensively test OSPF knowledge and skills. OSPF is the most popular dynamic routing protocol used in complex enterprise networks as an interior gateway protocol (IGP). This post will provide a comprehensive example of the OSPF metric calculation and how different configurations impact the metric for type-1 and type-2 routes. The OSPF lab is configured in Dynamips/GNS3 using 5 Cisco c3725 routers laid out in the topology below. For more information on how the OSPF metric is determined, see OSPF Cost/Metric Calculation.

As I described in a previous post, there are really three main types of metrics considered in OSPF:
  • Intra-area and summary cost
  • External/NSSA type 1 cost
  • External/NSSA type 2 cost
In the topology below, we have a backbone area and two non-backbone areas (one a regular area and one a totally not so stubby [totally NSSA] area).

We have two routing domains running the routing information protocol (RIP) and the routing domain running Open Shortest Path First (OSPF). To get our external routes into OSPF, we redistribute RIP into OSPF on R1 and R2. The RIP routes from R1 are propagated through the OSPF domain (until R02) and the RIP routes from R2 are only propagated through the no-summary NSSA area as N1/N2 routes, then they become E1/E2 routes in area 0 and beyond.

For the initial part of the lab, get the basic OSPF configuration and RIP redistribution set up. In this instance, I use a route map on R1 and R2 to set the following:

172.16.1.0/24 Metric type 1, initial cost 100
172.16.2.0/24 Metric type 2, cost 100
192.168.1.0/24 Metric type 1, initial cost 100
192.168.2.0/24 Metric type 2, cost 100

There are multiple ways to achieve this configuration, but I use a route map and prefix lists. Here are the relevant configuration commands for R1

!
router ospf 1
 redistribute rip subnets route-map set-ospf-metric-type
 network 10.0.0.0 0.255.255.255 area 1
!
ip prefix-list match-172-16-1 seq 5 permit 172.16.1.0/24
!
ip prefix-list match-172-16-2 seq 5 permit 172.16.2.0/24
!
route-map set-ospf-metric-type permit 10
 match ip address prefix-list match-172-16-1
 set metric 100
 set metric-type type-1
!
route-map set-ospf-metric-type permit 20
 match ip address prefix-list match-172-16-2
 set metric 100
 set metric-type type-2
!


And for R2:
!
router ospf 1
 log-adjacency-changes
 area 2 nssa no-summary
 redistribute rip subnets route-map set-ospf-metric
 network 10.0.3.0 0.0.0.255 area 2
!
ip prefix-list match-192-168-1 seq 5 permit 192.168.1.0/24
!
ip prefix-list match-192-168-2 seq 5 permit 192.168.2.0/24
!
route-map set-ospf-metric permit 10
 match ip address prefix-list match-192-168-1
 set metric 100
 set metric-type type-1
!
route-map set-ospf-metric permit 20
 match ip address prefix-list match-192-168-2
 set metric 100
 set metric-type type-2
!


Looking at the Area Border Router (ABR) routing tables, it is clear that the E1/N1 cost increases as it is propagated through the network, but the E2/N2 cost remains what it was initially set to.

From R01:

R01#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 2 subnets
O E1    172.16.1.0 [110/110] via 10.0.2.1, 00:12:14, FastEthernet0/1
O E2    172.16.2.0 [110/100] via 10.0.2.1, 00:12:14, FastEthernet0/1
     10.0.0.0/24 is subnetted, 4 subnets
C       10.0.2.0 is directly connected, FastEthernet0/1
O IA    10.0.3.0 [110/30] via 10.0.0.2, 01:57:47, FastEthernet0/0
C       10.0.0.0 is directly connected, FastEthernet0/0
O       10.0.1.0 [110/20] via 10.0.0.2, 01:57:47, FastEthernet0/0
O E1 192.168.1.0/24 [110/130] via 10.0.0.2, 01:57:47, FastEthernet0/0
O E2 192.168.2.0/24 [110/100] via 10.0.0.2, 01:57:49, FastEthernet0/0


From R02:

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 2 subnets
O E1    172.16.1.0 [110/130] via 10.0.1.1, 00:00:02, FastEthernet0/0
O E2    172.16.2.0 [110/100] via 10.0.1.1, 00:00:02, FastEthernet0/0
     10.0.0.0/24 is subnetted, 4 subnets
O IA    10.0.2.0 [110/30] via 10.0.1.1, 00:00:02, FastEthernet0/0
C       10.0.3.0 is directly connected, FastEthernet0/1
O       10.0.0.0 [110/20] via 10.0.1.1, 00:00:02, FastEthernet0/0
C       10.0.1.0 is directly connected, FastEthernet0/0
O N1 192.168.1.0/24 [110/110] via 10.0.3.2, 03:44:00, FastEthernet0/1
O N2 192.168.2.0/24 [110/100] via 10.0.3.2, 03:44:00, FastEthernet0/1


For internal routes, it is easy to see that the cost increases as the advertisement propagates from the source.

OSPF Cost for Summary Routes

Summary external routes can be created on autonomous system border routers (ASBRs) using the OSPF summary-address router configuration command. External summary route cost is determined according to the following rules:
  • If all summary components are E2/N2 routes, the summary is considered E2/N2 and is advertised with the lowest metric (cost) of the summarized routes
  • If any of the summarized routes are E1/N1 routes, the summary is considered E1/N1 and is initially advertised with the lowest cost/metric of any of the summarized routes. As the LSA is propagated, the new metric follows regular E1/N1 rules.  
For routes within the OSPF routing domain that are summarized at the area border routers (ABRs) using the area range command, the metric advertised with the summary is the lowest metric of any of the summarized routes.

See Also,
The Road to the CCIE
OSPF Cost/Metric Calculation

No comments:

Post a Comment