Redistributing Classful and Classless Networks into OSPF
By default, when redistribution into OSPF is configured, OSPF will only redistribute Classful networks. This default behavior can be changed by including the subnets keyword when redistributing routes into OSPF. As an example, assume that a router is receiving the following routes via EIGRP in autonomous system 1:
| R2#show ip route eigrp 10.0.0.0/24 is subnetted, 5 subnets D 10.0.1.0 [90/30720] via 10.0.0.1, 00:00:08, FastEthernet0/0 D 192.168.254.0/24 [90/156160] via 10.0.0.1, 00:00:08, FastEthernet0/0 192.168.253.0/29 is subnetted, 1 subnets D 192.168.253.0 [90/156160] via 10.0.0.1, 00:00:08, FastEthernet0/0 |
It is required that these routes be redistributed into OSPF. To demonstrate the default behavior of OSPF when the subnets keyword is omitted, the redistribution is configured as follows:
| R2(config)#router ospf 2 R2(config-router)#redistribute eigrp 1 % Only classful networks will be redistributed R2(config-router)#exit |
In the output above, following the redistribution of EIGRP into OSPF, Cisco IOS software prints a warning message that only Classful networks will be redistributed because the subnets keyword is omitted, which means that only the 192.168.254.0/24 network will be imported (redistributed) into OSPF. The 10.0.1.0/24 and 192.168.253.0/29 subnets will not be redistributed. This can be validated by looking at the Link State Database of R2:
| R2#show ip ospf database | begin Type-5 Type-5 AS External Link StatesLink ID ADV Router Age Seq# Checksum Tag 192.168.254.0 2.2.2.2 178 0x80000001 0x00052B 0 |
To include the subnetted networks, the subnet keyword must be used during redistribution as is illustrated in the configuration below:
| R2(config)#router ospf 2 R2(config-router)#redistribute eigrp 1 subnets R2(config-router)#exit |
Following this configuration modification, the Link State Database on R2 shows the following:
| R2#show ip ospf database | begin Type-5 Type-5 AS External Link StatesLink ID ADV Router Age Seq# Checksum Tag 10.0.0.0 2.2.2.2 42 0x80000001 0x002965 0 10.0.1.0 2.2.2.2 42 0x80000001 0x001E6F 0 192.168.253.0 2.2.2.2 42 0x80000001 0x00E552 0 192.168.254.0 2.2.2.2 293 0x80000001 0x00052B 0 |
NOTE: The additional 10.0.0.0 Link ID is for the connection between R2 and the EIGRP router.
The subnets keyword is applicable when redistributing any protocol into OSPF, and must also be used when redistributing another OSPF process into OSPF. If omitted, only Classful networks will be imported (redistributed) into OSPF. It is considered good practice to always include this keyword, regardless of the addressing scheme in use. When the subnets keyword is configured, the statement ‘includes subnets in redistribution‘ will be included in the output of the show ip protocols command as shown below:
| R2#show ip protocols Routing Protocol is “ospf 2” Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 2.2.2.2 It is an autonomous system boundary router Redistributing External Routes from, eigrp 1, includes subnets in redistribution Number of areas in this router is 1. 1 normal 0 stub 0 nssa[Truncated Output] |
However, when not included, this statement will be omitted, as shown below:
| R2#show ip protocols Routing Protocol is “ospf 2” Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID 2.2.2.2 It is an autonomous system boundary router Redistributing External Routes from, eigrp 1 Number of areas in this router is 1. 1 normal 0 stub 0 nssa[Truncated Output] |
Redistributing between two OSPF Processes
When redistributing between two OSPF processes, OSPF uses the metric of the route source as the metric of the generated Type 5 LSA. This is applicable for both Type 1 and Type 2 external routes. As a basic example, consider the basic network topology illustrated in Figure 4-12:
Fig. 4-12. Redistributing Between Two OSPF Processes
Referencing Figure 4-12, R2 is running two OSPF processes: process ID 1 and process ID 2. R2 is using process ID 1 for the segment between itself and R1 and process ID 2 for the link between itself and R4. R2 is currently receiving the following routes from R1:
| R2#show ip route ospf | include 192.168 O 192.168.254.0/24 [110/2] via 10.0.0.1, 00:00:10, FastEthernet0/0 192.168.253.0/29 is subnetted, 1 subnets O 192.168.253.0 [110/2] via 10.0.0.1, 00:00:10, FastEthernet0/0 |
As can be seen in the output above, both routes are received with a metric of 2. Next, process ID 1 is redistributed into process ID as follows:
| R2(config)#router ospf 2 R2(config-router)#redistribute ospf 1 subnets R2(config-router)#exit |
Even though no metric has been specified during redistribution, because the routes are being redistributed from another OSPF process, OSPF will simply use the metric of the other OSPF process. This is confirmed by looking at the entries in the LSDB on R2:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesLS age: 75 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.253.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x3119 Length: 36 Network Mask: /29 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 2 Forward Address: 0.0.0.0 External Route Tag: 0 LS age: 79 |
There are three ways in which the metric for redistributed routes can be set:
- Directly using the default-metric router configuration command
- Indirectly by setting the metric value in a route map using the set metric command
- Directly by using the metric command with the redistribute command
The use of the default-metric router configuration command sets the value specified as the metric for all external routes. This command works in the same manner for OSPF as was illustrated in the EIGRP configuration examples. If this command is specified and a route map is used or the metric value is specified in the redistribute command, the metric values specified in the route map or using the redistribute command take precedence. This also applies to EIGRP. The set metric command allows individual metrics to be specified for matching prefixes based on the route map configuration. And finally, the metric command may be used with the redistribute command to set the metric for all routes from the route source.
Referencing the topology illustrated in Figure 4-12, the following example illustrates how to set a metric of 253 for the 192.168.253.0/29 subnet and a metric of 254 for the 192.168.254.0/24 subnet that R2 is receiving from R1 using a route map:
| R2(config)#ip prefix-list NET-253 description ‘Match 192.168.253.0/29 Only’ R2(config)#ip prefix-list NET-253 seq 5 permit 192.168.253.0/29 R2(config)#ip prefix-list NET-254 description ‘Match 192.168.254.0/24 Only’ R2(config)#ip prefix-list NET-254 seq 5 permit 192.168.254.0/24 R2(config)#route-map OSPF-1-into-OSPF-2 permit 10 R2(config-route-map)#description ‘Set Metric For 192.168.253.0/29’ R2(config-route-map)#match ip address prefix-list NET-253 R2(config-route-map)#set metric 253 R2(config-route-map)#exit R2(config)#route-map OSPF-1-into-OSPF-2 permit 20 R2(config-route-map)#description ‘Set Metric For 192.168.254.0/24’ R2(config-route-map)#match ip address prefix-list NET-254 R2(config-route-map)#set metric 254 R2(config-route-map)#exit R2(config)#router ospf 2 R2(config-router)#redistribute ospf 1 subnets route-map OSPF-1-into-OSPF-2 R2(config-router)#exit |
Following this configuration, the Link State Database on R2 shows the following:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesLS age: 162 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.253.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000002 Checksum: 0x746 Length: 36 Network Mask: /29 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 253 Forward Address: 0.0.0.0 External Route Tag: 0 LS age: 162 |
Unlike the route metric, the metric type, i.e. Type 1 external or Type 2 external can only be set using one of two methods. These methods are:
- Directly using the metric-type command with the redistribute command
- Indirectly by setting the type in a route map using the set metric-type command
The following configuration illustrates how to redistribute all routes from OSPF 1 into OSPF 2 on R2 as Type 1 external routes using the redistribute command:
| R2(config)#router ospf 2 R2(config-router)#redistribute ospf 1 subnets metric-type 1 R2(config-router)#exit |
Following this configuration, the Link State Database on R2 shows the following:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesLS age: 12 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.253.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0xAD1D Length: 36 Network Mask: /29 Metric Type: 1 (Comparable directly to link state metric) TOS: 0 Metric: 2 Forward Address: 0.0.0.0 External Route Tag: 0 LS age: 12 |
When redistributing into OSPF, it is important to know that you can use a combination of all the different commands at the same time. As an example, assume that R1 is now advertising the following networks to R2 via OSPF:
| R2#show ip route ospf | include 192.168 192.168.251.0/27 is subnetted, 1 subnets O 192.168.251.0 [110/2] via 10.0.0.1, 00:00:05, FastEthernet0/0 O 192.168.254.0/24 [110/2] via 10.0.0.1, 00:00:05, FastEthernet0/0 192.168.253.0/29 is subnetted, 1 subnets O 192.168.253.0 [110/2] via 10.0.0.1, 00:00:05, FastEthernet0/0 192.168.252.0/25 is subnetted, 1 subnets O 192.168.252.0 [110/2] via 10.0.0.1, 00:00:05, FastEthernet0/0 |
Assume that you have been requested to change the default OSPF metrics and metric types for these received prefixes as illustrated in Table 4-5:
|
Prefix |
Metric |
Metric Type |
|---|---|---|
|
192.168.251.0/27 |
111 |
E1 |
|
192.168.252.0/25 |
222 |
E1 |
|
192.168.253.0/29 |
111 |
E1 |
|
192.168.254.0/24 |
333 |
E1 |
Tab. 4-5. Setting OSPF Metrics and Metric Types
| R2(config)#ip prefix-list NET-252 description ‘Match 192.168.252.0/25 Only’ R2(config)#ip prefix-list NET-252 seq 5 permit 192.168.252.0/25 R2(config)#ip prefix-list NET-254 description ‘Match 192.168.254.0/24 Only’ R2(config)#ip prefix-list NET-254 seq 5 permit 192.168.254.0/24 R2(config)#route-map OSPF-1-into-OSPF-2 permit 10 R2(config-route-map)#description ‘Set Metric for 192.168.252.0/25 Only’ R2(config-route-map)#match ip address prefix-list NET-252 R2(config-route-map)#set metric 222 R2(config-route-map)#exit R2(config)#route-map OSPF-1-into-OSPF-2 permit 20 R2(config-route-map)#description ‘Set Metric for 192.168.254.0/24 Only’ R2(config-route-map)#match ip address prefix-list NET-254 R2(config-route-map)#set metric 333 R2(config-route-map)#exit R2(config)#route-map OSPF-1-into-OSPF-2 permit 30 R2(config-route-map)#exit R2(config)#route-map OSPF-1-into-OSPF-2 permit 30 R2(config-route-map)#description ‘Allow All Other Prefixes’ R2(config-route-map)#exit R2(config)#router ospf 2 R2(config-router)#redistribute ospf 1 metric 111 metric-type 1 subnets route-map OSPF-1-into-OSPF-2 R2(config-router)#exit |
This configuration can be verified by looking at the Link State Database of R2 as follows:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesLS age: 125 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.251.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000002 Checksum: 0x77FE Length: 36 Network Mask: /27 Metric Type: 1 (Comparable directly to link state metric) TOS: 0 Metric: 111 Forward Address: 0.0.0.0 External Route Tag: 0 LS age: 126 LS age: 126 LS age: 126 |
Referencing the configuration above, the route map is used to explicitly set the route metric for the 192.168.252.0/25 and 192.168.254.0/24 prefixes. This metric value is assigned because the route map always takes precedence over the redistribute and default-metric commands. However, because no metric type is specified in the route map statements matching these two prefixes, the metric type defaults to the type specified in the redistribute command. The third route map permit statement allows all routes. No metric or metric type is specified in this statement and so all routes that match this statement as assigned the metric and metric type values configured using the redistribute command.
Keep in mind that this is one way of accomplishing the required task. Many different variations of the configuration can be used to do the same. The main purpose here is to demonstrate the flexibility of Cisco IOS software. While this example is based on OSPF redistribution, the same concept is applicable when redistributing routes into other routing protocols such as EIGRP.
Redistributing EIGRP Routes into OSPF
When EIGRP is redistributed into OSPF, if the metric or the metric type values are not explicitly configured during redistribution, the routes will be imported as Type 2 external routes with a default metric of 20. When redistributing EIGRP into OSPF, always ensure that you use the subnets keyword during your configuration. The following illustrates how to configure OSPF to import or redistribute EIGRP routes using default values but with a route tag of 222:
| R2(config)#router ospf 2 R2(config-router)#redistribute eigrp 1 subnets tag 222 R2(config-router)#exit |
The administrator defined route tag can be viewed in the Link Stated Database as follows:
| R2#show ip ospf database | begin Type-5 Type-5 AS External Link StatesLink ID ADV Router Age Seq# Checksum Tag 192.168.253.0 2.2.2.2 64 0x80000001 0x0091C7 222 192.168.254.0 2.2.2.2 64 0x80000001 0x00B0A0 222 |
NOTE: The use of route tags is described in detail later in this chapter.
Redistributing Connected and Static Routes into OSPF
Any directly connected interfaces (subnets) and static routes can be redistributed into an OSPF process using theredistribute connected subnets and redistribute static subnets respectively. As is the case with dynamic route sources, the metric and metric types for these route sources can also be manually specified during redistribution.
Additionally, as was demonstrated in the EIGRP configuration examples, static routes can be tagged and then a route-map can be used to match the tagged routes. The following configuration demonstrates how to redistribute static routes into OSPF as Type 2 external routes with a default metric and a tag of 111 and connected subnets as Type 1 external routes with a metric of 111 and no administrator tag:
| R1(config)#interface loopback 254 R1(config-if)#ip address 192.168.254.1 255.255.255.0 R1(config-if)#exit R1(config)#ip route 192.168.252.0 255.255.255.128 null 0 R1(config)#router ospf 1 R1(config-router)#redistribute static subnets tag 111 R1(config-router)#redistribute connected metric 111 metric-type 1 subnets R1(config-router)#exit |
In the output above, while the subnets keyword is technically not required to redistribute the 192.168.254.0/24 network, it is always considered good practice to include it in redistribution. Following this configuration, the Link State Database on R1 shows the following:
| R1#show ip ospf database externalOSPF Router with ID (1.1.1.1) (Process ID 1)Type-5 AS External Link StatesLS age: 354 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.252.0 (External Network Number ) Advertising Router: 1.1.1.1 LS Seq Number: 80000001 Checksum: 0x1234 Length: 36 Network Mask: /25 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 111 LS age: 4 |
OSPF NSSA Type 1 and Type 2 External Routes
The Type 1 and Type 2 metric types for Type 5 LSAs are also comparable to Type 1 and Type 2 metric types for Type 7 LSAs generated by the NSSA ASBR. When routes are redistributed into the NSSA, the show ip ospf database nssa-external command can be used to view the corresponding Type 7 LSAs for these routes.
The Type 7 LSAs are then translated to Type 5 LSAs by the ABR and flooded into other adjacent areas. By default, all routes redistributed into the NSSA are Type 2 external routes and the ABR generates a corresponding Type 5 LSA with a Type 2 metric type for these routes. If the routes are redistributed into the NSSA as Type 1 a corresponding Type 5 LSA with a Type 1 external metric is generated by the ABR. To reinforce this point, the following output shows an ABR that is receiving a Type 2 external route from a neighbor in an NSSA:
| R2#show ip route ospf 10.0.0.0/24 is subnetted, 4 subnets O 10.0.9.0 [110/128] via 10.0.2.4, 00:02:29, Serial0/0 O 10.0.3.0 [110/192] via 10.0.2.4, 00:02:29, Serial0/0 O N2 192.168.254.0/24 [110/20] via 10.0.0.1, 00:02:19, FastEthernet0/0 |
The show ip ospf database nssa-external command provides detailed information on the Type 7 LSA, including the route metric and the metric type as illustrated below:
| R2#show ip ospf database nssa-externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-7 AS External Link States (Area 1)Routing Bit Set on this LSA LS age: 286 Options: (No TOS-capability, Type 7/5 translation, DC) LS Type: AS External Link Link State ID: 192.168.254.0 (External Network Number ) Advertising Router: 192.168.254.1 LS Seq Number: 80000001 Checksum: 0x1E9B Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 10.0.0.1 External Route Tag: 0 |
When R2 generates the Type 5 LSA, all fields remain consistent including the IP address that is specified in the Forward Address field as shown below:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesLS age: 278 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 192.168.254.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x81A3 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 10.0.0.1 External Route Tag: 0 |
If you recall, in Chapter 3 we learned that one of the primary differences between Type 5 and Type 7 LSAs is the Forwarding Address calculation. With Type 5 LSAs, the Forward Address field contains a value of 0 unless one of the following exceptions applies:
- If the ASBRs next-hop interface network type is not P2P or point-to-multipoint
- If OSPF is enabled on the ASBRs next-hop interface
- If the next-hop interface of the ASBR falls into a defined OSPF network range
- If the ASBRs next-hop interface is not a passive OSPF interface
With Type 7 LSAs, if the route has a next-hop address, i.e. it is not a connected network; use the next-hop address in the Forward Address field. This hold true only if the route is an internal OSPF route. In other words, if the network between the NSSA boundary router and the adjacent autonomous system is advertised into OSPF as an internal OSPF route, the forwarding address should be the next-hop address.
However, if the network is not advertised into OSPF as an internal route, the Forward Address should be any of the active interfaces on the router. This means that if there is a Loopback interface enabled for OSPF routing in the area announcing the LSAs on the router, use that interface. If there are no Loopback interfaces, then the address of the first operational interface in that area should be used.
Although the translate type7 suppress-fa keyword can be used in conjunction with the area [area ID] nssarouter configuration command to configure OSPF Forwarding Address Suppression in Translated Type-5 LSAs, this configuration causes the router to be noncompliant with RFC 1587 – The OSPF NSSA Option. The primary reason the Forward Address is included is to prevent suboptimal routing following the Type 7 to Type 5 translation.
Troubleshooting OSPF Route Redistribution Issues
In some instances you may change the route redistribution configuration and notice that routes are not redistributed into OSPF. For example, you may be using a route map during redistribution which matches a specified prefix list and add permitted prefixes to this list but do not see them in the LSDB following the configuration change. In such situations, assuming that the correct configuration has been implemented, you can use the clear ip ospf redistribution privileged EXEC command to flush external LSAs, i.e. Type 5 or Type 7 LSAs and force the router to scan the routing table for permitted redistributed routes.
When issued, the local router sets the delete flag for all external LSAs and flushes and renews the external LSAs. Because Type 5 LSAs have a domain flooding scope, all other routers in the network perform a partial SPF calculation so they can flush and renew these LSAs. The following output shows a Type 7 LSA marked to be flushed following the issuing of the clear ip ospf redistribution privileged EXEC command on a router:
| R2#show ip ospf database nssa-externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-7 AS External Link States (Area 1) Delete flag is set for this LSA LS age: MAXAGE(3601) Options: (No TOS-capability, No Type 7/5 translation, DC) LS Type: AS External Link Link State ID: 200.1.1.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x4685 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 0 |
This LSA would be flooded into the NSSA and cause all routers in the NSSA to perform a partial SPF calculation. The corresponding Type 5 LSA would also reflect the same:
| R2#show ip ospf database externalOSPF Router with ID (2.2.2.2) (Process ID 2)Type-5 AS External Link StatesDelete flag is set for this LSA LS age: MAXAGE(3600) Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 200.1.1.0 (External Network Number ) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x626B Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 0 |
Because Type 5 LSAs are flooded throughout the domain, this would cause all other routers in the network, except routers in stubby type areas because Type 5 LSAs are not flooded into stubby type areas, to perform a partial SPF calculation and flush and renew the Type 5 LSA.
