BGP MASTERCLASS · CHAPTER 7

Best path, BFD and BGP backdoor

Make BGP detect the failure of an indirect link in milliseconds, take a prefix out of BGP with a backdoor, and learn to think like the router that picks the best path.

13 min readVideos: Day 2, parts 6 and 7Level: intermediate

From point A to point B

Point A: your BGP network works, but a failure between two routers can leave you sending traffic nowhere for three minutes, and when BGP picks a route you can't explain why. Point B: you detect the failure in milliseconds with BFD, you take a prefix out of BGP with a backdoor when an IGP has a better path, and you walk through the best path algorithm step by step.

What you will see
  1. Why an indirect link leaves BGP waiting for the 180-second hold time.
  2. BFD with bfd interval 50 min_rx 50 multiplier 3 and neighbor … fall-over bfd.
  3. BGP backdoor with EIGRP 100: administrative distances 20, 90 and 200, and RIB-failure.
  4. The best path algorithm with the N WLLA OMNI rule and its tie-breakers.
  5. Why BGP doesn't load-balance by default and what maximum-paths does.

Ticket 7: the indirect link

Ticket 7 says: “R3 must converge in 50 ms with R4 in case of an indirect link failure.”

Picture R4 in Panama and R3 in a lab in the United States. There is no fiber running from one rack to the other. In between there are switches, transport and provider equipment. Between two BGP routers there is always an indirect link.

If the fiber fails inside Panama, the nearest switch is the one that notices. R3's interface stays up, because its side of the cable didn't change. For R3, the neighbor is still there.

180 seconds of waiting

When does BGP find out? When the hold time expires. On Cisco the keepalive is 60 seconds and the hold time is 180. If no KEEPALIVE or UPDATE arrives within 180 seconds, the router declares the neighbor dead and closes the session with a NOTIFICATION.

! default timers: keepalive 60 s, hold time 180 s
R3# show ip bgp summary
R3# show ip bgp neighbor
! R4 shuts its interface toward R3
R4(config)# interface GigabitEthernet0/0
R4(config-if)# shutdown
R4# show ip bgp summary
! R3 still shows the session up until the hold time expires
R3# show ip bgp summary
R3# show ip bgp

In the demo, Jesús shuts R4's interface toward R3. R4 goes to Idle instantly: for R4 the failure is direct. R3, on the other hand, doesn't flinch. The session stays Established, the counter keeps going up, and 40.40.40.0 is still best through 172.16.4.4. Wireshark shows TCP retransmissions and, at the end, the NOTIFICATION with hold time expired.

Why does it matter? R4 no longer sends traffic over that link, but R3 does. If other AS use R3 to reach 40.40.40.0, that traffic is lost for three minutes. Today 30 seconds is already a significant outage; three minutes is a lot of money lost.

BFD: failure in milliseconds

Bidirectional Forwarding Detection (BFD, RFC 5880) is a failure-detection protocol. It works at the interface level, sends control packets very fast and is independent of the routing protocol: once configured, you tie it to OSPF, EIGRP or BGP. BGP hands detection over to it and no longer depends on its 180 seconds.

! R4: BFD on the interface toward R3, then BGP uses it
R4(config)# interface GigabitEthernet0/0
R4(config-if)# bfd interval 50 min_rx 50 multiplier 3
R4(config-if)# exit
R4(config)# router bgp 64100
R4(config-router)# neighbor 172.16.4.3 fall-over bfd
! R3: the same on the other end
R3(config)# interface GigabitEthernet0/1
R3(config-if)# bfd interval 50 min_rx 50 multiplier 3
R3(config-if)# exit
R3(config)# router bgp 1.1
R3(config-router)# neighbor 172.16.4.4 fall-over bfd
R3# show bfd summary
R3# show bfd neighbors

bfd interval 50 min_rx 50 multiplier 3 means: I send every 50 ms, I expect to receive every 50 ms, and if three packets in a row are lost, I declare the neighbor down. With these values, detection takes about 150 ms.

A detail you see in the class: with BFD only on the interfaces, show bfd neighbors shows nothing. The BFD session appears when a protocol asks for it. As soon as R4 has neighbor 172.16.4.3 fall-over bfd, Wireshark shows the BFD control messages: first the Init state and then Up, with one packet every 50 ms. Then R3 does the same toward 172.16.4.4.

