In part 1 we put BGP in context as the protocol that ties together the autonomous systems of the internet. Now let’s bring it down to your world: a company with branches, a data center, two providers and workloads in the cloud. The question is no longer “what is BGP?” but “do I actually need it?”.
When I configure an eBGP peering with an ISP, bringing up the session is rarely the hard part. The hard part is deciding what you advertise, what you accept and where traffic enters and leaves. That’s what you take away today: judgment, attributes and filters, with Cisco IOS commands.
When does a company need BGP (and when doesn’t it)?
Let me start with the honest answer: many companies don’t need BGP. If you have a single provider, a default route toward it solves the problem. The ISP advertises your addresses inside its own AS and you have nothing else to manage.
- One ISP, one link:
ip route 0.0.0.0 0.0.0.0 203.0.113.1 - One ISP, two links: add a floating static route, with a higher administrative distance, that only kicks in if the primary fails:
ip route 0.0.0.0 0.0.0.0 198.51.100.1 250
RFC 1930 (BCP 6) puts it bluntly: you only need an AS when your routing policy differs from your neighbors’. A single-homed site shares the policy of its ISP’s other customers, so its prefix belongs inside the provider’s AS.
BGP comes into play when one of these needs shows up:
- Multihoming: you connect to two or more ISPs and want your prefixes to stay reachable if one fails. RFC 1930 calls it “almost the only case” in which an operator should create its own AS.
- Traffic control: you want to decide which provider each flow uses to leave and to come back.
- Private cloud connectivity: AWS, Azure and Google Cloud exchange routes with you over BGP on their dedicated links.
Do you need your own ASN and PI space, or is PA enough?
Real multihoming takes two pieces: an AS number and an address block you can advertise through both providers.
- PA space (provider aggregatable): your ISP assigns it from its own block. It’s simple, but if you switch providers you have to renumber.
- PI space (provider independent): the regional internet registry (RIR) assigns it to you directly. It’s portable: you advertise it with your ASN through whichever provider you choose.
Each RIR sets its own criteria for issuing an ASN. Check them before you request resources:
| Registry | What it requires for an ASN |
|---|---|
| ARIN (United States, Canada and part of the Caribbean) | Since September 7, 2022, proof of a unique routing policy: originating your prefixes from an ASN different from your provider’s, multihoming, or interconnecting with other ASes. |
| LACNIC (Latin America and the Caribbean) | Policy Manual v2.20: a need to interconnect with other ASes at the time of the request or within 6 months, plus a description of your routing policy with the neighbor ASNs and the prefixes you’ll advertise. |
| RIPE NCC (Europe, the Middle East and part of Central Asia) | RIPE-679: the network must be multihomed and describe its new routing policy in RPSL, the language of the RIPE Database. |
One LACNIC detail worth reading twice: the portable addresses it assigns to end users come with no guarantee of being routable. For IPv4 they range from a /24 to a /20, and you must show you’ll announce them from your own AS to at least one other AS. For IPv6 the assignment is a /48 or larger.
How do you steer traffic across two ISPs?
With two providers you face two different problems. You decide outbound traffic. Inbound traffic you can only influence, because other ASes make the final call.
Outbound traffic: weight and LOCAL_PREF
In Cisco’s best path algorithm, the router compares weight first and LOCAL_PREF next. For both, the highest value wins.
- Weight: a Cisco-specific parameter, local to the router where you set it. It works when you have a single edge router.
- LOCAL_PREF: defaults to 100 and travels over iBGP to every router in your AS. It’s the right tool with two edge routers, one per ISP.
Inbound traffic: AS_PATH prepend, MED and communities
- AS_PATH prepend: you repeat your ASN in the advertisements toward the backup ISP. The path looks longer and the rest of the internet tends to prefer the other one. It’s a hint, not an order: a remote AS that sets its own LOCAL_PREF will ignore it.
- MED: the lowest value wins, but Cisco only compares it between routes from the same neighboring AS. It helps with two links to the same ISP, not with two different ISPs.
- Provider communities: some providers publish communities that change LOCAL_PREF inside their network when you tag your routes. AWS does this on Direct Connect with
7224:7100(low),7224:7200(medium) and7224:7300(high). Ask your ISP whether it offers something similar. - More-specific prefixes: the longest match always wins. If your block allows it, advertising a more specific piece over one link pulls that traffic toward it.
How do you avoid becoming a transit AS?
This is the mistake that does the most damage. If you accept routes from ISP A and pass them on to ISP B, your company becomes a transit AS: other people’s traffic can cross your links and saturate them.
RFC 7454 (BCP 194) gives the rule for a leaf network: announce only your local routes, and don’t advertise prefixes with a non-empty AS_PATH unless you intend to provide transit. In Cisco IOS that becomes two filters, one by prefix and one by AS_PATH:
ip prefix-list OWN seq 5 permit 192.0.2.0/24ip as-path access-list 10 permit ^$
The expression ^$ describes an empty AS_PATH: it only matches routes that originate inside your AS. Anything learned from an ISP carries its ASN in the path and gets dropped. Apply both filters toward each neighbor with neighbor 203.0.113.1 prefix-list OWN out and neighbor 203.0.113.1 filter-list 10 out.
Inbound, the same RFC recommends that if you only asked for a default route, you accept only the default route. If you receive more, filter non-routable prefixes, overly specific ones and your own prefixes when they come back from outside.
Case study: a company with two ISPs
Picture a company with AS 64500 and the PI block 192.0.2.0/24 (documentation values). Router R1 connects to ISP A (AS 64501) and R2 to ISP B (AS 64502). R1 and R2 run iBGP between them. The goal: ISP A is primary in both directions and ISP B stays as backup.
| Goal | Attribute or tool | Where you apply it | What wins |
|---|---|---|---|
| Pick the exit with a single edge router | Weight | Inbound, on that router | Highest |
| Pick the exit with two edge routers | LOCAL_PREF | Inbound from the primary ISP (R1) | Highest |
| Pull inbound traffic to the primary ISP | AS_PATH prepend | Outbound to the backup ISP (R2) | Shortest |
| Choose between two links to the same ISP | MED | Outbound to that ISP | Lowest |
| Ask the provider to lower its preference | Provider community | Outbound on the backup link | Per the provider |
| Never become a transit AS | prefix-list and filter-list with ^$ | Outbound to both ISPs | Only your routes pass |
On R1 you raise LOCAL_PREF for everything learned from ISP A and filter what you advertise:
route-map ISP-A-IN permit 10set local-preference 200router bgp 64500neighbor 203.0.113.1 remote-as 64501address-family ipv4network 192.0.2.0 mask 255.255.255.0neighbor 203.0.113.1 route-map ISP-A-IN inneighbor 203.0.113.1 prefix-list OWN outneighbor 203.0.113.1 filter-list 10 out
On R2 you lengthen your prefix’s path toward ISP B. The route-map match also acts as a filter, because anything that doesn’t match is dropped:
route-map ISP-B-OUT permit 10match ip address prefix-list OWNset as-path prepend 64500 64500 64500router bgp 64500neighbor 198.51.100.1 remote-as 64502address-family ipv4network 192.0.2.0 mask 255.255.255.0neighbor 198.51.100.1 route-map ISP-B-OUT outneighbor 198.51.100.1 filter-list 10 out
Verify with these commands. In the second one you should see only 192.0.2.0/24, with your ASN repeated:
show ip bgpshow ip bgp neighbors 198.51.100.1 advertised-routes
If you ask an AI to generate this configuration, review every filter before you apply it. One forgotten out turns you into a transit AS. AI proposes; you decide.
Why is BGP waiting for you in the cloud too?
If your company uses private links to the cloud, you’re already running BGP whether you asked for it or not. The big three use it on their dedicated connections:
- AWS Direct Connect: you exchange prefixes over BGP on each virtual interface. AWS evaluates the longest prefix first, then its LOCAL_PREF communities, before AS_PATH. It doesn’t recommend relying on MED. If you use a private ASN on a public interface, AWS replaces it with 7224 and your prepending is lost.
- Azure ExpressRoute: Microsoft doesn’t use HSRP or VRRP; it requires a redundant pair of BGP sessions per peering, and you need both for the SLA to apply. It uses AS 12076. On private peering you can advertise up to 4,000 IPv4 prefixes (10,000 with the premium add-on), and the session drops if you exceed the limit.
- Google Cloud Interconnect: Dedicated and Partner Interconnect require Cloud Router, the managed service that runs the BGP sessions with your network. Cloud Router only exchanges routes; it doesn’t forward packets.
The lesson is the same as with ISPs: attributes to choose the path and filters to advertise only what’s yours. The neighbor changes; the craft stays the same.
What you take away
- With a single ISP, a default route is usually enough; BGP arrives with multihoming, traffic control and the cloud.
- Your own ASN and PI space give you portability; ARIN, LACNIC and RIPE ask you to prove a routing policy of your own.
- You control outbound traffic with weight or LOCAL_PREF; inbound you can only influence with AS_PATH prepend, MED, communities or more-specific prefixes.
- Advertise only your prefixes: a prefix-list and a filter-list with ^$ keep you from becoming a transit AS.
- AWS Direct Connect, Azure ExpressRoute and Google Cloud Interconnect exchange routes with your network over BGP.
In part 3 we close the series with BGP at the service provider: how an ISP uses it at scale, plus an invitation to THoR’s BGP Masterclass.
Practice these policies in the BGP Masterclass
In The House of Routing’s BGP Masterclass, recorded live on Cisco routers, you work through two marathons. The first covers eBGP and iBGP, messages and states, and filtering and routing policies. The second covers iBGP scalability with route reflectors and confederations, best path selection and communities. It wraps up with a ticket workshop that emulates real-world requests. The readings are free: the first one is open, and you unlock the rest with a free sign-up.
Want the commands at hand? Get the free PDF guide “The 30 BGP commands”: send BGP to @thehouseofrouting on Instagram (as a comment or a direct message) and we’ll email it to you.
Sources
- RFC 1930 (BCP 6): Guidelines for creation, selection, and registration of an Autonomous System (AS)rfc-editor.org
- RFC 7454 (BCP 194): BGP Operations and Securityrfc-editor.org
- Select BGP Best-path Algorithmcisco.com
- ARIN-2021-3: Private AS Number and Unique Routing Policy Clarificationsarin.net
- Manual de políticas de LACNIC (v2.20)lacnic.net
- RIPE-679: Autonomous System (AS) Number Assignment Policiesripe.net
- Direct Connect routing policies and BGP communitiesdocs.aws.amazon.com
- Azure ExpressRoute: Routing requirementslearn.microsoft.com
- Cloud Router overviewcloud.google.com
Text by Jesús Espinoza, prepared with AI assistance and reviewed by him. Original illustration by The House of Routing.
