What is BGP?
BGP is the routing protocol of the internet, exchanging routes between autonomous systems. Learn eBGP, iBGP, AS paths and security.
Last updated:
BGP (Border Gateway Protocol) is the routing protocol that holds the entire internet together. It exchanges reachability information between autonomous systems (AS). Every ISP, content provider and large enterprise owns its own AS number, and BGP lets these networks announce to each other which IP address prefixes they serve. As a result, a packet sent from one corner of the world knows how to reach its destination, even though no single router holds a complete map of the internet.
What BGP does and how it works
BGP is a path-vector protocol. Instead of exchanging raw metrics like interior protocols do, BGP routers pass each other complete AS paths, the list of autonomous system numbers through which a prefix has been advertised. BGP sessions run over TCP on port 179, which guarantees reliable delivery of updates. Once a session is established, neighbours exchange full routing tables and then send only incremental changes. In a stable network this keeps control traffic low.
eBGP versus iBGP
The distinction between eBGP and iBGP depends on whether a session connects two different autonomous systems or routers within a single AS. eBGP (external BGP) runs between different AS and is what builds the global internet routing table. iBGP (internal BGP) propagates externally learned routes inside your own AS so that every border router has a consistent view of the available paths.
- eBGP usually connects directly adjacent routers and lowers the TTL by default, expecting a neighbour on the same segment.
- iBGP requires a full mesh of sessions or scaling mechanisms such as route reflectors or confederations.
- Routes learned via iBGP are not advertised to other iBGP peers by default, which is why a full mesh or reflectors are needed.
- eBGP modifies the AS path by prepending its own AS number, whereas iBGP leaves it unchanged.
Route selection and why it matters for ISPs
When a router learns several routes to the same prefix, BGP picks a single best path using a fixed order of attributes. It first considers the local weight, then LOCAL_PREF, then AS path length, origin type, the MED attribute, then a preference for eBGP over iBGP and finally the metric to the next hop. For operators this means real control over traffic policy. With LOCAL_PREF you can prefer cheaper peering over paid transit, and with AS path prepending you can influence which path inbound traffic uses to return to your network.
For any ISP, BGP is a tool for traffic engineering and resilience. Owning your own AS and running BGP sessions enables multihoming, connecting to several providers at once and automatically rerouting traffic if a link fails. It is also the foundation of public and private peering, which lowers transit costs and shortens the path packets take to popular destinations.
Security: route hijacks, MANRS and RPKI
BGP was designed in an era when operators trusted each other, so on its own it does not verify whether whoever announces a prefix is actually entitled to it. The consequences are route hijacks, where a foreign AS announces someone else's prefix, and route leaks, where routes are unintentionally propagated against policy. To curb these risks the MANRS initiative emerged, along with RPKI and ROA validation, which cryptographically binds a prefix to the AS number authorised to announce it. Prefix filtering, origin validation and maximum prefix limits are now standard BGP hygiene.
Frequently asked questions
How does eBGP differ from iBGP?
eBGP runs between different autonomous systems and builds the global routing table, while iBGP propagates those routes inside a single AS. eBGP prepends its own AS number to the path, whereas iBGP leaves it unchanged.
Why would an ISP run its own BGP?
Owning an AS and running BGP enables multihoming, meaning link redundancy and automatic failover, as well as peering that lowers transit costs and improves latency.
What is a route hijack?
It is when an autonomous system announces a prefix in BGP that it has no right to, redirecting the victim's traffic. Prefix filtering and RPKI validation reduce this risk.
How does RPKI improve BGP security?
RPKI with ROA objects cryptographically binds a prefix to its authorised AS number, so routers can reject invalid origin announcements and limit the impact of route hijacks.
