​Admin Distance And Route Preference

In this post, we will look at Cisco’s Administrative Distance (AD) and Juniper’s Route Preference.

What Is Admin Distance And Route Preference

Administrative distance on Cisco or route preference on Juniper is used to choose what route to use when the exact same route is learned via different routing protocols.

It is a measure of how much the router trusts a protocol. We trust connected routes because they are configured on the local device, followed by static routes explicitly configured by a network admin.

Regarding dynamic routing protocols, we generally trust the information from OSPF or IS-IS more than we trust RIP.

For both administrative distance and route preference, a lower value is preferred.

These values are locally significant only and are not communicated to other routers in the network.

How Does Administrative Distance Differ From A Route Metric

The easiest way to think about this is as follows:

  • Administrative Distance (or Route Preference) is a decision based on which routing protocol we trust more.
  • The metric is a decision based on which path to use when a single protocol has multiple paths to a destination.

This distinction is needed because we can’t compare the metrics of different routing protocols. An OSPF metric of 100 can’t be compared to a RIP metric of 10, for example. Since we can’t choose by comparing the metrics, we need to choose which protocol we think is more likely to have reliable information about the network.

What Are The Default Values For Admin Distance And Route Preference

The following table shows the default values for several common routing protocols.

ProtocolAdmin Distance (Cisco IOS)Route Preference (Juniper)
Connected interface00
Static Route15
EIGRP Summary5N/A
eBGP20170
Internal EIGRP90N/A
IGRP100N/A
OSPF110
OSPF Internal10
OSPF AS External150
IS-IS115
IS-IS Level 1 Internal15
IS-IS Level 2 Internal18
IS-IS Level 1 External160
IS-IS Level 2 External165
RIP120100
External EIGRP170N/A
iBGP200170

As you can see from the table above, there are some differences between the two vendors.

Some of the key points are:

  • IGRP / EIGRP
    • These are Cisco proprietary protocols and are not supported on Juniper equipment.
  • BGP
    • Juniper treats both iBGP and eBGP the same, with a preference of 170.
    • Cisco instead has eBGP with an admin distance of 20 and iBGP of 200.
  • OSPF and IS-IS
    • Juniper has different values for the various types of routes – internal, external, or in the case of IS-IS different levels.
    • Cisco instead has just one admin distance for OSPF and another for IS-IS, without breaking it down into the different types of routes.
    • Overall, the actual behavior is similar. OSPF internal routes are preferred over externals, and IS-IS level-1 routes are preferred over level-2 routes.

Can I Change The Default Values?

Yes. It is usually possible to change the default admin distance or route preference on a per protocol or per route basis.

When doing route redistribution it is sometimes necessary to change the default values to make the routing work as desired.

Another use is to have a “floating” static route. By increasing the admin distance of a static route it will only come into use when that exact route isn’t learned via any other protocol.

Administrative Distance And Route Preference Example

In the following examples, we will see how a Cisco IOS device and a Juniper Junos device behave when they learn the same route via different protocols. We’ll be making use of BGP, OSPF, and IS-IS.

Lab Setup

The lab is set up as follows.

  • Three routers are connected over one shared subnet.
  • VMX-1 advertising its loopback and the 10.200.0.0/24 network.
  • VMX-1 advertising its loopback
  • CSR-1 advertising its loopback.
  • Initially, vMX-1 will advertise the 10.200.0.0/24 network via BGP, IS-IS, and OSPF.

Initial State – vMX-1 advertising via eBGP, IS-IS, and OSPF

The vMX-1 router has an interface with an address of 10.200.0.1/24. This is configured as a passive interface under both IS-IS and OSPF so the route appears as type internal. The 10.200.0.0/24 route is exported into eBGP using policy.

Let’s look at the routing tables on vMX-2 and CSR-1.

vMX-2:

lab@vMX-2> show route table inet.0 

inet.0: 9 destinations, 13 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.0.0/24        *[Direct/0] 03:35:15
                    >  via fxp0.0
10.0.0.52/32       *[Local/0] 03:35:15
                       Local via fxp0.0
10.100.1.0/24      *[Direct/0] 02:36:05
                    >  via ge-0/0/0.0
10.100.1.2/32      *[Local/0] 02:36:05
                       Local via ge-0/0/0.0
10.200.0.0/24      *[OSPF/10] 00:06:28, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 00:05:08, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [BGP/170] 00:06:26, localpref 100
                      AS path: 65001 I, validation-state: unverified
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.1/32     *[OSPF/10] 01:17:19, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 00:05:08, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.2/32     *[Direct/0] 02:37:24 
                    >  via lo0.0
