BGP — Border Gateway Protocol
BGP is the internet's routing protocol. All other protocols (OSPF, EIGRP, ...) are interior protocols — they work within one managed environment. BGP is exterior — it connects separate autonomous systems to each other. Current version: BGP-4.
Interior vs Exterior
| Interior (IGP) | Exterior (EGP) | |
|---|---|---|
| Peer discovery | Automatic | Manually configured |
| Trust | Routers in own network | External networks |
| Route distribution | To all routers in the AS | Only to configured peers |
| Examples | OSPF, EIGRP, RIP | BGP |
Route Types
| Type | Description |
|---|---|
| Static routes | Manually configured |
| Connected routes | Automatically created when an interface comes up |
| Interior routes | Within an AS (via IGP) |
| Exterior routes | Outside an AS (via BGP) |
BGP Properties
- The only protocol that can handle multiple connections to unrelated routing domains
- Designed for internet scale
- Policy-based — each AS can decide for itself which routes it accepts, advertises and prefers
- Decentralized — each AS makes decisions autonomously
- Low bandwidth and processor overhead
- Built-in loop detection
Autonomous System (AS)
An Autonomous System is a collection of IP prefixes (networks) under one common routing policy.
- Identified by an AS number (public or private)
- Registered with an RIR (Regional Internet Registry)
- Internally: one routing protocol (IGP); externally: BGP to connect to other ASes
- Examples of entities with an AS: service providers, multi-homed customers, large organizations
iBGP vs eBGP
| iBGP | eBGP | |
|---|---|---|
| When | AS numbers of both peers are the same | AS numbers are different |
| Use | Internally in an AS, between border routers | Between ASes |
router bgp 100
network 220.220.8.0 mask 255.255.255.0
neighbor 222.222.10.1 remote-as 101 ← eBGP (different AS)
BGP Protocol
BGP peers establish a TCP connection on port 179 before exchanging routes.
Message Types
| Type | Description |
|---|---|
| Open | Initiates the BGP connection — identifies itself and starts route exchange |
| Update | Core of the protocol — contains reachability info and path attributes |
| Keepalive | Periodically verifies the peer is still reachable |
| Notification | Error messages and control messages |
Update message structure
BGP Header
├── Withdrawn Routes (routes that are no longer available)
├── Path Attributes (Origin, AS Path, Next Hop, MED, Local Pref, ...)
└── NLRI (Network Layer Reachability Info — new routes)
AS-Path Attribute
The AS-Path attribute is the list of AS numbers a route has passed through — a kind of route history.
- Each AS adds its own number to the path when forwarding the route
- Used for loop detection: an AS rejects routes where its own AS number is already in the path
- Also used for policy — determine preferred paths based on AS path length or content
Next Hop Attribute
The Next Hop attribute indicates via which IP address a network is reachable.
- In an eBGP session: the IP of the interface the eBGP peer is connected to
- The next hop is updated at every eBGP hop — each AS sets the next hop to its own interface toward the next peer