New Batch Starts on 16th Oct.
Module: Network Fundamentals (L2 L3 Protocol Testing)
Timing: 07:00 AM to 08:00 AM IST (Weekdays)
Sign Up Now !

OSPF Configuration Example 4 : Redistribution Commands

Configuring Redistribution, E1 Metric, and Route Tags in OSPF

In the tutorial “Understanding OSPF Redistribution” , we discussed different concepts in redistribution. In this one, we’ll go through the various OSPF commands related to redistribution. We’ll walk through a step-by-step process to configure redistribution in OSPF, focusing on scenarios like redistributing from Static routes and EIGRP. We’ll also cover how to adjust the metric by using External Type 1 routes and the use of Route Tags when OSPF redistributes networks from other routing protocols.

Table of Contents


Let’s understand the OSPF redistribution commands using the following topology.

A diagram to explain OSPF redistribution commands with three routers where Router 1 and Router 2 are in OSPF, and Router 2 acting as the ASBR.
Configuring redistribution from other protocols to OSPF

Let’s begin by looking at how to redistribute static routes.

Redistribution of Static Routes: Topology and Configuration

In the topology above, Router 1 and Router 2 are using OSPF. There is a network 30.0.0.0/8 on Router 3’s loopback interface. To reach this network from Router 2, we add a static route. Now, Router 2 and Router 3 can reach the 30.0.0.0 network, but Router 1 cannot. This is where redistribution comes into play. On Router 2, we can configure the “redistribute static subnets” command under OSPF configuration mode. This command injects the static route into OSPF, allowing Router 2 to advertise this network to Router 1 using an LSA type 5.

Note: Adding the keyword “subnets” at the end of the command is optional. If you omit it, only the major networks will be redistributed, and subnets will not be included. Therefore, if your network includes subnets that need to be redistributed, you must include the “subnets” keyword at the end of the command.

Now, let’s go through the configuration commands for redistributing static routes in the above given topology.

Configuration Commands:

Configuring the IP address on FastEthernet 0/0: 1.1.1.1/8 and enabling OSPF on network 1.0.0.0 with a wildcard mask of 0.255.255.255 in Area 1 on Router 1:

R2 Configuration: On Router 2, we need to configure IP addresses on the interfaces, add a static route, and redistribute the static route into OSPF. The following commands will configure the IP 1.1.1.2/8 on FastEthernet 0/0, 2.2.2.2/8 on FastEthernet 0/1, add a static route to 30.0.0.0/8, and finally redistribute that static route into OSPF.

R3 Configuration: Note: You don’t need to configure Router 3 if you only want to check whether the static route is being redistributed into OSPF. By configuring the commands on R1 and R2, the static route to 30.0.0.0/8 will be redistributed into OSPF, and you can verify this route in R1’s routing table. However, if you want to test whether data packets can be sent to this redistributed network using Ping, you’ll need to configure R3 as well. Additionally, R3 must have a static route to the 1.0.0.0 network for the ping packets to return successfully. Following commands will configure IP address 2.2.2.3/8 on Fastethernet 0/1 , 30.1.1.1/8 on Loopback interface and will add static route to 1.0.0.0/8

Verifying the OSPF Redistribution Configuration

Now, let’s check the results of this configuration. Ideally, Router 1 should receive the 30.0.0.0/8 network from Router 2. This route will appear in Router 1’s routing table with the code ‘O E2,’ indicating that it is a redistributed route. ‘O E2’ stands for OSPF External Type 2 route. As we discussed in the other chapter about redistribution, O E2 routes do not factor in the internal cost to reach the Autonomous System Boundary Router (ASBR). Therefore, the cost or metric to reach this network will be 20, which is the default cost that OSPF assigns when redistributing external routes.

Output of 'show ip route' on a Cisco router showing OSPF redistributed networks with code OE2.
Output of ‘show ip route’ showing the redistributed route

Understanding and Configuring Redistribution from EIGRP to OSPF

Next, let’s explore how to perform redistribution from another protocol. In this example, we’ll use EIGRP, though you could use any other protocol like BGP, ISIS, or RIP. To redistribute from EIGRP, we’ll add one more loopback interface on R3 with the network address 31.0.0.0/8. R3 will advertise this network to R2 using EIGRP, and R2 will then redistribute this network into OSPF.