192.168.0.3/32     *[OSPF/10] 01:59:37, metric 11
                    >  to 10.100.1.3 via ge-0/0/0.0
                    [IS-IS/15] 01:59:27, metric 20
                    >  to 10.100.1.3 via ge-0/0/0.0
224.0.0.5/32       *[OSPF/10] 02:37:24, metric 1
                       MultiRecv

lab@vMX-2>

On Junos, all three routes are visible in the routing table. The ‘*’ next to OSPF denotes it as the currently active route. It has been chosen as it has the lowest route preference of the three protocols.

CSR-1:

CSR-1#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

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet1
L        10.0.0.53/32 is directly connected, GigabitEthernet1
C        10.100.1.0/24 is directly connected, GigabitEthernet2
L        10.100.1.3/32 is directly connected, GigabitEthernet2
B        10.200.0.0/24 [20/0] via 10.100.1.1, 00:06:59
      192.168.0.0/32 is subnetted, 3 subnets
O        192.168.0.1 [110/10] via 10.100.1.1, 01:17:57, GigabitEthernet2
O        192.168.0.2 [110/10] via 10.100.1.2, 01:28:53, GigabitEthernet2
C        192.168.0.3 is directly connected, Loopback0
CSR-1#

On the CSR we only see the BGP route. Since we’ve used eBGP, its administrative distance of 20 is better than OSPF or IS-IS, making the path via eBGP preferred.

The IOS routing table only shows the one preferred route, not all available routes as Junos does.

vMX-1 advertising via IS-IS, and OSPF

What happens if we stop vMX-1 from advertising the BGP route?

vMX-2:

lab@vMX-2> show route table inet.0    

inet.0: 9 destinations, 12 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.0.0/24        *[Direct/0] 03:42:00
                    >  via fxp0.0
10.0.0.52/32       *[Local/0] 03:42:00
                       Local via fxp0.0
10.100.1.0/24      *[Direct/0] 02:42:50
                    >  via ge-0/0/0.0
10.100.1.2/32      *[Local/0] 02:42:50
                       Local via ge-0/0/0.0
10.200.0.0/24      *[OSPF/10] 00:13:13, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 00:11:53, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.1/32     *[OSPF/10] 01:24:04, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 00:11:53, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.2/32     *[Direct/0] 02:44:09
                    >  via lo0.0
192.168.0.3/32     *[OSPF/10] 02:06:22, metric 11
                    >  to 10.100.1.3 via ge-0/0/0.0
                    [IS-IS/15] 02:06:12, metric 20
                    >  to 10.100.1.3 via ge-0/0/0.0
224.0.0.5/32       *[OSPF/10] 02:44:09, metric 1
                       MultiRecv

lab@vMX-2>

vMX-2 no longer has a BGP route to 10.200.0.0/24. It still prefers the OSPF route over the IS-IS route.

CSR-1:

CSR-1#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

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet1
L        10.0.0.53/32 is directly connected, GigabitEthernet1
C        10.100.1.0/24 is directly connected, GigabitEthernet2
L        10.100.1.3/32 is directly connected, GigabitEthernet2
O        10.200.0.0/24 [110/11] via 10.100.1.1, 00:01:42, GigabitEthernet2
      192.168.0.0/32 is subnetted, 3 subnets
O        192.168.0.1 [110/10] via 10.100.1.1, 01:25:12, GigabitEthernet2
O        192.168.0.2 [110/10] via 10.100.1.2, 01:36:08, GigabitEthernet2
C        192.168.0.3 is directly connected, Loopback0
CSR-1#

Since the eBGP route is no longer available, the CSR prefers the OSPF route (AD 110) over the IS-IS route (AD 115).

vMX-2 And CSR-1 Update Admin Distance And Route Preference

In this step we have made the following changes:

  • vMX-2 – OSPF route preference set to 19
  • CSR – OSPF administrative distance set to 130

vMX-2:

lab@vMX-2> show route table inet.0    

inet.0: 9 destinations, 12 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.0.0/24        *[Direct/0] 03:50:51
                    >  via fxp0.0
10.0.0.52/32       *[Local/0] 03:50:51
                       Local via fxp0.0
10.100.1.0/24      *[Direct/0] 02:51:41
                    >  via ge-0/0/0.0
10.100.1.2/32      *[Local/0] 02:51:41
                       Local via ge-0/0/0.0
10.200.0.0/24      *[IS-IS/15] 00:20:44, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [OSPF/19] 00:02:38, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.1/32     *[IS-IS/15] 00:20:44, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [OSPF/19] 00:02:38, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.2/32     *[Direct/0] 02:53:00
                    >  via lo0.0
