~/netref / BGP
##

BGP

The path-vector protocol that runs the internet. eBGP AD 20 · iBGP AD 200 · TCP 179.

// neighbor states

Idle
Not started / not responding
Connect
TCP session establishing
Active
Attempting to connect
OpenSent
Open message sent
OpenConfirm
Response received
Established
Adjacency up — routes exchanged
// message types
OpenStart the session, negotiate parameters
UpdateAdvertise / withdraw routes + attributes
KeepaliveMaintain the session
NotificationReport an error & close
// attribute categories
Well-known MandatorySupported & propagated — AS-Path, Next-Hop, Origin
Well-known DiscretionarySupported; propagation optional — Local Pref, Atomic Aggregate
Optional TransitiveMarked partial if unsupported — Aggregator, Community
Optional Non-transitiveDropped if unsupported — MED, Originator ID
// path attributes (type code)
1OriginHow it entered BGP (i / e / ?)
2AS_PathASes traversed — loop prevention & length
3Next_HopIP used to reach the prefix
4MEDMulti-Exit Discriminator — hints entry point (lower wins)
5Local_PrefPreferred exit within the AS (higher wins)
6Atomic_AggregateMarks a summarized route
7AggregatorAS + router that summarized
8CommunityTag for grouping / policy
9Originator_IDRoute reflector — route origin
10Cluster_ListRoute reflector — loop prevention
// well-known communities
NO_EXPORTDon’t advertise outside the AS / confederation
NO_ADVERTISEDon’t advertise to any peer
NO_EXPORT_SUBCONFEDDon’t advertise to eBGP peers
LOCAL_ASKeep within the local sub-AS
INTERNETAdvertise to everyone (default)
// origin codes
IGP (i)Originated by a network statement / IGP
EGP (e)Learned via legacy EGP (rare)
Incomplete (?)Redistributed from another source
// eBGP vs iBGP
eBGPiBGP
BetweenDifferent ASesSame AS
AD20200
TTL1 (directly connected)default IP TTL
Next-hopSet to selfUnchanged (use next-hop-self)
AS-PathPrepends own ASUnchanged
Re-advertiseTo iBGP & eBGP peersNot to other iBGP (needs RR / mesh)
// path selection order
1WeightHighest (Cisco, local to router)
2Local PreferenceHighest (within the AS)
3Self-originatedPrefer locally originated
4AS-PathShortest path
5OriginIGP > EGP > unknown
6MEDLowest
7eBGP / iBGPPrefer eBGP
8IGP metricLowest to next hop
9eBGP ageOldest / most stable
10Router IDLowest (tie-break)

// facts

  • eBGP AD 20 · iBGP AD 200 · TCP 179 · MD5 auth
  • Path-vector — chooses by policy, not just hop count
  • iBGP needs full mesh, route reflectors or confederations
  • Synchronization (legacy): route in the IGP before advertising

// numbers & scaling

  • Public ASN 1–64511 · private 64512–65535 · 32-bit ASNs (RFC 6793)
  • Timers: Keepalive 60 s · Hold 180 s
  • Message header: 16-byte marker + 2-byte length + 1-byte type
  • iBGP scaling: route reflectors (RR) or confederations
  • RR uses Originator-ID & Cluster-List to break loops
configuration · cisco ios
router bgp 65100
 bgp router-id 1.1.1.1
 no synchronization
 neighbor 172.16.0.2 remote-as 65200
 neighbor 172.16.0.2 password S3cret
 network 192.168.1.0 mask 255.255.255.0
 no auto-summary
verify
show ip bgp summary
show ip bgp neighbors
show ip bgp
clear ip bgp * soft