BGP Routing

AS numbers, iBGP vs eBGP, path selection attributes (MED/LocalPref/AS_PATH), route aggregation, and BGP hijacking attacks.

Overview

Overview BGP (Border Gateway Protocol) is the routing protocol that holds the internet together. As an exterior gateway protocol standardized in RFC 4271, BGP exchanges reachability information between autonomous systems (AS) — collections of IP prefixes under a single administrative domain identified by a unique AS number. Unlike interior routing protocols that optimize for shortest path within a network, BGP is a path-vector protocol that makes routing decisions based on policies and a rich set of attributes.

BGP sessions operate over TCP port 179, ensuring reliable delivery of routing updates. Two fundamental session types exist: eBGP (external BGP) connects routers in different autonomous systems and is the basis of inter-domain internet routing, while iBGP (internal BGP) connects routers within the same AS to distribute externally learned routes internally.

Understanding BGP is critical for SRE and network engineering roles at large-scale companies. Google, Amazon, and Meta each operate large autonomous systems and peer with hundreds of ISPs globally. BGP misconfigurations have caused some of the internet's most severe outages, including the 2021 Facebook incident where an erroneous BGP withdrawal made all Facebook properties unreachable worldwide for over six hours.

In cloud environments, BGP is used extensively: AWS Direct Connect uses BGP to exchange routes between on-premises networks and AWS, Transit Gateway route tables propagate BGP-learned prefixes, and Kubernetes CNI plugins like Calico use BGP to distribute pod CIDR routes across nodes. Mastery of BGP path selection, attribute manipulation, and troubleshooting is expected at the senior SRE and network engineer level.

Key concepts

  • Autonomous System (AS)
  • Path Vector Protocol
  • LOCAL_PREF
  • MED (Multi-Exit Discriminator)
  • BGP Path Selection Order
  • Route Reflector

Interview questions

  • Explain the BGP path selection algorithm. Given multiple paths to the same prefix, how does BGP choose the best one?
  • What is a BGP route leak and a BGP hijack? How would you detect and mitigate each?
  • How does BGP work over AWS Direct Connect? Walk through the configuration and what happens if the BGP session drops.

Sign up free to read the full topic

More Networking topics

Start free on Cariara · Coding problems · System design studio