Open Shortest Path First (OSPF) is a popular routing protocol used in many production networks throughout the world.
Understanding route types is important when designing an OSPF topology for efficient and effective operation.
Among the various route types OSPF offers, the External types E1 and E2 play an important role in importing routes from outside the OSPF domain, as each type carries unique characteristics and implications for path selection and route calculation.
This article explains and compares these two types of routes, offering insights into their differences and impact on routing.
OSPF Path Selection
OSPF’s hierarchical design means that there are various types of routes that are shared between OSPF routers.
These types depend upon where they were learned from in relation to the area to which the local router belongs.
Take a look at the output of the show ip route command in a Cisco IOS router. We’ll be looking specifically at the codes:
R1#show ip route
Codes: L – local, 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, H – NHRP, l – LISP
a – application route
+ – replicated route, % – next hop override, p – overrides from PfR
Notice the various codes that are reserved for OSPF, highlighted in red. These are:
- 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
These are the letters that appear to the left of the routing entries in the routing table indicating the route type. In this article, we’ll be examining the last two route types, E1 and E2.
External OSPF Routes
In the context of OSPF, an external route refers to a network route that originates from outside the OSPF domain.
Such routes are not natively part of the OSPF routing domain but are introduced into OSPF from other sources using redistribution.
These routes can originate from other routing protocols, or from static routes. External routes are introduced into OSPF by an Autonomous System Boundary Router (ASBR).
Let’s take a look at what these external routes look like and how they are configured. Refer to the following OSPF topology diagram:
In this topology, R2 and R3 are ASBRs because they have at least one interface outside of the OSPF domain.
That interface is loopback 0 in both cases. The same IP address has been assigned to both loopbacks to demonstrate an additional characteristic of these external routes, which we will see in a moment.
Note: Using the same IP address on the two loopback interfaces on two different routers may seem improper, but for the purposes of this example it is not. This is akin to having a physical interface on R2 and R3 connected to the same subnet, which is perfectly fine. From the point of view of R1, the same subnet is being advertised by both routers. |
R1 is a normal OSPF router and will receive the OSPF updates about the 1.1.1.1/32 network from both R2 and R3.
Let’s assume that OSPF has been configured correctly on R1, and both of its interfaces connected to R2 and R3 are participating in OSPF. Now, let’s configure an E1 external route on R2.
Configuring an E1 External Route
Take a look at the following series of configurations on R2:
R2(config)#router ospf 1
R2(config-router)#router-id 22.22.22.22
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#redistribute connected subnets metric-type 1
The above commands enable OSPF on the router by:
- Assigning a router ID to the router
- Including the network of the interface facing R1 in the operation of OSPF using the network
- Redistributing all connected subnets (including 1.1.1.1/32) into OSPF.
Observe the metric-type keyword followed by a 1. This is the command that specifies that this is an E1 route. Note that if the metric-type keyword is not used, the default metric-type is 2.
Configuring an E2 External Route
Let’s similarly configure R3 to advertise an E2 external route:
R3(config)#router ospf 1
R3(config-router)#router-id 33.33.33.33
R3(config-router)#network 192.168.3.0 0.0.0.255 area 0
R3(config-router)#redistribute connected subnets metric-type 2
Note that the metric-type in this case is 2. This makes this redistributed route an E2 route. Again, if we don’t use this keyword at all, the default metric type is 2.
Looking at the routing table
Now let’s take a look at the routing table of R1 to see what OSPF routes it has received. We’ll be using the ospf keyword to limit our output:
R1#show ip route ospf
1.0.0.0/32 is subnetted, 1 subnets
O E1 1.1.1.1 [110/21] via 192.168.2.2, 00:00:12, GigabitEthernet0/1
We now see a route to the 1.1.1.1 network via R1 which has a next hop IP of 192.168.2.2. And we can see that this is an OSPF E1 route due to the O E1 label on the left of the entry.
Note that we don’t see any E2 routes. This is because OSPF has received updates from both R1 and R2, but it prefers E1 routes over E2 routes. This is the case regardless of the metric. This is why we used the same IP address for both loopbacks, to be able to compare this behavior.
To see the E2 route, let’s shutdown the Gi0/1 interface of R1 and see what happens.
R1#configure terminal
R1#(config)#interface gigabitethernet0/1
R1#(config-if)#shutdown
R1#(config-if)#exit
R1#(config)#exit
R1#
Now let’s look at the routing table of R1 once again:
R1#show ip route ospf
1.0.0.0/32 is subnetted, 1 subnets
O E2 1.1.1.1 [110/20] via 192.168.3.2, 00:00:09, GigabitEthernet0/2
Since the E1 route is no longer being advertised to R1, we now see the E2 route has entered the OSPF routing table as expected.
What’s the point?
So far, all of this might seem pointless. We have two types of external routes, and we can essentially label them as such simply using the metric-type keyword. But how are these two types different and why are their differences useful?
When an external route is redistributed into OSPF, it is assigned a particular metric. This metric can be left to a default value, or it can be configured as part of the redistribute command.
We won’t go into how that’s done here. Suffice it to say however, that the primary difference between E1 and E2 routes lies in how OSPF changes (or doesn’t change) that metric as the route is propagated into the OSPF domain.
E1 External route cost calculation
The metric for an E1 route is the sum of the external route’s cost and the internal OSPF cost to reach the ASBR. This means the metric may be variable and depends on the path to the ASBR. As the OSPF topology changes and if the path to the ASBR changes, the metric for the E1 route will also change.
E2 External route cost calculation
The metric for an E2 route is solely the external route’s cost, without considering the internal OSPF cost to reach the ASBR. Thus, the metric remains constant throughout the OSPF domain regardless of the path to the ASBR. It doesn’t change even if there are multiple paths to reach the ASBR.
Visual representation of the difference
To more fully understand the difference, take a look at this modified topology:
Here you can see that the initial redistribution metric of the E1 and E2 routes is set to 20. Now when these E1 and E2 routes are propagated through the OSPF topology, R4 will learn about both of them.
- The E1 route will be received by R4 with a metric of 20 + whatever the additional OSPF metric is to reach R2 from R4.
- The E2 route will have a metric of 20.
So, an E1 external route will have a different metric, while an E2 external route will have the same metric when viewed from all of the various OSPF routers within the domain.
Use cases
This can be useful in various scenarios including:
- E1 routes can be advantageous in scenarios where the internal OSPF topology might influence the best path to reach the external network.
- E2 routes are suitable in scenarios where the external cost is the primary deciding factor and where the internal OSPF topology shouldn’t influence the path selection for external routes.
Conclusion
The difference between E1 and E2 external routes in OSPF is quite nuanced and may be difficult to grasp.
Depending on the network’s needs, administrators might choose to use E1 or E2 routes to influence routing decisions for external networks.
Hopefully this article has helped you to gain a better grasp of the types of external routes that OSPF uses.
Related Posts
- Discussion and Explanation of OSPF Graceful Restart and Shutdown
- Explanation and Configuration of OSPF MD5 Authentication on Cisco Networks
- Explanation of BGP Neighbor Adjacency States on Cisco Devices
- Comparison of Static vs Dynamic Routing in TCP/IP Networks
- How to Configure Static Routing on Cisco IOS Routers (Examples)