Course contents

Module 1: Communities and MultihomingLesson 1.4 (4 of 4 in this module)4 of 14 in the Advanced BGP course

Lab: ISP B as a conditional backup path

Prepending still tells the backup ISP about your prefix, so some traffic can arrive that way even when the primary works. This lab holds the prefix back completely, then proves that the backup switches on when the primary fails and off when it returns.

Advanced · 20 min read

You'll learn to configure advertise-map with non-exist-map on R2, confirm the withhold state, fail ISP A and watch the backup advertisement start, restore ISP A, and explain two ways the condition can fire when ISP A is healthy.

The goal

You are using the course network: the company AS 64500 has R1 connected to ISP A (AS 64501, neighbour 192.0.2.1) and R2 connected to ISP B (AS 64502, neighbour 192.0.2.5), with an iBGP session between R1 and R2 and the company prefix 198.51.100.0/24 behind them. ISP A sends its customer prefix 203.0.113.0/24. Both ISPs currently receive the company prefix from the first lab.

By the end, ISP B hears the company prefix only while the route 203.0.113.0/24 is missing from R2's BGP table. You will test that by failing ISP A on purpose, then find the two situations where the backup starts when it should not.

Diagram
The conditional advertisement lab: ISP B is the backup
The conditional advertisement lab: ISP B is the backup
The conditional advertisement lab: ISP B is the backupISP A connects to R1 and ISP B connects to R2 over eBGP. R1 and R2 share an iBGP session. ISP A sends the route 203.0.113.0/24 to R1 and R1 passes it to R2 over iBGP. R2 watches that route. While it is present, R2 does not advertise the company prefix 198.51.100.0/24 to ISP B. When it disappears, R2 advertises the company prefix to ISP B.ISP AAS 64501ISP BAS 64502R110.255.0.1R210.255.0.2203.0.113.0/24iBGP carries 203.0.113.0/24 to R2198.51.100.0/24, only on failureCondition on R2advertise 198.51.100.0/24 to ISP Bonly if 203.0.113.0/24 is missingCompany LAN198.51.100.0/24

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

R2 does not watch the ISP A link. It watches one route in its BGP table, so anything that removes that route, including an iBGP failure, switches the backup on.

Step 1: check the starting point

Conditional advertisement works with the BGP table, so confirm that both prefixes are in R2's table first: the watched route from ISP A through R1, and the company prefix that R2 will conditionally send.

Example output written for this lesson, not a router capture
R2#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 203.0.113.0/24   10.255.0.1               0    100      0 64501 i
 *>  198.51.100.0/24  0.0.0.0                  0         32768 i
The watched route is learned from R1 over iBGP, with next hop 10.255.0.1. The company prefix is local to R2. Both must be present: if the company prefix is missing from the table there is nothing to advertise, and if the watched route is missing the condition is true from the start.
Diagram
Lab order
Lab order

Check the table, add the two maps, confirm the withhold state, fail ISP A, then restore it.

  1. Checkboth prefixesin the table
  2. Configuretwo maps andthe condition
  3. Confirmstatus showsWithdraw
  4. Fail ISP Awatch itswitch on
  5. Restorewatch itswitch off
Each step has a check. Do not move on if the check fails.

Step 2: configure the condition on R2

Diagram
The two halves of the neighbour command
The two halves of the neighbour command

The advertise-map names what is sent to ISP B, which is the company prefix. The non-exist-map names the route that must be missing for the sending to start, which is the prefix from ISP A.

advertise-mapWhat goes to ISP B198.51.100.0/24
non-exist-mapWhat must be missing203.0.113.0/24
One prefix list feeds each half. Swapping the two halves reverses the behaviour.

Two prefix lists name the routes. The watched list holds the route whose absence means ISP A has failed. The advertised list holds the company prefix. Two route maps connect the lists to the neighbour command on R2.

ip prefix-list WATCH-ISPA seq 10 permit 203.0.113.0/24 ip prefix-list COMPANY-ONLY seq 10 permit 198.51.100.0/24 route-map ADVERTISE-COMPANY permit 10 match ip address prefix-list COMPANY-ONLY route-map ISPA-GONE permit 10 match ip address prefix-list WATCH-ISPA router bgp 64500 address-family ipv4 unicast neighbor 192.0.2.5 advertise-map ADVERTISE-COMPANY non-exist-map ISPA-GONE

