When and how would you change the administrative distance of a protocol or a route?
Show the answer
Say this first
To make the router prefer a different source for the same prefix. Common cases: floating statics, a
protocol migration where you flip which protocol wins one router at a time, fixing redistribution
preferences, and BGP backdoor routes so an IGP path beats an eBGP one. You set it per static route, per
protocol with distance, or per neighbor and prefix with a distance line and an ACL. AD is local, so
inconsistent changes across routers can create loops.
Go deeper
Syntax
ip route 0.0.0.0 0.0.0.0 198.51.100.1 250
!
router ospf 1
distance ospf intra-area 110 inter-area 110 external 175
!
router eigrp 100
distance eigrp 90 170
!
router bgp 64500
address-family ipv4
distance bgp 20 200 200
!
router rip
distance 125 10.0.12.2 0.0.0.0 20
!
access-list 20 permit 172.16.0.0 0.0.255.255distance eigrp <internal> <external>.distance bgp <external> <internal> <local>.- The RIP line gives AD 125 to routes from neighbor 10.0.12.2 that match ACL 20.
Migration example: EIGRP to OSPF
Run OSPF beside EIGRP everywhere. EIGRP still wins (90 and 170 beat 110). Then, router by router, set
distance eigrp 120 180, check that OSPF routes take over, and finally remove EIGRP.
BGP backdoor
Site A and site B learn each other's prefixes from the provider over eBGP (AD 20) and also have a private link running OSPF. On site A's router, name site B's prefix:
router bgp 64500
address-family ipv4
network 10.60.0.0 mask 255.255.0.0 backdoorThe eBGP-learned 10.60.0.0/16 now gets AD 200, so the OSPF route over the private link wins. Site B's router does the same for site A's prefix. A backdoor network is not advertised by the router that has it.
They will ask next
Can you change AD on one router only?
Yes, AD is local. That is what makes per-router migrations possible, and also why careless changes cause loops: two routers that each prefer the other for the same prefix will bounce packets.
Traps
- Lowering a protocol's AD below static (1) or connected (0) to win. Connected cannot be beaten, and fighting static routes hides configuration errors.