BGP multihoming

Connecting to two providers is multihoming, and it brings a risk: your AS can become a transit AS, carrying internet traffic between the providers and consuming your bandwidth. A border router that learns one provider's routes over iBGP will offer them to the other unless a filter stops it. Advertise only locally generated routes. Then local preference decides your way out, which is yours to decide.

In Daveth Pro (Network)5 min video · lab: BGP policy

By , founder of Daveth · Updated

Opening frame of the video walkthrough of BGP multihoming

Watch this lesson

5 min · Video walkthrough

In Daveth Pro (Network)

The full 5 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C8: BGP policy

What the lab covers

What this page answers

How do you prevent your AS becoming a BGP transit AS?

Filter outbound so only locally generated routes are advertised to each provider, for example with a route map that permits only your own prefixes. Otherwise routes learned from one provider are advertised to the other. Read it in “The filter that has to exist”

What is BGP multihoming?

Connecting your network to two different internet service providers, for redundancy and to use the provider with the best path to a resource. Read it in “One provider, and it works”

One provider, and it works

You are adding a second provider for redundancy. Start with the one you have.

When you connect your network to two different internet service providers (ISPs), it is called multihoming. Multihoming provides redundancy and network optimization. It selects the ISP that offers the best path to a resource.

BR1 peers with PROV-A, and AS 65000 originates two prefixes, 10.1.0.0/16 and 10.2.0.0/16. What is BR1 offering PROV-A?

This course's output: BR1 toward PROV-A

BR1# show ip bgp neighbors 172.16.1.1 advertised-routes
BGP table version is 15, local router ID is 172.16.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop          Metric LocPrf Weight Path
*> 10.1.0.0/16   0.0.0.0                0         32768 i
*> 10.2.0.0/16   0.0.0.0                0         32768 i
! Proves what this router has advertised to that provider: if every row is one of our own prefixes, this AS is not offering it transit. Does not prove anything is transiting, or what the provider did with the routes. The table version and the rows are this page's own.

Two rows, both ours, each with next hop 0.0.0.0 and weight 32768. The layout is the command reference's own sample:

Not from this scenario: the Cisco IOS IP Routing: BGP Command Reference, show ip bgp neighbors

Device# show ip bgp neighbors 172.16.232.178 advertised-routes

BGP table version is 27, local router ID is 172.16.232.181
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop          Metric LocPrf Weight Path
*>i10.0.0.0      172.16.232.179         0    100      0 ?
*> 10.20.2.0     10.0.0.0               0         32768 i
Displays all routes that have been advertised to neighbors. An entry of 0.0.0.0 indicates that there are non-BGP routes in the path to the destination network.

That a prefix this AS originates prints next hop 0.0.0.0 is this course's reading of that field description. With one provider nothing is filtered, and nothing needs to be: there is nobody else to offer its routes to.

A second provider, for redundancy

BR2 peers with PROV-B. It already holds what PROV-A sent, learned from BR1 over iBGP through INT. Before reading on, decide what it offers PROV-B.

When you run BGP with more than one service provider, you run the risk that your autonomous system (AS) becomes a transit AS. This causes internet traffic to pass through your AS and potentially consume all the bandwidth and resources on the CPU of your router.

What is BR2 offering PROV-B now?

This course's output: BR2 toward PROV-B

BR2# show ip bgp neighbors 172.16.2.1 advertised-routes
BGP table version is 18, local router ID is 172.16.0.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop          Metric LocPrf Weight Path
*> 10.1.0.0/16   0.0.0.0                0         32768 i
*> 10.2.0.0/16   0.0.0.0                0         32768 i
*>i192.0.2.0/24  172.16.1.1             0    100      0 64500 i
*>i100.64.0.0/16 172.16.1.1             0    100      0 64500 64999 i

Our two prefixes, and two rows marked i with PROV-A's address as the next hop. Those are PROV-A's routes, and the next hop is the one it advertised:

For iBGP, the protocol states that the next hop that eBGP advertises must be carried into iBGP.

This course's reading: what each border router offers its provider

to        advertised  learned from the other provider
PROV-A    4           2
PROV-B    4           2

AS 65000 is offering a path between PROV-A and PROV-B

Two providers bought for resilience, and each one now offered a path to the other over links this business pays for.

So what is misconfigured? Nothing. Each border router advertises its best paths, which is what BGP does. With one provider there was nobody to offer those routes to, so nothing ever showed it. Some weeks later the uplinks are busy with traffic between two customers who are not yours.

This course's reading: what the field reported

reported from the field: traffic between CUST-A and CUST-B on both uplinks

It is easy to treat multihoming as a connectivity exercise. The connectivity is trivial: two sessions came up, and failover works. The work is in what you advertise, and the default actively creates the liability.