R2. advertise-map names what is sent when the condition is true. non-exist-map names the route whose absence makes it true. If R2 already has an outbound prefix-list or route map toward ISP B, it must still permit 198.51.100.0/24; the condition decides when the prefix may go, not whether the outbound filter allows it.

A neighbour needs a soft refresh to apply the new policy. Send one, then read the state.

clear ip bgp 192.0.2.5 soft out

R2. Asks R2 to run its outbound policy for ISP B again without closing the session. The command prints nothing on success.

Example output written for this lesson, not a router capture
R2#show ip bgp neighbors 192.0.2.5 | include Condition
  Condition-map ISPA-GONE, Advertise-map ADVERTISE-COMPANY, status: Withdraw
Withdraw means the watched route exists, so the company prefix is withheld. This is the normal state while ISP A works.
Example output written for this lesson, not a router capture
R2#show ip bgp neighbors 192.0.2.5 advertised-routes
Total number of prefixes 0
ISP B receives nothing from R2. With the primary working, no traffic should enter through ISP B.

Step 3: fail ISP A

On R1, close the session to ISP A. A shutdown stands in for a provider failure, and it removes the watched route quickly. Then wait: R1 withdraws the route from R2 at once, but R2 acts on it at the next condition check.

router bgp 64500 neighbor 192.0.2.1 shutdown

R1. This closes the session to ISP A and withdraws 203.0.113.0/24. Use no neighbor 192.0.2.1 shutdown to restore it.

Example output written for this lesson, not a router capture
R2#show ip bgp 203.0.113.0
% Network not in table
The watched route is gone. Check this before you wait for the condition: if a path still shows here, the condition cannot fire, and that path is the next thing to explain.
Example output written for this lesson, not a router capture
R2#show ip bgp neighbors 192.0.2.5 | include Condition
  Condition-map ISPA-GONE, Advertise-map ADVERTISE-COMPANY, status: Advertise
After the check interval the status changes to Advertise. Read it repeatedly until it does, and note how long it took.
Example output written for this lesson, not a router capture
R2#show ip bgp neighbors 192.0.2.5 advertised-routes
     Network          Next Hop            Metric LocPrf Weight Path
 *>  198.51.100.0/24  0.0.0.0                  0         32768 i

