BGP
What
Exterior Gateway Protocol (EGP) for routing between ASes
Policy-based rather than metric based
Money makes the BGP go round
Why
Allows the use of policies, enabling ASes to make deals with one another on routing
Path vector algorithm: prevents loops
Flexible:
Complex policies
Traffic engineering
Multi-homing
Load balancing
Concepts
Autonomous System (AS)
An administrative domain with a unified routing policy, e.g. an ISP or large company
Each AS has a unique AS Number
BGP sessions are on port 179 using TCP
BGP types
External BGP (eBGP): used to route between ASes
Internal BGP (iBGP): within one AS
Communities
A way to communicate preferred treatment
The meaning of certain numbers has to be agreed upon beforehand between 2 or more parties
When a route is forwarded to a party that does not have an agreement on community meanings, the community field is emptied
Multi-Exit-Discriminator (MED)
- Used to tell peer which entry point to prefer
- Lower MED = better
- Influences incoming traffic
- Only a suggestion
Tables
- Neighbour Table: BGP peers and their state
- BGP Table (Adj-RIB-In): A table per peer containing routes received before filtering
- BGP Table (Loc-RIB): Best routes selected by BGP decision process
- BGP Table (Adj-RIB-Out): A table per peer containing routes advertised to said neighbour after filtering
- Routing Table (RIB): Best BGP routes installed for forwarding (if better than IGP routes)
Attributes
- ORIGIN: How route entered BGP (IGP, EGP, Incomplete)
- AS_PATH: List of ASes route has traversed (loop prevention, path selection)
- NEXT_HOP: IP address of next router to reach destination
- LOCAL_PREF: Preference within AS (higher = better), not sent to eBGP peers
- MED (Multi-Exit Discriminator): Suggestion to external AS about preferred entry point (lower = better)
- COMMUNITY: Tags for grouping routes and applying policies
- WEIGHT: Cisco-proprietary, local to router only (higher = better)
Neighbour States
- Idle: Initial state, waiting to start
- Connect: TCP connection initiated
- Active: Trying to establish TCP connection (despite name, this indicates problems)
- OpenSent: TCP established, Open message sent
- OpenConfirm: Open message received, waiting for Keepalive
- Established: Session up, exchanging routes
Messages
- Open: Establishes session, negotiates parameters (AS number, Router ID, hold time)
- Update: Advertises new routes or withdraws unreachable routes
- Keepalive: Maintains session (sent every 60s by default)
- Notification: Reports errors, closes session
(S)Election
All BGP speakers are equal, but there is path selection
The following attributes are used:
- Highest WEIGHT (Cisco-proprietary, local to router)
- Highest LOCAL_PREF (prefer certain exit paths within AS)
- (isn't this done through LOCAL_PREF?) Locally originated (prefer own routes)
- Shortest AS_PATH (fewer ASes to traverse)
- Lowest ORIGIN (IGP < EGP < Incomplete, mostly 0 nowadays)
- Lowest MED (if from same AS, prefer suggested entry)
- eBGP over iBGP (prefer external routes)
- Lowest IGP metric to NEXT_HOP (closest exit point)
- Oldest route (stability preference)
- Lowest Router ID (tiebreaker)
How
- Configure BGP on your router
- Set AS number
- Set router ID
- Define peers
- Advertise certain network(s)
- TCP connection is initiated to peers (3-way handshake)
- R1 send BGP OPEN message
- R2 receives, validates and if the params are acceptable sends an OPEN back to R1
- R1 receives and if the params are acceptable sends a KEEPALIVE (goes to
OpenConfirmstate) - Once KEEPALIVEs have been exchanged, both routers go to
Establishedstate - Send BGP UPDATE messages to exchange routes
- Receive updates and process them, if acceptable store them and populate the routing table