192.168.0.3/32     *[IS-IS/15] 02:15:03, metric 20
                    >  to 10.100.1.3 via ge-0/0/0.0
                    [OSPF/19] 00:02:38, metric 11
                    >  to 10.100.1.3 via ge-0/0/0.0
224.0.0.5/32       *[OSPF/10] 02:53:00, metric 1
                       MultiRecv

lab@vMX-2> 

Looking at the entries for the 10.200.0.0/24 route you can see that IS-IS is now preferred and the route preference for OSPF is 19.

Changing the route preference for OSPF also affected the loopback routes for 192.168.0.1 and .2.

CSR-1:

CSR-1#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

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet1
L        10.0.0.53/32 is directly connected, GigabitEthernet1
C        10.100.1.0/24 is directly connected, GigabitEthernet2
L        10.100.1.3/32 is directly connected, GigabitEthernet2
i L1     10.200.0.0/24 [115/11] via 10.100.1.1, 00:02:27, GigabitEthernet2
      192.168.0.0/32 is subnetted, 3 subnets
i L1     192.168.0.1 [115/10] via 10.100.1.1, 00:02:27, GigabitEthernet2
i L1     192.168.0.2 [115/10] via 10.100.1.2, 00:02:27, GigabitEthernet2
C        192.168.0.3 is directly connected, Loopback0
CSR-1#

Similarly to vMX-2, the IS-IS routes are now preferred for the 10.200.0.0/24 and the loopback routes.

Reset Admin Distance, Route Preference, And Advertise New Route From v-MX-1

In this final example, we reset the admin distance and route preference on CSR-1 and vMX-2. Then we get vMX-1 to advertise a more specific route for 10.200.0.0/25 in IS-IS only.

VMX-2:

lab@vMX-2> show route table inet.0 

inet.0: 10 destinations, 13 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.0.0/24        *[Direct/0] 07:38:29
                    >  via fxp0.0
10.0.0.52/32       *[Local/0] 07:38:29
                       Local via fxp0.0
10.100.1.0/24      *[Direct/0] 06:39:19
                    >  via ge-0/0/0.0
10.100.1.2/32      *[Local/0] 06:39:19
                       Local via ge-0/0/0.0
10.200.0.0/24      *[OSPF/10] 00:02:05, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 04:08:22, metric 11
                    >  to 10.100.1.1 via ge-0/0/0.0
10.200.0.0/25      *[IS-IS/160] 00:00:12, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.1/32     *[OSPF/10] 00:02:05, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
                    [IS-IS/15] 04:08:22, metric 10
                    >  to 10.100.1.1 via ge-0/0/0.0
192.168.0.2/32     *[Direct/0] 06:40:38
                    >  via lo0.0        
192.168.0.3/32     *[OSPF/10] 00:02:05, metric 11
                    >  to 10.100.1.3 via ge-0/0/0.0
                    [IS-IS/15] 06:02:41, metric 20
                    >  to 10.100.1.3 via ge-0/0/0.0
224.0.0.5/32       *[OSPF/10] 06:40:38, metric 1
                       MultiRecv

lab@vMX-2> 

The vMX-2 router is receiving 10.200.0.0/24 via both IS-IS and OSPF, due to route preference it prefers the OSPF route. The 10.200.0.0/25 route on the other hand is only advertised in the IS-IS protocol. Because the router only receives that route once, it doesn’t have to choose between multiple protocols.

CSR-1:

CSR-1#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

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 6 subnets, 3 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet1
L        10.0.0.53/32 is directly connected, GigabitEthernet1
C        10.100.1.0/24 is directly connected, GigabitEthernet2
L        10.100.1.3/32 is directly connected, GigabitEthernet2
O        10.200.0.0/24 [110/11] via 10.100.1.1, 00:02:37, GigabitEthernet2
i L1     10.200.0.0/25 [115/10] via 10.100.1.1, 00:00:21, GigabitEthernet2
      192.168.0.0/32 is subnetted, 3 subnets
O        192.168.0.1 [110/10] via 10.100.1.1, 00:02:37, GigabitEthernet2
O        192.168.0.2 [110/10] via 10.100.1.2, 00:02:37, GigabitEthernet2
C        192.168.0.3 is directly connected, Loopback0
CSR-1#

Similarly to vMX-2, CSR chooses the OSPF route instead of IS-IS for 10.200.0.0/24 due to OSPF having a lower administrative distance. The 10.200.0.0/25 route is only learned via IS-IS, which is why it is an IS-IS route.

Conclusion

Administrative distance on Cisco and route preference on Juniper perform similar functions. This only becomes a deciding factor when several protocols have the exact same route available.

Leave a Comment

Your email address will not be published. Required fields are marked *