BGP (Border Gateway Protocol)

The Path Vector protocol that powers the Internet. Unlike IGPs (OSPF/EIGRP) which seek speed, BGP seeks stability, policy control, and loop-free routing between Autonomous Systems (AS).

1. eBGP vs iBGP

BGP operates differently depending on the AS (Autonomous System) relationship.

Feature eBGP (External) iBGP (Internal)
Peers Different AS Same AS
TTL Default 1 (Directly Connected) Default 255 (Can be multiple hops away)
Route Advertising Advertises all best paths to peers. Split Horizon Rule: Routes learned from an iBGP peer are NOT advertised to other iBGP peers.
Next Hop Changes Next-Hop to self (usually). Preserves Next-Hop. (Often causes "Next-Hop Unreachable" errors unless `next-hop-self` is used).
The iBGP Full Mesh Problem

Because iBGP routers don't re-advertise iBGP-learned routes, every iBGP router must peer with every other iBGP router (Full Mesh). Formula: N * (N-1) / 2.

Solution: Use Route Reflectors (RR) or Confederations to break the full mesh requirement.

2. BGP Attributes & Path Selection

BGP selects a single "Best Path" based on this strict tie-breaker list.

  1. Weight (Cisco): Highest wins. Local to the router only. (Not sent to peers). Range 0-65535.
  2. Local Preference: Highest wins. Local to the AS (Transitive within AS). Used to influence outbound traffic. Default 100.
  3. Locally Originated: Prefer paths I injected (network/redistribute/aggregate).
  4. AS Path: Shortest length wins. (Can be manipulated with AS-Path Prepending).
  5. Origin: IGP (i) < EGP (e) < Incomplete (?).
  6. MED (Metric): Lowest wins. Used to influence inbound traffic from an external AS. Non-transitive.
  7. eBGP over iBGP: Prefer external paths.
  8. IGP Cost: Lowest IGP metric to the BGP Next-Hop.
  9. Router ID: Lowest BGP Router ID.

Mnemonic: "We Love Oranges As Oranges Mean Pure Refreshment"

3. Connection States (FSM)

BGP uses TCP Port 179. Troubleshooting peerings requires understanding these states:

4. Advanced Features & Scenarios

BGP Backdoor

Normally, eBGP routes (AD 20) are preferred over IGP routes (OSPF 110, EIGRP 90). Sometimes, you have a private backdoor link (IGP) that you prefer over the public internet (eBGP) for specific prefixes.

Use the network <ip> backdoor command. This sets the BGP route's distance to 200 (Local/iBGP), making the IGP route preferred.

Synchronization

Legacy rule: "Do not use or advertise a route learned via iBGP unless that route is also known via IGP." This prevents black-holing traffic in transit ASs that are not fully meshed. Modern networks disable this (no synchronization) because they rely on full iBGP meshes or MPLS.

Community Attribute

An optional, transitive tag (32-bit number) attached to routes. Used to group destinations for policy decisions.


References