Course contents

Module 3: Path SelectionLesson 3.13 (13 of 13 in this module)22 of 43 in the BGP course

Lab: primary and backup ISP

The company decides ISP A is primary. This lab applies the outbound and inbound techniques together, proves each one with a show command, and then breaks the primary link to see the backup work.

Advanced · 18 min read

You'll learn to apply local preference and AS path prepending to the course network, verify both with show commands on the right router, and prove failover and recovery.

The goal

Starting from the finished lab-ebgp-ibgp network, make ISP A the primary provider in both directions. Outbound traffic from both routers leaves through ISP A, other networks reach the company through ISP A, and everything moves to ISP B if the ISP A link fails.

Primary and backup ISP: before and after a failure
Primary and backup ISP: before and after a failureLeft: under normal conditions company traffic leaves through R1 and ISP A, and R2 sends its traffic across R1. Right: when the ISP A link fails, R1 withdraws that path and traffic leaves through R2 and ISP B.Normal: primary through ISP AISP A link down: backup through ISP BISP AAS 64501ISP BAS 64502R1LOCAL_PREF 200R2LOCAL_PREF 100downISP AAS 64501ISP BAS 64502R1LOCAL_PREF 200R2LOCAL_PREF 100

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

Green shows where company traffic leaves. The backup path was already in the BGP table, so failover needs no configuration change.

Step 1: outbound preference on R1

Step 1: outbound preference
Step 1: outbound preferenceSet local preference on R1 so it becomes the exit.Route mapset local-pref 200Apply inboundfrom ISP ARefreshreapply policy

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

Higher local preference wins.
route-map ISPA-IN permit 10 match ip address prefix-list PROVIDER-ONLY set local-preference 200 router bgp 64500 address-family ipv4 unicast no neighbor 192.0.2.1 prefix-list PROVIDER-ONLY in neighbor 192.0.2.1 route-map ISPA-IN in end clear ip bgp 192.0.2.1 soft in

R1. The route map replaces the inbound prefix list; PROVIDER-ONLY is used inside it as the match.

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R2#show ip bgp 203.0.113.0
BGP routing table entry for 203.0.113.0/24, version 11
Paths: (2 available, best #2, table default)
  64502
    192.0.2.5 from 192.0.2.5 (12.12.12.12)
      Origin IGP, metric 0, localpref 100, valid, external
  64501
    10.255.0.1 from 10.255.0.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 200, valid, internal, best
R2 now prefers R1's path with local preference 200, even though R2's own ISP B path is external. That is the result to expect: local preference is compared before eBGP over iBGP.

Step 2: inbound preference with prepending on R2

route-map ISPB-OUT permit 10 match ip address prefix-list COMPANY-ONLY set as-path prepend 64500 64500 64500 router bgp 64500 address-family ipv4 unicast no neighbor 192.0.2.5 prefix-list COMPANY-ONLY out neighbor 192.0.2.5 route-map ISPB-OUT out end clear ip bgp 192.0.2.5 soft out

R2. ISP B now hears a longer path to the company prefix.

Verify on ISP B, which in this lab you can log in to: show ip bgp 198.51.100.0 should show the AS path 64500 64500 64500 64500. On ISP A it should still show just 64500.

Step 2: inbound preference
Step 2: inbound preferencePrepend the AS path on R2 to make the path less attractive.Route mapprepend 64500 x2Apply outboundto ISP BCheckpath via R1 shorter

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

The remote network may prefer the shorter path through R1.

Step 3: test failover and recovery

interface GigabitEthernet0/0 shutdown

R1, interface to ISP A. Keep a ping to 203.0.113.1 running from the LAN side in another session.

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R1#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>  198.51.100.0     0.0.0.0                  0         32768 i
 *>i 203.0.113.0      10.255.0.2               0    100      0 64502 i
With ISP A down, the only remaining path to 203.0.113.0/24 is through R2 and ISP B, so R1 selects it. Expect a short pause while the BGP session is declared down. How long depends on the hold timer unless you tune it, which a later lesson covers.

Now run no shutdown and wait for the session to re-establish. R1 should return to ISP A because its local preference is 200, and outbound traffic moves back without any command from you.

Step 3: failover and recovery
Step 3: failover and recoveryShut a provider link and watch the path move.ShutdownISP A linkFailoverR2 path usedRestorepreferred path returns

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

Then restore it and confirm the preferred path returns.

Troubleshooting prompts

Local preference is 200 on R1 but R2 does not follow

Check show ip bgp neighbors 10.255.0.1 on R2 for a session in Established state, then look for a weight configured on R2's ISP B neighbour. A weight beats local preference. Remove it with no neighbor 192.0.2.5 weight.

The prepend is configured but ISP B shows only one 64500

The outbound route map has not been re-applied. Run clear ip bgp 192.0.2.5 soft out on R2. Also confirm the route-map sequence matches the prefix; a prefix list typo here makes the sequence match nothing and the implicit deny removes the route entirely.

After no shutdown, traffic stays on ISP B

The session may still be in Active or Idle. Check show ip bgp summary on R1. Once it is Established and ISP A's route returns, local preference 200 wins again.

Technical reference: Cisco, BGP best path selection algorithm. Output above is illustrative.

Check what you learned

Predict · scenario 1

After step 1, which router shows localpref 200 for the ISP A path?

Predict · scenario 2

Which router is configured to influence how other networks reach the company?

Predict · scenario 3

ISP A's link is shut. What does the company lose?

FAQ

Which router do I configure for each direction?
Outbound: R1 raises local preference on routes from ISP A. Inbound: R2 prepends its AS number when advertising to ISP B. Each change is made where the attribute is set, and the effect is checked on the other side.
Why test failover by shutting the interface?
A configured backup that has never been tested is a guess. Shutting the primary link shows the real convergence time and confirms the backup path was valid all along.