R4(config)# interface GigabitEthernet0/0
R4(config-if)# shutdown
! R3 drops the session in milliseconds
R3# show ip bgp summary
R3# show ip bgp
R3# traceroute 40.40.40.40 source 30.30.30.30 ttl 1 5

The test is repeated: shutdown on R4's interface. This time the BFD session goes down and takes BGP with it. On R3, show ip bgp summary shows the neighbor in Idle immediately, show ip bgp has 40.40.40.0 through 172.16.2.1, and the traceroute from 30.30.30.30 goes down through R1 and R2 to R4. In milliseconds, with no intervention.

Configure both ends. BFD is bidirectional: each router needs the values on its interface and fall-over bfd on its BGP neighbor. Verify with show bfd summary and show bfd neighbors.

Ticket 12: one hop for VIP customers

Ticket 12 says: “R3 must be able to use the 172.16.7.0 segment with EIGRP to reach the 60.60.60.60 prefix.” The story: the company bought a 100 Gb link that connects R6 directly to R3. The 60.60.60.0 network belongs to VIP customers and must use that link, on one condition: the solution must stay outside BGP.

The starting point is bad. The traceroute from R3 (source 30.30.30.30) to 60.60.60.60 goes through R1, R2, R4 and R5 before reaching R6. Five hops when the direct cable gives one.

R3# traceroute 60.60.60.60 source 30.30.30.30 ttl 1 5
R3(config)# router eigrp 100
R3(config-router)# network 172.16.7.0 0.0.0.255
R3# show ip eigrp neighbors
R3# ping 172.16.7.6
R3# show ip route
R3# show ip eigrp topology

First, EIGRP 100 is enabled on the 172.16.7.0/24 segment. R6 already had it configured and advertises 60.60.60.0. The adjacency comes up and the ping to 172.16.7.6 answers. But show ip route still shows 60.60.60.0 as a BGP route. Why?

Because when the same prefix arrives through two protocols, with the same length, the routing table breaks the tie with the administrative distance. It's basic CCNA routing: the lowest value wins. And eBGP (20) beats EIGRP (90).

network backdoor and administrative distance

Route sourceAdministrative distance
Connected · static0 · 1
eBGP20
Internal EIGRP90
OSPF110
iBGP · local BGP · backdoor200

The network … backdoor command marks a prefix learned through eBGP as a “back door” route. BGP gives it distance 200, like a local route, and the IGP wins. Jesús describes it as a script that tells the route: “you used to be worth 20; now you're worth 200.”

R3(config)# router bgp 1.1
R3(config-router)# network 60.60.60.0 mask 255.255.255.0 backdoor
! 60.60.60.0/24 now comes from EIGRP (90); BGP shows it as RIB-failure (r)
R3# show ip route
R3# show ip bgp
R3# traceroute 60.60.60.60 source 30.30.30.30 ttl 1 5

You read the result in three places:

  • show ip route: 60.60.60.0 is now an EIGRP D route, distance 90, through 172.16.7.6.
  • show ip bgp: the route is still in BGP, but marked r, RIB-failure. BGP has it, but another protocol installed it in the routing table.
  • The traceroute reaches 60.60.60.60 in a single hop.
BGP backdoor: long eBGP path versus a direct EIGRP link R3 in AS 1.1 and R6 in AS 1.2, sub-AS 64300, which advertises 60.60.60.0/24. On top, the eBGP path from R3 to R6 goes through R1, R2, R4 and R5: five hops, administrative distance 20. At the bottom, the direct link 172.16.7.0/24 runs EIGRP 100, administrative distance 90. Before the backdoor, the routing table of R3 installs the eBGP route because 20 is lower than 90. With network 60.60.60.0 mask 255.255.255.0 backdoor under router bgp 1.1, the eBGP route gets distance 200, EIGRP wins with 90, BGP marks the route as RIB-failure and traceroute reaches 60.60.60.60 in one hop. R1 AS 100 R2 AS 200 R4 AS 1.2 R5 AS 1.2 eBGP path · AD 20 · 5 hops R3 · AS 1.1 30.30.30.0/24 R6 · AS 1.2 60.60.60.0/24 172.16.7.0/24 · EIGRP 100 direct link · AD 90 · 1 hop BEFORE B 60.60.60.0/24 [20/0] via 172.16.2.1 eBGP 20 < EIGRP 90: BGP route installed traceroute: R1 · R2 · R4 · R5 · R6 AFTER · NETWORK … BACKDOOR D 60.60.60.0/24 [90/…] via 172.16.7.6 eBGP route raised to 200: EIGRP 90 wins show ip bgp: r (RIB-failure) · 1 hop router bgp 1.1 · network 60.60.60.0 mask 255.255.255.0 backdoor The backdoor network is not advertised and best path selection does not change: only the distance does.

