Course contents

Module 5: Scaling and OperationsLesson 5.5 (5 of 7 in this module)35 of 43 in the BGP course

Next-hop tracking and the BGP scanner

Every BGP route depends on a next hop that must be reachable. When the IGP loses that next hop, how quickly does BGP notice? On modern IOS XE the answer is seconds, and the reason is a feature you never configured.

Advanced · 11 min read

You'll learn to explain why a BGP route needs a reachable next hop, describe the scanner and next-hop tracking, and read and tune the trigger delay.

A route is only as good as its next hop

Every path in the BGP table names a next hop, and the router must be able to reach that address through its routing table. If it cannot, the path is not valid and is not used. Inside an AS the next hop is usually the loopback of another router, reached over the IGP, so BGP convergence depends on the IGP.

NEXT_HOP: eBGP changes it, iBGP does not
NEXT_HOP: eBGP changes it, iBGP does notISP A advertises 203.0.113.0/24 to R1 over eBGP with next hop 192.0.2.1. R1 passes it to R2 over iBGP and by default leaves the next hop at 192.0.2.1, which R2 cannot reach. With next-hop-self, R1 sets the next hop to its own loopback 10.255.0.1.ISP AAS 64501R1AS 64500R2AS 64500eBGPiBGPNEXT_HOP 192.0.2.1set by ISP ADefault iBGP: NEXT_HOP stays 192.0.2.1R2 has no route to it, path not validWith next-hop-self on R1NEXT_HOP 10.255.0.1, R2 can reach itFix on R1: neighbor 10.255.0.2 next-hop-self

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The next hop is the address the router forwards packets to. A path whose next hop is unreachable is not valid, so it is never chosen as best.

That raises a question: when the IGP changes the route to a next hop, how does BGP find out? Two mechanisms answer it.

The BGP scanner: a periodic check

The original method is a scanner. A background process wakes up periodically (every 60 seconds by default) and walks the whole BGP table, checking each next hop against the routing table. It is simple but slow: a change just after a scan waits almost a full minute. During that time the router may keep forwarding to a next hop that no longer exists, or fail to use a better one. Traffic is black-holed or looped until the next scan.

Next-hop tracking: react to the event

Next-hop tracking removes the wait. The router registers the next-hop addresses it uses with the routing table. When one of those routes changes, BGP is told at once and schedules a next-hop scan after a short delay, 5 seconds by default. The delay lets a burst of IGP changes settle so BGP recalculates once instead of repeatedly.

Reacting to a next-hop change: scanner against tracking
Reacting to a next-hop change: scanner against trackingA next-hop route disappears at second 0. With only the periodic BGP scanner, which runs every 60 seconds, BGP may wait up to 60 seconds before it notices. With next-hop tracking, BGP schedules a scan about 5 seconds after the routing table change.0 s15 s30 s45 s60 snext-hop route lostScanner onlyup to 60 s of wrong or dead next hopNext-hop trackingabout 5 s

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Defaults on IOS XE: the BGP scanner runs every 60 seconds, and next-hop tracking waits 5 seconds after a routing table change before it recalculates. During the wait, traffic can still follow a dead next hop.
What happens when a next-hop route is lost
What happens when a next-hop route is lostFour steps from the IGP change to the new best path.IGP changeRoute to nexthop is removedNotifyRIB tells BGPimmediatelyDelayWait 5 s forchanges to settleRecalculateNew best path,RIB updated

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The sequence is event-driven. The scanner is not needed for this case.

After the walk, paths whose next hop is now unreachable lose the valid flag, the best-path algorithm picks another path, and the RIB is updated. The failed path stays in the table for a while but is not chosen.

Viewing and tuning it

Next-hop tracking is on by default, so a normal configuration does not mention it. It appears in the full running configuration.

show running-config all | include nexthop trigger

Privileged EXEC mode. Shows the defaults: bgp nexthop trigger enable and bgp nexthop trigger delay 5. These lines are hidden from a normal show running-config because they are default values.

router bgp 64500 address-family ipv4 unicast bgp nexthop trigger delay 2

R1. Shortens the wait before the scan from 5 to 2 seconds. A smaller value reacts faster but recalculates more often if the IGP is unstable. The value is in seconds.

Fast reaction or fewer recalculations
Fast reaction or fewer recalculationsThe delay trades speed for stability.Short delayFaster failoverMore recalculationif the IGP flapsLong delayCalmer under churnSlower failovervs

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The default suits most networks. Reduce it only when the IGP itself is stable and fast.

When a default route hides a lost next hop

If the router has a default route, it can resolve almost any next hop through it, and a next hop that really is gone still looks reachable. Traffic then follows the default route instead of the BGP path you expected. Cisco IOS XE lets you restrict which routes may be used to resolve next hops, with bgp nexthop route-map. Without it, make sure the IGP carries a specific route to each BGP next hop, usually a /32 loopback.

Technical reference: Cisco IOS XE BGP configuration guide, BGP next-hop tracking. Commands shown are the defaults on current IOS XE.

Check your understanding

Predict · scenario 1

With default settings, about how long after the IGP removes a next-hop route does BGP begin to recalculate?

Predict · scenario 2

A BGP neighbour stops sending keepalives but the IGP route to its loopback is unchanged. Does next-hop tracking react?

Predict · scenario 3

Where do you normally see bgp nexthop trigger delay 5?

FAQ

Is next-hop tracking on by default?
Yes. On current IOS XE the nexthop trigger is enabled with a delay of 5 seconds. You only configure it to change the delay or to turn it off.
Does next-hop tracking detect a dead BGP neighbour?
No. It reacts to changes in the routing table for next-hop addresses. A neighbour that fails without a routing change is still found by the hold timer or by BFD.
What does the 60 second scanner still do?
It periodically walks the BGP table for housekeeping and as a backstop. Next-hop tracking handles next-hop changes in the meantime.