Backdoor Routes
Prefer a direct IGP path to a specific destination while retaining external BGP as backup.
Two customer sites and a provider
R1 and R2 exchange loopbacks over their direct OSPF link. They also advertise those /32s to provider R3 through separate external sessions. With the default administrative distances in this command family, eBGP distance 20 beats OSPF 110 for the same /32.
| Link | First endpoint | Second endpoint |
|---|---|---|
| R1–R2 | GigabitEthernet1 192.0.2.1/30 | GigabitEthernet1 192.0.2.2/30 |
| R1–R3 | GigabitEthernet2 192.0.2.5/30 | GigabitEthernet1 192.0.2.6/30 |
| R2–R3 | GigabitEthernet2 192.0.2.9/30 | GigabitEthernet2 192.0.2.10/30 |
Complete baseline configurations
R1
hostname R1
ip cef
interface Loopback0
ip address 10.255.0.1 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.1 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.5 255.255.255.252
no shutdown
exit
router ospf 1
router-id 10.255.0.1
network 10.255.0.1 0.0.0.0 area 0
passive-interface Loopback0
network 192.0.2.1 0.0.0.0 area 0
exit
router bgp 65001
bgp router-id 10.255.0.1
no bgp default ipv4-unicast
neighbor 192.0.2.6 remote-as 65003
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.6 activate
network 10.255.0.1 mask 255.255.255.255
exit-address-family
endR2
hostname R2
ip cef
interface Loopback0
ip address 10.255.0.2 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.2 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.9 255.255.255.252
no shutdown
exit
router ospf 1
router-id 10.255.0.2
network 10.255.0.2 0.0.0.0 area 0
passive-interface Loopback0
network 192.0.2.2 0.0.0.0 area 0
exit
router bgp 65002
bgp router-id 10.255.0.2
no bgp default ipv4-unicast
neighbor 192.0.2.10 remote-as 65003
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.10 activate
network 10.255.0.2 mask 255.255.255.255
exit-address-family
endR3
hostname R3
ip cef
interface Loopback0
ip address 10.255.0.3 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.6 255.255.255.252
no shutdown
exit
interface GigabitEthernet2
ip address 192.0.2.10 255.255.255.252
no shutdown
exit
router bgp 65003
bgp router-id 10.255.0.3
no bgp default ipv4-unicast
neighbor 192.0.2.5 remote-as 65001
neighbor 192.0.2.9 remote-as 65002
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.5 activate
neighbor 192.0.2.9 activate
exit-address-family
endInspect the undesired exit
R1# show ip route 10.255.0.2
Routing entry for 10.255.0.2/32
Known via "bgp 65001", distance 20, metric 0
* 192.0.2.6, via GigabitEthernet2The direct physical path may be faster, but route-source preference makes R1 use R3. Administrative distance is local and differs from BGP LOCAL_PREF.
Mark the remote destination backdoor
router bgp 65001
address-family ipv4 unicast
network 10.255.0.2 mask 255.255.255.255 backdoor
exit-address-familyR2
router bgp 65002
address-family ipv4 unicast
network 10.255.0.1 mask 255.255.255.255 backdoor
exit-address-familyThe backdoor statement changes treatment of the specified BGP destination to the local/internal distance, normally 200. It does not originate that remote prefix as an ordinary network statement would.
Verify primary and fallback routes
R1# show ip route 10.255.0.2
Routing entry for 10.255.0.2/32
Known via "ospf 1", distance 110, metric 2
* 192.0.2.2, via GigabitEthernet1The IGP copy now wins installation. In the lab, shut the direct R1–R2 interface and wait for OSPF to withdraw; the external BGP candidate can then become the fallback.
interface GigabitEthernet1
shutdown
exitR1# show ip route 10.255.0.2
Routing entry for 10.255.0.2/32
Known via "bgp 65001", distance 200, metric 0
* 192.0.2.6, via GigabitEthernet2Restore the direct link and baseline
interface GigabitEthernet1
no shutdown
exitrouter bgp 65001
address-family ipv4 unicast
no network 10.255.0.2 mask 255.255.255.255 backdoor
exit-address-familyR2
router bgp 65002
address-family ipv4 unicast
no network 10.255.0.1 mask 255.255.255.255 backdoor
exit-address-familyThe saved baseline again prefers eBGP distance 20. Keep the backdoor setting instead when it is the intended operational policy. Always compare identical prefix lengths before comparing route-source preference.
Key Takeaways
- Backdoor changes local installation preference for a specified destination.
- Default eBGP distance 20 beats OSPF 110 in these examples.
- A backdoor destination normally uses distance 200.
- The statement does not originate the remote destination.
- An existing external path can remain as fallback.
Protocol and command references
Backdoor command reference · BGP specification · Router-symbol attribution.