Computer Networks

BGP

The internet's inter-domain routing protocol: path vectors, policy, and the default-free zone.

Level: advanced

What is it?

Border Gateway Protocol (BGP) is a path-vector routing protocol used to exchange IP reachability between autonomous systems and in other policy-driven routing contexts. It selects routes using attributes and local policy rather than simply choosing the physically shortest path.

Why does it matter?

The global internet consists of independently operated networks with business and security policies. BGP allows operators to control which routes they announce and prefer, but configuration mistakes can leak or withdraw large numbers of routes.

Mental model

BGP advertisements include a destination prefix and path/policy attributes. A router applies import policy, selects a best path among eligible candidates, and applies export policy before advertising reachability onward.

How it works

  • AS_PATH records autonomous systems traversed and is used for loop prevention and policy decisions.
  • LOCAL_PREF influences preferred exit paths within an AS in common BGP policy; exact selection order follows the BGP implementation/policy.
  • NEXT_HOP must resolve for a route to be usable.
  • BGP can establish external (eBGP) or internal (iBGP) sessions; their rules and topology requirements differ.
  • Route filters, prefix limits, RPKI-based validation, and monitoring help reduce route-leak and hijack risks.

Steps

  • Routers establish a BGP session with a peer and exchange capabilities and routes.
  • Import policy filters or modifies candidate advertisements.
  • The router selects eligible best paths using attributes and configured policy.
  • Export policy determines which routes to advertise to other peers; operators monitor changes and reachability.

Real-world usage

  • Interconnecting internet service providers and large enterprise networks.
  • Managing multiple upstream providers and controlled traffic engineering.

Common mistakes

  • Assuming BGP picks the lowest-latency or fewest-hop route by default.
  • Accepting all routes from a peer without appropriate filters and limits.
  • Confusing route announcement with proof of legitimate ownership or reachability at the destination.

Interview questions

Why is BGP called policy-driven?

Its path attributes and operator policies determine which routes are accepted, preferred, and exported; the selected route is not simply the shortest physical path.

How does AS_PATH help?

It lists ASes traversed and helps detect routing loops; operators also use it in route selection and policy.

Prerequisites

Related concepts

Continue learning

Browse the full computer science library