the Border Gateway Protocol
/ B-G-P /
Inside one network, routers can use protocols like OSPF to find shortest paths, because they all trust each other and share full maps. But the Internet is built from tens of thousands of separate networks that do NOT trust each other and will not share their internal maps. They still need to agree on how to reach everyone. The Border Gateway Protocol, or BGP, is the single protocol they all use to do that. It is, in a real sense, the glue that holds the Internet together: there is one inter-domain routing protocol, and it is BGP.
BGP works between the border routers of different autonomous systems. Two routers that agree to exchange routes set up a BGP session (a TCP connection) and then tell each other which IP prefixes they can reach and by what AS path. When something changes — a new prefix becomes reachable, or a link goes down — they send an incremental update advertising the new route or withdrawing the dead one. Crucially, a router does not advertise a distance or a cost; it advertises the full list of autonomous systems a packet would traverse, which is why BGP is called a path-vector protocol. A receiving AS then applies its own policy to decide which advertised path to actually use, and which (if any) to pass on to its other neighbours.
BGP is policy-driven, not shortest-path. An AS routinely chooses a longer AS path because it is cheaper or contractually preferred, and it filters which routes it re-advertises based on business relationships. That flexibility is BGP's strength and its weakness: it lets independent networks cooperate without a central authority, but because BGP largely trusts what neighbours tell it, a single misconfiguration or malicious advertisement can divert or black-hole large parts of Internet traffic.
Suppose ISP A owns 203.0.113.0/24. Its border router opens a BGP session with neighbour ISP B and advertises: "prefix 203.0.113.0/24, AS path = [A]." B accepts it, then tells its own neighbour C: "203.0.113.0/24, AS path = [B, A]." Now C knows that to reach that block, packets go through B then A — and C can choose this path or a different one it learned elsewhere.
BGP advertises reachable prefixes plus the full AS path; each AS applies its own policy before re-advertising.
BGP finds a policy-compliant, loop-free path, not a globally shortest or fastest one — a route with a short AS path can still be slow, congested, or longer in miles than an alternative.