CCNP ROUTE Tutorial and Lab: “distance ospf” vs. “distance”

Note:  You don’t have to study the “previous lab” mentioned in the first paragraph in order to enjoy this lab.  I’d check it out when I’m done here, though, as it’s one of the best labs I’ve ever created for my CCNP ROUTE and TSHOOT students.

As always, comments and compliments welcome at my Twitter feed and my Facebook page.   I love hearing from you!    Now, let’s dive in….

In the previous (and huge) CCNP ROUTE lab on route redistribution, we used the distance command twice.   First, we used it to change the administrative distance of all OSPF routes on a router.  Second, we used distance along with an ACL in order to change the distance of one particular route without changing it on the others.

The odd thing is that IOS Help displayed distance and distance ospf, and we used distance. Here’s the IOS Help readout along with the command we used:

R2(config)#router ospf 1

R2(config-router)#distance ?

  <1-255>  Administrative distance

  ospf     OSPF distance

R2(config-router)#distance 121

We’re working with OSPF routes, so why didn’t I choose distance ospf?    Before I demo distance ospf for you, let me draw a clear line between these two commands.

distance is used to change the AD of a specific route, group of routes, or all routes discovered by a particular routing protocol, such as OSPF.

distance ospf is used to change the AD of a type of OSPF routes.

Chris Bryant's CCNP ROUTE Study Guide

Let’s use the following OSPF routing table to demo distance ospf.    This is not from the previous lab, and OSPF is the only routing protocol running on this router.

R2#show ip route ospf

      3.0.0.0/32 is subnetted, 1 subnets

O IA     3.3.3.3 [110/2] via 30.1.1.3, 00:13:16, FastEthernet0/0

      10.0.0.0/24 is subnetted, 1 subnets

O E2     10.1.1.0 [110/20] via 30.1.1.3, 00:09:21, FastEthernet0/0

      33.0.0.0/32 is subnetted, 1 subnets

O        33.3.3.3 [110/2] via 30.1.1.3, 00:12:41, FastEthernet0/0

      172.12.0.0/24 is subnetted, 1 subnets

O E2     172.12.123.0 [110/20] via 30.1.1.3, 00:09:49, FastEthernet0/0

There’s a little of everything in this table!   R2 has two external routes, an inter-area route, and an intra-area route.   Let’s use distance ospf to change all of those ADs, but to different values.   We can actually change three route type ADs with one command, and I’ll use IOS Help to show you the options as we go along.

R2(config)#router ospf 1

R2(config-router)#distance ospf ?

  external    External type 5 and type 7 routes

  inter-area  Inter-area routes

  intra-area  Intra-area routes

R2(config-router)#distance ospf external ?

  <1-255>  Distance for external type 5 and type 7 routes

R2(config-router)#distance ospf external 200 ?

  inter-area  Inter-area routes

  intra-area  Intra-area routes

  <cr>

R2(config-router)#distance ospf external 200 inter-area ?

  <1-255>  Distance for inter-area routes

R2(config-router)#distance ospf external 200 inter-area 150 ?

  intra-area  Intra-area routes

  <cr>

R2(config-router)#distance ospf external 200 inter-area 150 intra-area ?

  <1-255>  Distance for intra-area routes

R2(config-router)#distance ospf external 200 inter-area 150 intra-area 140

You could certainly enter three separate distance ospf commands, one for each route type, instead of this one long command.   The important thing is that the command works, and according to show ip route ospf, it does indeed.

R2#show ip route ospf

      3.0.0.0/32 is subnetted, 1 subnets

O IA     3.3.3.3 [150/2] via 30.1.1.3, 00:01:00, FastEthernet0/0

      10.0.0.0/24 is subnetted, 1 subnets

O E2     10.1.1.0 [200/20] via 30.1.1.3, 00:01:00, FastEthernet0/0

      33.0.0.0/32 is subnetted, 1 subnets

O        33.3.3.3 [140/2] via 30.1.1.3, 00:01:00, FastEthernet0/0

      172.12.0.0/24 is subnetted, 1 subnets

O E2     172.12.123.0 [200/20] via 30.1.1.3, 00:01:00, FastEthernet0/0

The only real problem with distance ospf is that it does not allow the use of ACLs to filter out some routes.  If we wanted to change the AD of only one of the external routes in that table, we’d have to use distance <AD> instead, and use an ACL to indicate which route to change.  As IOS Help showed us, there’s no ACL option with distance ospf.

We’ll tackle EIGRP route redistribution in our next CCNP ROUTE redistribution lab, which I’ll post over the weekend of July 25, 2018.  Check out these previous redistribution labs while you’re here, as well as my CCNP ROUTE Study Guide in hard and soft copy on Amazon.   As always, thanks for making me part of your certification success journey.

Chris B.

Chris Bryant's CCNP ROUTE Study Guide

 

CCNP ROUTE Redistribution Lab:  One Protocol Only

CCNP ROUTE Redistribution Lab:  RIP < > OSPF

CCNP ROUTE Lab:  Redistribution and Admin Distance