The internet is a network of networks: ISPs, hosting providers, cloud platforms, universities, content networks. BGP (Border Gateway Protocol) is how these networks tell each other which IP addresses they can reach, and how traffic finds its way between them. You don’t need to run BGP to host a website, but understanding it explains why latency differs between providers, why “premium routes” exist, and how outages and hijacks happen.

Autonomous systems and ASNs

An autonomous system (AS) is a network under one administrative control, with its own routing policy. Each has a number, an ASN: Cloudflare is AS13335, Google AS15169, and every ISP and hosting provider has one or more.

Look up who announces an IP:

whois -h whois.radb.net 1.1.1.1 | grep -E 'origin|route'
whois 203.0.113.10 | grep -iE 'origin|netname|org'

Online tools (bgp.tools, bgp.he.net, RIPEstat) show an IP’s prefix, origin ASN and upstream providers.

Prefixes and announcements

Networks announce prefixes: blocks of IP addresses such as 198.51.100.0/24. An announcement says “send traffic for this prefix to me”, and carries the AS path, the list of ASes the route has passed through:

198.51.100.0/24   AS path: 3356 64500

Here the route reached you via AS3356, and the prefix originates in AS64500. Routers receive many possible paths for each prefix, and pick one per their policy.

The smallest prefix generally accepted globally is /24 for IPv4 and /48 for IPv6. See subnetting and CIDR.

How BGP picks a route

BGP isn’t “shortest distance” routing. It’s policy routing. Simplified, a network prefers:

  1. routes from customers (they pay), then peers (free exchange), then transit providers (they cost money);
  2. among equals, the shortest AS path;
  3. then various tie-breakers.

The result: traffic follows business relationships and peering arrangements, not geography. A packet from a city to a server in the same city can travel through another country, if that’s where the two networks interconnect.

Transit vs peering

  • Transit: a network pays a larger provider (a “Tier 1” or major carrier) to reach the whole internet.
  • Peering: two networks exchange traffic for each other’s customers directly, often for free, at internet exchange points (IXPs) or through private interconnects.

A hosting provider with good peering to the networks your users are on gives lower latency and fewer congested hops. That’s what route quality means. Providers buy premium transit (for example, China Telecom’s CN2 GIA for mainland China traffic) to improve paths to particular regions. See latency vs bandwidth.

See the path yourself

mtr -rwzc 50 203.0.113.10        # -z shows the AS number of each hop
traceroute -A 203.0.113.10       # AS lookup per hop (some versions)

ASN changes along the path show where traffic crosses between networks. Sudden latency jumps often appear at those borders, or on long-haul links. See ping, traceroute and mtr.

When BGP goes wrong

Route leaks and hijacks. If a network wrongly announces someone else’s prefix, deliberately or by mistake, traffic can be drawn to it. Real incidents have taken major services offline for hours.

Defences:

  • RPKI (Resource Public Key Infrastructure): IP holders publish signed ROAs stating which ASN may originate their prefixes. Networks performing Route Origin Validation drop invalid announcements. Adoption has grown rapidly.
  • IRR filtering: route-object databases used to filter what customers may announce.
  • Monitoring: services alert prefix owners when their prefixes appear from unexpected origins.

Outages. A bad BGP configuration can withdraw a company’s prefixes from the internet. Its DNS and services become unreachable worldwide, even though the servers are fine.

Do you need BGP?

For almost all websites and applications: no. Your hosting provider runs BGP. You get an IP address from its announced prefixes, and use DNS, CDNs and multiple servers for resilience.

You’d run BGP yourself if you:

  • own IP space (your own /24 or /48) and an ASN;
  • want to announce it from several providers or locations (multi-homing, anycast). See anycast explained;
  • operate a network: an ISP, a large hosting setup, DDoS protection.

That requires a provider that offers BGP sessions, plus tools like BIRD or FRRouting on Linux.

Glossary

Term Meaning
AS / ASN A network and its number
Prefix A block of IPs (/24, /48)
AS path The ASes a route passed through
Transit Paid access to the whole internet
Peering Direct traffic exchange between networks
IXP Internet exchange point, where many networks peer
RPKI / ROA Cryptographic proof of who may announce a prefix

Related: NAT explained and choosing a VPS location.

  • Networking
  • BGP
  • Infrastructure