What is BGP, why do we need it, and what is an autonomous system?
Show the answer
Say this first
BGP version 4 (RFC 4271) is the routing protocol between autonomous systems, the one that holds the internet together. An autonomous system (AS) is a set of networks run by one organisation with one routing policy, identified by an AS number. An IGP like OSPF finds the best path inside one network; BGP exchanges reachability between organisations and lets each one apply its own policy, at a scale of roughly a million IPv4 prefixes.
Go deeper
Why not run OSPF across the internet
- Scale. A link-state protocol floods every topology change to every router and runs SPF over the whole graph. That works for hundreds of routers, not for the whole internet.
- Policy. OSPF picks the lowest cost. Between companies you need rules like "never send my traffic through that network" or "prefer the cheaper transit provider". BGP decisions are driven by attributes and policy, not by a single metric.
- Privacy. BGP shares reachability (a prefix plus attributes), not your internal topology.
Path vector
BGP is a path-vector protocol. Every route carries the AS_PATH, the list of ASes it has crossed. A router that sees its own AS number in a received path drops the route. That is the loop prevention between ASes.
AS numbers
- 2-byte ASNs run from 1 to 65535. 4-byte ASNs (RFC 6793) go up to 4294967295.
- Private ranges: 64512 to 65534 and 4200000000 to 4294967294.
- Public ASNs are assigned by the regional internet registries (ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC).
Where else BGP shows up
MPLS L3VPN (the VPNv4 address family), EVPN for VXLAN fabrics, and as the only routing protocol in large spine-leaf data centres (RFC 7938). Being good at BGP pays off well beyond the internet edge.
They will ask next
When does a company actually need BGP?
When it connects to two or more providers and wants control over which link carries traffic in and out, usually with its own provider-independent prefix and public ASN. A site with one ISP and ISP-assigned addresses is fine with a static default route.
Is BGP a routing protocol or an application?
Both views are fair. It runs as an application over TCP port 179, but its job is routing: it installs routes in the routing table. It depends on connected routes or the IGP to reach its peers and next hops.
Traps
- Calling BGP a distance-vector protocol. It is path vector, and best path selection uses attributes and policy, not hop count.
- Saying you need a public ASN to run BGP. Private ASNs work for iBGP, confederation sub-ASes and many single-provider customers.