Before the backdoor, R3 installs the eBGP route (distance 20) and traffic takes five hops. With network 60.60.60.0 mask 255.255.255.0 backdoor, the eBGP route goes to 200 and EIGRP (90) wins over the direct link. Diagram: The House of Routing.

According to Cisco's command reference, a backdoor network is treated as local but is not advertised, and the best path algorithm doesn't change. The backdoor only acts on the distance, which lives in the routing table. That's why Jesús solved this ticket before the theory: to make it clear that administrative distance doesn't appear in BGP. And remember that the backdoor only affects that prefix on that router: return traffic toward 30.30.30.0 needs its own backdoor on R6.

The best path with N WLLA OMNI

When BGP has several paths to the same prefix, it picks one. Jesús uses a mnemonic he learned years ago: N WLLA OMNI. Each letter is a step, in order.

The BGP best path ladder: N WLLA OMNI and the tie-breakers A staircase of steps that BGP walks in order until one of them breaks the tie. N: the next hop must be reachable, a prerequisite. W: highest weight, Cisco-specific and local. L: highest local preference, default 100. L: prefer locally originated paths from network, redistribute or aggregate. A: shortest AS_PATH. O: lowest origin, IGP before EGP before incomplete. M: lowest MED, compared within the same neighbor AS. N: eBGP over iBGP. I: lowest IGP metric to the next hop. Then the multipath check with maximum-paths, default 1, and the tie-breakers: oldest eBGP path, lowest router ID, shortest cluster list and lowest neighbor address. In W and L the highest value wins; from A down, the lowest or shortest wins. N WLLA OMNI · CISCO ORDER first step that differs decides N NEXT HOP must be reachable (recursive lookup) prerequisite W WEIGHT Cisco-specific, local to the router highest L LOCAL_PREF default 100, shared inside the AS highest L LOCALLY ORIGINATED network · redistribute · aggregate local first A AS_PATH AS-path prepend acts here shortest O ORIGIN i (IGP) < e (EGP) < ? (incomplete) lowest M MED compared within the same neighbor AS lowest N NEIGHBOR TYPE eBGP over iBGP eBGP I IGP METRIC IGP metric to the BGP next hop lowest · MULTIPATH maximum-paths (default 1) check · OLDEST eBGP PATH first received wins, less flapping oldest · ROUTER ID originator ID with route reflectors lowest · CLUSTER LIST route reflector environments only shortest · NEIGHBOR ADDRESS IP used in the neighbor command lowest W, L: highest wins · from A down: lowest or shortest wins Orange: prerequisite · green: higher wins · blue: lower wins · brown: tie-breakers

The best path ladder: BGP compares step by step and stops at the first one that breaks the tie. Diagram: The House of Routing.

  • N, valid next hop. More a requirement than a step. It isn't enough for the attribute to carry a next hop: the router must reach it through recursion. Otherwise the route doesn't even enter the algorithm.
  • W, weight. Higher is better. It's Cisco-specific and local to the router: it isn't advertised to anyone.
  • L, local preference. Higher is better. Default 100; in the previous chapter you raised it to 500.
  • L, locally originated. The route the router itself originated with network, redistribute or aggregate-address is preferred.
  • A, AS_PATH. Shorter is better. Since weight and local preference are rarely touched, in practice this is usually the attribute that decides. That's why prepend works.

The rule to remember: in W and L the highest value wins; from A down, the lowest or shortest wins.

Origin, MED, neighbor type and tie-breakers

  • O, origin. IGP (i) is better than EGP (e), and EGP is better than incomplete (?). The i comes from the network command; the ? usually comes from redistribution. EGP is the protocol that existed before BGP: you won't see it. That's why the class recommends advertising with network.
  • M, MED (multi-exit discriminator). Lower is better. It's rarely used, and by default it's only compared between routes from the same neighboring AS.
  • N, neighbor type. eBGP is preferred over iBGP. This has nothing to do with administrative distance (20 or 200), which lives in the routing table. In show ip bgp you see it in the “i” on the left, the one for internal routes.
  • I, IGP metric to the next hop. Lower is better: the closest next hop according to the IGP.