Below are the commands you need to add on R2 and R3. Assuming that you have already configured the IP addresses from the previous exercise, we’ll only show the commands required to configure EIGRP and redistribute the networks learned from EIGRP into OSPF. When configuring EIGRP, you need to specify the Autonomous System (AS) number. .

R2 Configuration: In the following configuration, we’re using AS number 100. When issuing the redistribution command, this AS number must be included. So, in this case, the command to redistribute EIGRP networks of AS 100 into OSPF will be “redistribute eigrp 100 subnets

R3 Configuration: On Router 3, we are only configuring the loopback interface and enabling EIGRP to advertise that network. Assuming the IP address for the physical interface is already configured, the following commands will configure the IP 31.1.1.1/8 on Loopback 2 and enable EIGRP with AS number 100 to advertise networks 2.0.0.0 and 31.0.0.0.

Verifying the results:

In the output of “show ip route” on R1 shown above, you can see two newly redistributed routes on R1: 2.0.0.0 and 31.0.0.0, both marked with the code ‘O E2.’ These are the networks that OSPF has redistributed from EIGRP on R2. Note that, similar to the previously redistributed static route, these networks also have a metric of 20.


Configuring redistribution with Metric Type 1 : O E1 routes

In the previous examples, we saw OSPF advertising the redistributed routes with the code ‘O E2,’ which stands for External Type 2 routes. In these routes, the metric assigned to the networks remains constant across the OSPF network, meaning routers inside the OSPF domain do not consider the internal cost to reach the ASBR. So, the metric that the ASBR announces is the one used by these routers. In other words, with ‘O E2’ routes, the metric shown in the routing table is not the actual path cost – it’s just the metric set by the ASBR for that network.

If you want OSPF to calculate the actual cost, including the internal cost to reach the ASBR, you can use the ‘Metric Type 1’ option. This requires configuring your ASBR to announce the redistributed networks with ‘Metric Type 1.’ You can do this in OSPF configuration mode. For example, if you want to use Metric Type 1 in the scenarios we discussed earlier, you can use “redistribute static subnets metric-type 1” or “redistribute eigrp 100 subnets metric-type 1“.

Configuring redistribution with metric type 1 on R2 (ASBR) :

Now, let’s check the impact of this configuration on Router 1’s routing table using “show ip route”.

A screenshot of 'show ip route' command on a Cisco router showing OSPF redistributed networks with metric type 1
Routing table of Router 1 showing ‘O E1’ routes after setting the metric type to 1.

In the output of “show ip route” on R1 shown above, you can see that the code has changed to ‘O E1,’ and the metric is now 21. In this setup, there’s a fast Ethernet link between Router 1 and Router 2, which has a cost of 1. Therefore, the total cost is calculated as the advertised cost of 20 plus the internal cost of 1, resulting in a metric of 21


Using the Route Tag Field in OSPF

When configuring OSPF redistribution, the tag is an optional field that can be used to mark redistributed routes with a 32-bit value known as the ‘External Route Tag.’ This tag appears in Type 5 and Type 7 LSAs, which advertise external routes in OSPF. The tag is a number that admins can set when redistributing networks into OSPF. It can be used for various purposes, such as filtering routes, preventing loops when multiple ASBRs are involved, applying route policies, and tracking routes.

Configuring Route Tags while configuring static routes to OSPF :


OSPF Commands to Configure Redistribution from Other Protocols:

You can use the same method to configure redistribution from other routing protocols. Below are the commands you need to use to redistribute from BGP, ISIS, RIP, and directly connected routes:

  1. redistribute bgp 10 subnets (where 10 is the BGP AS number)
  2. redistribute isis subnets
  3. redistribute rip subnets
  4. redistribute connected subnets

Next >>> BGP Configuration Example 1: EBGP Peering

Previous >>> OSPF Configuration Example 3 : DR BDR election


We’d love to hear your feedback and suggestions about this article. Feel free to reach out to us using the WhatsApp number below.

Sajith Achipra has been a trainer and testing consultant at Zframez Technologies since 2009. With 15+ years of experience, he specializes in networking, Python, development, and testing. He conducts online courses to help students and professionals enhance their skills. You can reach him on WhatsApp at +91 8884 884 844 for your training and testing requirements.