Border Gateway Protocol (BGP) is the routing protocol that runs the internet. It is used to exchange routing information between different autonomous systems (AS).
Key concepts
- AS (Autonomous System) — a network or group of networks under a single administrative domain, identified by an AS number (ASN)
- eBGP — BGP between different autonomous systems (external)
- iBGP — BGP within the same autonomous system (internal)
- BGP peer/neighbour — a router you have a BGP session established with
- Prefix — a network route being advertised (e.g. 10.0.0.0/24)
How BGP works
- Two routers form a TCP session on port 179
- They exchange their full routing tables (once)
- After that, only changes (updates) are sent
- BGP selects the best path using attributes
BGP path selection (simplified)
BGP prefers routes in this order:
- Highest Local Preference (iBGP)
- Shortest AS Path
- Lowest Origin type
- Lowest MED (Multi-Exit Discriminator)
- eBGP over iBGP
- Lowest IGP metric to next hop
- Oldest route / lowest router ID
Common BGP states
| State | Meaning |
|---|---|
| Idle | Not attempting connection |
| Connect | TCP connection in progress |
| Active | Trying to establish TCP |
| OpenSent | OPEN message sent |
| OpenConfirm | Waiting for KEEPALIVE |
| Established | Session up, exchanging routes |
Related Notes
- Forti - BGP Debug
- Forti - BGP route changes
- Juniper - Find export policies and prefix lists for VRF
- Juniper - Finding routes