BGP (Border Gateway Protocol) is the routing protocol that connects the internet's networks. Each network (autonomous system) announces the IP ranges it can reach to its neighbours, which pass them on. Routers use these announcements to pick a path for every packet.
How it works
Announcements and paths
A network announces “I can reach 17.0.0.0/8”. Its neighbours add their own ASN to the AS path and pass it on. Every router ends up with possible routes to every prefix and picks one, preferring, roughly, cheaper business relationships first, then shorter AS paths.
Peering and transit
- Transit: a network pays a bigger network to reach the whole internet.
- Peering: two networks exchange traffic directly, often for free, at internet exchange points (IXPs).
BGP runs over TCP port 179 between routers that are configured as neighbours.
When BGP goes wrong
BGP trusts what neighbours say, so mistakes spread fast:
- Route leaks and hijacks: a network announces prefixes it doesn't own, pulling traffic its way.
- Withdrawals: in 2021 Facebook withdrew the routes to its own DNS servers, taking its services offline for hours.
RPKI lets owners cryptographically sign which ASN may announce their prefixes, and more networks now drop invalid routes.
Examples
Traceroute shows the result of BGP decisions: each jump from one network's routers to another's is a BGP boundary.
$ whois -h whois.cymru.com " -v 1.1.1.1"
13335 | 1.1.1.1 | 1.1.1.0/24 | AU | apnic | 2011-08-11 | CLOUDFLARENET - Cloudflare, Inc., US
On a Mac
Your Mac doesn't run BGP; your ISP's routers do. To see where BGP sends your traffic, run traceroute to a destination and look up the network of each hop.
See it in the app
LightAtom's traceroute shows the routers your traffic crosses; router names often hint at the network that runs them.
Frequently asked questions
What is BGP used for?
Exchanging routing information between the networks that make up the internet, so traffic can travel between them.
What port does BGP use?
TCP port 179.
What is a BGP hijack?
When a network announces IP ranges it doesn't own, misdirecting traffic to itself, by mistake or on purpose.
Do home routers use BGP?
No. Home routers send everything to the ISP with a default route; BGP runs between ISPs and large networks.