Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

Autonomous Systems and Prefixes

An autonomous system (AS) is a network under one administration with its own routing policy: an internet provider, a data center operator, a university, a large company. Each has a number, its ASN. ASNs were 16-bit numbers and are now 32-bit. The ranges 64496 to 64511 and 65536 to 65551 are reserved for documentation (RFC 5398), which is why the examples here use them; 64512 to 65534 and 4200000000 to 4294967294 are for private use (RFC 6996).

A prefix is a block of addresses written in CIDR notation, such as 203.0.113.0/24 or 2001:db8::/32 (see CIDR notation). An AS originates the prefixes it holds. By common practice, not by any rule in the protocol, /24 is the smallest IPv4 block and /48 the smallest IPv6 block that most networks accept from others.

How Routes Spread

Two routers that exchange BGP information are neighbors, connected over TCP port 179. When AS64500 announces 203.0.113.0/24, its neighbor AS64501 learns the route with the path 64500. When AS64501 passes it on, it adds itself, and the next network sees the path 64501 64500. Every route carries this AS path, which tells where it came from and prevents loops: a network ignores a route that already contains its own number.

BGP between different networks is called eBGP; inside one network, routers share what they learned with iBGP.

Peering and Transit

  • Transit: a network pays another to carry its traffic to the whole internet. The transit provider announces the customer's prefixes everywhere and gives it routes to everything.
  • Peering: two networks exchange traffic only between themselves and their customers, often without payment, because both benefit. Peering happens over a direct link or at an internet exchange point (IXP), where many networks connect in one place.

A network usually combines both: peering for nearby networks it exchanges a lot of traffic with, transit for the rest.

How a Path Is Chosen

A router often hears several routes to the same prefix and picks one. Policy comes first: a network typically prefers routes from customers over peers, and routes from peers over paid transit, set with an attribute called local preference. Among equal choices, a shorter AS path usually wins. Speed and load are not part of the basic decision.

Why the Return Path Differs

Each network chooses its outgoing path by its own policy, and many hand traffic to the next network as early as possible. Your request to a server and the server's reply are therefore chosen by different networks with different preferences, and they often travel different routes. A traceroute from your side shows only one direction, which is why you also need a view from the other end.

When Routing Goes Wrong

  • Route leak: a network passes routes on to neighbors it should not, pulling traffic through a path that cannot carry it.
  • Hijack: a network announces a prefix that belongs to someone else, by mistake or on purpose.
  • RPKI: address holders publish signed records stating which AS may originate their prefixes, and networks that validate them reject announcements that do not match.

What You Can Observe

You cannot see a router's BGP table from a server, but you can see its effects:

mtr -rwzc 100 example.com
whois AS64496
whois 203.0.113.10
  • mtr -z: shows the AS number of each hop, so you see which networks your traffic crosses and where delay or loss begins.
  • whois on an AS number: shows who operates it. On an address, it shows the holder of the block, often with the originating AS.
  • Looking glass: runs ping, traceroute, and BGP route lookups from inside another network, which gives you the return direction. See what is a looking glass.

Run the tests in both directions and at different times of day before drawing conclusions. For the other tools, see Linux network commands.

Do You Need BGP Yourself?

Only if you hold your own ASN and address space and want to announce them, for example from more than one location. A normal server has a default route to its gateway and nothing more; the network around it handles BGP. What BGP means for you in practice is that the route to your users depends on the networks in between, which is one reason to choose a server location close to them, as explained in latency vs bandwidth.

Was this answer helpful?
Loading...