The filter that has to exist

The fix is in the same Cisco example.

The route-map localonly only allows the locally generated routes to be advertised to both of the service providers. In other words, they filter the internet routes from one service provider that go back to the other service provider. This prevents the risk your autonomous system becomes a transit AS for Internet traffic.

Not from this scenario: Cisco, Configure BGP with Two Different Service Providers: Router A, full table

Current configuration:

router bgp 300
 network 10.1.0.0
 network 10.2.0.0

 neighbor 10.10.10.10 remote-as 100
 neighbor 10.10.10.10 route-map localonly out

!--- Outgoing policy route-map that filters routes to service provider A (SP-A).

 neighbor 10.20.20.20 remote-as 200
 neighbor 10.20.20.20 route-map localonly out

!--- Outgoing policy route-map that filters routes to service provider B (SP-B).

end

ip as-path access-list 10 permit ^$

route-map localonly permit 10
 match as-path 10
This AS-Path access list only permits locally originated BGP routes:

Read the direction. route-map localonly out filters what Router A advertises, not what it accepts. ^$ matches an empty AS path, and only a route this AS originates has one.

This course's configuration: BR1, in the example's shape

BR1# configure terminal
BR1(config)# ip as-path access-list 10 permit ^$
BR1(config)# route-map localonly permit 10
BR1(config-route-map)# match as-path 10
BR1(config-route-map)# exit
BR1(config)# router bgp 65000
BR1(config-router)# neighbor 172.16.1.1 route-map localonly out
BR1(config-router)# end

BR2 gets the same, toward PROV-B. Both sessions are already up, and a policy change on a running session takes effect when the session is reset; which reset, and what it costs, is 1.5.f. After the reset, ask BR1 the first question again: what is it offering PROV-A?

This course's output: BR1 toward PROV-A

BR1# show ip bgp neighbors 172.16.1.1 advertised-routes
BGP table version is 18, local router ID is 172.16.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network          Next Hop          Metric LocPrf Weight Path
*> 10.1.0.0/16   0.0.0.0                0         32768 i
*> 10.2.0.0/16   0.0.0.0                0         32768 i

This course's reading: what each border router offers its provider

to        advertised  learned from the other provider
PROV-A    2           0
PROV-B    2           0

AS 65000 advertises only its own prefixes

And is that enough in every topology? Not claimed. The example says the filter prevents the risk in its own design, and this page does not widen that.

Outbound, which you decide

Everything else in a multihoming design is a mechanism this block already taught. Here is each one, with the lesson that taught it, and none is taught again:

This course's reading: the parts, and where each was taught

part                        direction             taught in
LOCAL_PREF                  outbound, decided     1.5.c.i
MED                         inbound, requested    1.5.b.i
AS path prepending          inbound, requested    1.5.d.i-ii
communities                 inbound, requested    1.5.c.iv
conditional advertisement   outbound, decided     1.5.c.ii-iii

Start with the one that is yours. 100.70.0.0/16 is reachable through both providers. Which way does each router leave for it?

This course's reading: which way each router leaves

router  to 100.70.0.0/16                  default route
BR1     via PROV-A                        no route
INT     not decided by the steps quoted   no route
BR2     via PROV-B                        no route

BR1 by PROV-A, BR2 by PROV-B: the same LOCAL_PREF, the same path length, and each prefers its own eBGP path. INT holds two iBGP paths that tie on every step this page quotes:

Prefer the path with the highest LOCAL_PREF. Prefer the path with the shortest AS_PATH. Prefer eBGP over iBGP paths.

Set LOCAL_PREF 200 on what BR1 learns from PROV-A.

Local preference is an indication to the AS about which path has preference to exit the AS in order to reach a certain network. The default value for local preference is 100. Unlike the weight attribute, which is only relevant to the local router, local preference is an attribute that routers exchange in the same AS.

This course's reading: which way each router leaves

router  to 100.70.0.0/16                  default route
BR1     via PROV-A                        no route
INT     via PROV-A                        no route
BR2     via PROV-A                        no route

All three leave by PROV-A, BR2 included, although BR2 has its own eBGP path: the LOCAL_PREF step comes before the other two. One setting on BR1, and the whole AS agrees.

And INT's own output? Not drawn. How INT reaches PROV-A's address inside the AS is not modelled here, so its exit is a reading rather than a command.

Conditional advertisement also decides what leaves, and when:

This feature is useful for multihomed networks, in which some prefixes are advertised to one of the providers only if information from the other provider is not present (this indicates a failure in the peering session or partial reachability). The conditional advertisement process is triggered by the BGP scanner process, which runs every 60 seconds.

So a backup advertisement can follow the loss of the other provider's routes by up to a minute. That arithmetic is this course's, and the feature is 1.5.c.ii-iii's.