BGP Conditional Advertisement
Introduction
In all the previous BGP posts, route advertisements have been static – you configure a network statement or redistribution, and the route is advertised continuously to configured neighbors. But what if you need advertisements to be dynamic, appearing and disappearing based on network conditions?
That’s what BGP Conditional Advertisement solves.
Conditional advertisement allows you to say: “Only advertise route X to neighbor Y if route Z exists in the BGP table” (or conversely, “if route Z does NOT exist”). This enables sophisticated scenarios like:
- Backup path advertisement: Advertise a backup route only when the primary fails
- Traffic engineering: Change advertisements based on upstream connectivity
- Multihoming policies: Advertise prefixes conditionally to different providers
- Disaster recovery: Automatically shift traffic during failures
The feature uses two key commands:
advertise-map: Specifies which routes to conditionally advertiseexist-mapornon-exist-map: Specifies the condition (route presence or absence)
Understanding Conditional Advertisement
The Concept
Traditional BGP advertisement:
Conditional advertisement:
Two Variants
exist-map (positive condition):
non-exist-map (negative condition):
The Processing Logic
The periodic re-evaluation means there’s a built-in delay – routes won’t appear/disappear instantly, but within the scan interval.
Lab Topology
Same topology from previous BGP posts:
- AS 2000: R7, R8, R9 (iBGP mesh, R9 is route reflector)
- R7: eBGP to R4 (AS 1000)
- R8: eBGP to R4 (AS 1000)
- R9: eBGP to R11 (AS 110)
- AS 110: R11
- AS 1000: R4
In this scenario:
- R9 receives routes 111.0.0.0/8 and 112.112.112.0/24 from R11 (AS 110)
- Both R7 and R8 receive these routes via iBGP and advertise them to R4
- We want R8 to advertise these routes to R4 only when R7 is unavailable
Example: Backup Path Advertisement
Requirement
R8 should advertise the 111.0.0.0/8 and 112.112.112.0/24 networks only if R7 is unreachable. R7 is unreachable if the 10.77.77.0/24 network is not reachable on R8.
Translation:
- Primary path: R7 advertises to R4 (preferred)
- Backup path: R8 advertises to R4 (only when R7 is down)
- Detection mechanism: Monitor presence of 10.77.77.0/24 in R8’s BGP table
This creates a clean failover: R4 sees routes via R7 normally, but if R7 fails (detected by absence of 10.77.77.0/24), R8 automatically takes over advertisement.
Configuration
R7 (advertise tracking network):
R7 advertises 10.77.77.0/24, which propagates via iBGP throughout AS 2000. This network serves as R7’s “heartbeat” – its presence signals R7 is operational.
R8 (conditional advertisement):
Breaking it down:
Prefix lists:
PL-MISSING: Matches the tracking route (10.77.77.0/24)PL-AMAP: Matches the routes to conditionally advertise (111.0.0.0/8 and 112.112.112.0/24)
Route maps:
MISSING: References PL-MISSING (the condition to check)AMAP: References PL-AMAP (the routes to advertise)
Conditional advertisement:
Why non-exist-map? We want R8 to advertise when R7 is DOWN. When R7 is up, 10.77.77.0/24 exists in R8’s BGP table (via iBGP). When R7 is down, 10.77.77.0/24 disappears. So we use non-exist-map – advertise when the tracking route is absent.
Initial State (Before Configuration)
R4 sees both paths:
R4 has two paths for both networks:
- Via R8 (192.1.48.8)
- Via R7 (192.1.47.7) – currently best
Both paths are available simultaneously. This is the problem – we want R8’s path to appear ONLY when R7 fails.
State 1: R7 Up and Running (Normal Operation)
After applying the conditional advertisement on R8:
R8 sees the tracking route:
R8 has 10.77.77.0/24 in its BGP table (via iBGP from R7, through route reflector R9). This means:
- Condition in
non-exist-map MISSING: FALSE (route exists, not non-existent) - Result: Do NOT advertise routes matched by AMAP to R4
R4 now sees only one path:
Perfect! R4 only sees the path via R7. The path via R8 is now suppressed by conditional advertisement.
State 2: R7 Down (Failure Scenario)
R7 goes offline (interface down, router failure, etc.).
R8 no longer sees the tracking route:
10.77.77.0/24 is gone from R8’s BGP table (R7 stopped advertising it). This means:
- Condition in
non-exist-map MISSING: TRUE (route does not exist) - Result: Advertise routes matched by AMAP to R4
R4 now sees the path via R8:
Excellent! R4 now only sees the path via R8. Automatic failover achieved!
State 3: R7 Returns (Recovery)
R7 comes back online and starts advertising 10.77.77.0/24 again.
R4 initially sees both paths:
Wait – why does R4 still see R8’s path? Shouldn’t the conditional advertisement suppress it immediately?
Answer: There’s a built-in delay. The conditional advertisement is evaluated periodically (default: 60 seconds). R7 has just come back up, but R8 hasn’t run its next conditional advertisement scan yet.
After a couple of minutes (next scan cycle):
Now R4 only sees R7’s path again. The conditional advertisement scan on R8 detected that 10.77.77.0/24 exists again, and R8 withdrew its advertisement to R4.
Result: Clean failback to primary path after recovery (with a delay).