If everything is still equal, Cisco's official order ends with the tie-breakers:

StepPreferred
MultipathIf maximum-paths allows it, several routes are installed in the table
Oldest eBGPBetween two external routes, the one received first (avoids flapping)
Router IDThe lowest router ID (with a route reflector, the originator ID)
Cluster listThe shortest cluster list (route reflector only)
Neighbor addressThe lowest neighbor IP

In the class, Jesús names these tie-breakers and wonders whether the route reflector one goes among them. Cisco's documentation places it right before the last one: router ID, then the cluster list and finally the neighbor IP.

Why BGP doesn't load-balance

If everything ends up tied, does BGP share the traffic? Not by default. The BGP multipath value is 1: a single route in the routing table.

Equal-cost load balancing needs three things:

  1. The routes must tie on weight, local preference, AS_PATH length, origin, MED and IGP metric to the next hop.
  2. They must come from the same neighboring AS, for example over two circuits to the same provider.
  3. You must configure maximum-paths with a value greater than 1 in the BGP process (for iBGP, maximum-paths ibgp).

Multipath doesn't change the best path: the router still picks one best route, and it's the only one it advertises to its neighbors. And if you want to “load-balance across different autonomous systems”, Jesús is clear: that doesn't exist by default. Work with your attributes: local preference for what leaves, prepend or MED for what comes in.

With these tickets the 2nd Marathon closes 8 of 12: 1 through 7, and 12. Summarization and communities (tickets 8 to 11) are left for the Day 3 ticket workshop.

Class videos

These are the two parts of the 2nd BGP Marathon that go with this chapter. Jesús recorded them live on March 6, 2021, with Cisco IOSv routers in GNS3. The audio is in Spanish, with subtitles in Spanish, English, French and Portuguese.

Recorded live; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 2 playlist on YouTube

Test what you learned

1. The fiber between R3 and R4 fails, but R3's interface stays up. Without BFD, how long does R3 take to close the session with Cisco's default values?

Answer. Up to 180 seconds, the hold time. Only then does it send a NOTIFICATION for hold time expired and withdraw that neighbor's routes.

2. You configure bfd interval 50 min_rx 50 multiplier 3 on both interfaces, but show bfd neighbors is still empty. What's missing?

Answer. A client protocol that uses BFD. In BGP it's neighbor … fall-over bfd on both routers. Then the BFD session goes from Init to Up.

3. R3 learns 60.60.60.0 through eBGP and through EIGRP. Which one goes into the routing table, and what changes with network 60.60.60.0 mask 255.255.255.0 backdoor?

Answer. Without backdoor, the eBGP route is installed (20 versus 90). With backdoor, the eBGP route goes to 200 and the EIGRP route is installed. In BGP the route shows as RIB-failure.

4. Two routes to the same prefix have the same weight and the same local preference, neither is local, and one has a shorter AS_PATH. Which one wins?

Answer. The one with the shorter AS_PATH. It's step A of N WLLA OMNI and, in practice, the one that decides most often.

5. R4 receives the same prefix from two different autonomous systems, tied on everything. Does BGP load-balance?

Answer. No. By default multipath is 1, and even with maximum-paths the routes must come from the same neighboring AS. It picks one through the tie-breakers.

Key takeaways

  • There is always an indirect link between BGP routers; without help, BGP waits for the 180-second hold time.
  • BFD detects the failure in milliseconds: bfd interval on the interface and neighbor … fall-over bfd in BGP, on both ends.
  • Administrative distance lives in the routing table: eBGP 20, EIGRP 90, OSPF 110, iBGP 200.
  • network … backdoor raises the eBGP route to 200 so the IGP wins; BGP marks it as RIB-failure.
  • N WLLA OMNI: valid next hop, weight, local preference, locally originated, AS_PATH, origin, MED, neighbor type and IGP metric to the next hop.
  • Then come multipath, oldest eBGP, router ID, cluster list and neighbor IP.
  • BGP doesn't load-balance by default: it needs a tie, the same neighboring AS and maximum-paths.

Official resources

Source and credits. Chapter written from the BGP Masterclass that Jesús Espinoza recorded live in 2021. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical details and configuration were checked against official Cisco documentation and IETF RFCs.

Navigate