Total number of prefixes 1
R2 now advertises the company prefix to ISP B. On ISP B the route appears with the path 64500, and inbound traffic starts to use the backup.
Example output written for this lesson, not a router capture
ISP-B#show ip bgp 198.51.100.0
BGP routing table entry for 198.51.100.0/24, version 8
Paths: (1 available, best #1, table default)
  64500
    192.0.2.6 from 192.0.2.6 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
The provider side confirms the result, which is the test that counts: the condition status is local to R2, and the provider's table shows whether the route reached it.
Diagram
What happens, in order, after the ISP A failure
What happens, in order, after the ISP A failure

The session closes, R1 withdraws the route, R2 notices at the next check, R2 advertises to ISP B, and ISP B starts to send traffic in.

  1. ISP A session closesR1 stops receiving 203.0.113.0/24Route withdrawn from R2 over iBGP
  2. R2 waits for its checkStatus still Withdraw until the next scanUp to the scan interval, 60 seconds by default on many releases
  3. Status becomes AdvertiseR2 sends an UPDATE for 198.51.100.0/24ISP B installs it
  4. Traffic arrives by ISP BInbound flows follow the new pathProvider caches and policy add their own delay
The wait for the next check is the largest part of the delay, so measure it instead of assuming it.

Step 4: restore ISP A

Remove the shutdown on R1 and watch the reverse. The session returns, the route reappears on R2, and the next check changes the status back to Withdraw. R2 then withdraws the company prefix from ISP B, and traffic returns to the primary path.

router bgp 64500 no neighbor 192.0.2.1 shutdown

R1. The session needs time to reach Established and for the route to cross to R2. Read the status again afterwards, not immediately.

Diagram
What happens, in order, after ISP A returns
What happens, in order, after ISP A returns

The session reaches Established, the route crosses to R2, R2 waits for its next check, and then the status returns to Withdraw so ISP B stops receiving the company prefix.

  1. ISP A session returnsSession reaches EstablishedR1 learns 203.0.113.0/24 again
  2. Route crosses to R2iBGP carries the route overR2 table has the watched route
  3. R2 waits for its checkStatus still Advertise until the next scanISP B still carries inbound traffic
  4. Status returns to WithdrawR2 withdraws the company prefixInbound traffic returns to ISP A
Both paths carry inbound traffic until the status returns to Withdraw.

Record the two times, failure to Advertise and restore to Withdraw. They are your design numbers: they say how long the company is without inbound service when ISP A fails, and how long the backup carries traffic after ISP A returns.

Worked example: how long is the company without inbound service?

The lab uses a shutdown, which is the kindest failure there is. R1 closes the session itself, so R1 knows at once. A real provider failure often leaves the session looking healthy until a timer runs out. The delay before the backup switches on is the detection time plus the wait for the next condition check, so it depends on how the failure happens.

Read the timers that apply to the ISP A session before you do the arithmetic.

Example output written for this lesson, not a router capture
R1#show ip bgp neighbors 192.0.2.1 | include hold time
  Last read 00:00:21, last write 00:00:21, hold time is 180, keepalive interval is 60 seconds
The session uses a 180-second hold time with keepalives every 60 seconds. These are the usual Cisco defaults, but the value in use is the lower of what the two sides offer, so read it from the session rather than assuming it.
Diagram
Time until ISP B receives the company prefix (computed)
Time until ISP B receives the company prefix (computed)
How ISP A failsR1 notices afterWait for next checkBest totalWorst total
Lab shutdown on R10 s0 to 60 s0 s60 s
Silent failure, hold time 180 s, keepalives every 60 s120 to 180 s0 to 60 s120 s240 s
Silent failure with BFD, 300 ms interval, multiplier 30.9 s0 to 60 s0.9 s60.9 s
Assumed values: a 60-second condition check, the hold time shown above and a BFD session that the provider supports on the circuit. A silent failure is noticed 120 to 180 seconds after it starts, because the hold timer restarts with each keepalive. Check your release for the real check interval.

The second row is the number to put in a design review. With default timers, inbound traffic can be missing for up to four minutes before the backup path carries anything, and the shutdown test of this lab alone would have suggested one minute at most. Faster detection (BFD, if the provider supports it on the circuit) shrinks the middle column. Nothing shortens the check interval except what your release allows, so read its documentation before you promise a figure.

The worst case suits a design review, but a typical failure lands between the best and worst case. The table repeats the arithmetic for other ways of noticing the failure and adds the average, with the 60-second check as before.

Diagram
Average and worst case by detection method (computed)
Average and worst case by detection method (computed)
How the failure is noticedAverage totalWorst totalDetection rangeCheck wait, share of average
Hold 180 s, keepalives 60 s (defaults)180 s240 s120 to 180 s17 percent
Hold 90 s, keepalives 30 s105 s150 s60 to 90 s29 percent
Hold 30 s, keepalives 10 s55 s90 s20 to 30 s55 percent
BFD, 300 ms interval, multiplier 330.9 s60.9 s0.9 s97 percent
Computed by script and checked against a simulation of 200,000 random failures. Assumed values: a 60-second condition check, keepalives at one third of the hold time, and a failure that starts at a random moment in both the keepalive cycle and the check cycle. Very short BGP timers cost stability on a noisy circuit, and BFD needs provider support on the circuit. Read the real values from your release and your provider.

Once detection is fast, the check wait is almost the whole delay: with BFD it is 30 of the 30.9 seconds on average. At that point faster detection buys nothing, and only a shorter check interval would help, if the release allows one.

The return trip has the same shape. After ISP A comes back, the session needs time to reach Established and for the route to cross to R2, and then the next check turns the status back to Withdraw. Until it does, ISP B still carries inbound traffic. Measure that too, because it decides how long both paths are in use.

Step 5: two false alarms

The condition watches a route, not a link. Two events that are not an ISP A failure can remove the watched route from R2's table. In both, the company prefix goes out to ISP B while ISP A is healthy, and inbound traffic splits across both providers.

Diagram
Two ways to trigger the backup by mistake
Two ways to trigger the backup by mistake

The iBGP session between R1 and R2 fails, or an inbound filter on R1 stops accepting the watched route. In both cases R2 stops seeing the route even though ISP A is fine.

iBGP session lostR1 to R2 failsR2 loses the routeISP A is healthy
Filter or policy changeR1 stops accepting203.0.113.0/24ISP A is healthy
Test both in the lab, and watch for them in production.

To see the first one, shut the iBGP neighbour on R1 and read the condition status on R2 after the check interval. It changes to Advertise although the ISP A session stays Established. The fix is design, not a command: watch a route that only disappears when ISP A fails, keep the iBGP session redundant, and alert on the condition status so a switch-on is noticed.

Troubleshooting prompts

Diagram
Three symptoms, three first checks
Three symptoms, three first checks

If the status stays Withdraw while ISP A is down, look for a remaining path to the watched route. If the status shows Advertise but ISP B has nothing, check the outbound policy toward ISP B. If the prefix is still sent after the status returns to Withdraw, look for another source advertising it.

Condition looks wrong
  • Stays WithdrawISP A is down, buta path to the route remains
  • Advertise, nothing sentstatus is true, butISP B has no route
  • Still sentstatus is Withdraw, butthe prefix is still out
The condition status only says whether the condition is true. The other policies are checked separately.
The status stays Withdraw although ISP A is down

Run show ip bgp 203.0.113.0 on R2. If any path remains, the condition is false. Look at where it came from: ISP B may also advertise the watched prefix, or a stale iBGP copy may remain. Watch a route that only the primary provides, or remove the other source of it.

The status shows Advertise but ISP B has no route

Check that 198.51.100.0/24 is in R2's BGP table, that the advertise-map matches it exactly, and that no outbound prefix list or route map toward ISP B denies it. The status says the condition is true, not that the route passed every other policy.

The prefix is still advertised after the status returns to Withdraw

Check the status again after a scan interval, then read advertised-routes. If the prefix is still sent, an unconditional route or an extra network statement is advertising it outside the map.

Technical reference: Cisco, BGP conditional advertisement. Output above is an example written for this lesson.

Check what you learned

Predict · scenario 1

The status shows Withdraw. What does that mean for ISP B?

Predict · scenario 2

You fail ISP A and the status still shows Withdraw after ten seconds. What is the most likely reason?

Predict · scenario 3

The iBGP session between R1 and R2 fails while ISP A is healthy. What happens to the condition?

Predict · scenario 4

ISP A fails silently with a 180-second hold time and keepalives every 60 seconds. The condition check is 60 seconds. What is the worst case before ISP B receives the company prefix?

Predict · scenario 5

Why does the lab's shutdown test understate the real outage?

Predict · scenario 6

With BFD detecting at 0.9 seconds and a 60-second condition check, what is the best case and the worst case?

Predict · scenario 7

A silent failure uses a 180-second hold time with keepalives every 60 seconds, and the condition check is 60 seconds. On average, how long until ISP B receives the company prefix?

Predict · scenario 8

BFD detects the failure in 0.9 seconds and the condition check stays at 60 seconds. Which change would shorten the average delay most?

Predict · scenario 9

The status shows Advertise, but ISP B has no route for the company prefix. Which check comes first?

FAQ

Why does the backup take up to a minute to switch on?
The condition is checked on a scan interval, which is 60 seconds by default on many releases. After the watched route disappears, the router waits for the next check before it advertises. Read your release for the interval and for any way to shorten it, and add that delay to your recovery time.
Does the condition watch the ISP A link?
No. It watches one route in R2's BGP table. A failure of the ISP A session removes that route, but so does a failure of the iBGP session between R1 and R2. The router cannot tell the two apart.
Why not use exist-map instead?
An exist-map advertises while the watched route is present. A non-exist-map advertises while it is missing. For a backup that switches on at failure, non-exist-map is the match, because the failure is the route going away.