My personal study notes for BGP. I do this so that I can quickly reference and update them and hopefully others might find them useful.

BGP – Path vector based EGP, providing routing between autonomous systems. 

Private AS range: 64512-65534

Public AS’s are assigned by RIR (regional internet registries) ex. ARIN / RIPE / APNIC

Uses TCP port 179

EBGP – Uses interface IP, 1 hop away only by default. 

IBGP – Usually uses loopback IP, no hop limit and utilizing an IGP adds aditional reliability. 

BGP Neighbor states: 

  1. Idle – Initializing BGP
  2. Connect – Waiting for TCP
  3. Active – Initiating session
  4. Open Sent – BGP Open
  5. Open Confirm – Wait
  6. Established – Ready

BGP Messages:  

  • Open – Router / Capabilities
  • Update – AS-Path / Attributes, NLRIs for Destinations
  • KeepAlive – Maintain Session (don’t include any data following the header)
  • Notification – Somethings wrong
  • Refresh – Soft Clear Session, resent previously acknowledged routes

BGP Path Selection: 

  1. Local-Preference (Highest)
  2. AS-Path (Shortest)
  3. Orgin (I>E>?)
  4. MED (Lowest)
  5. Prefer EBGP to IBGP 
  6. IBGP – Lowest IGP Cost, EBGP – Active Route
  7. Peer Router ID (Lowest)
  8. Cluster-List (Shortest)
  9. Peer IP (Lowest)

BGP Communities – 32 bit number that can traverse from AS to AS, doesn’t effect path selection directly, but can be used in policy that would then change metrics on path selection items. 

Juniper BGP default route import / export: 


  • EBGP: Export all active EBGP & IBGP routes
  • IBGP: Active EBGP Routes, no IBGP routes 


  • Accept BGP Routes

BGP Attributes: 

Attributes types:

  • Well-Known Mandatory – Must be supported by all BGP implementations and must be included in every BGP update. 
  • Well-known Discretionary – Must be supported in all BGP implementations, but doesn’t have to be included in every BGP update. 
  • Optional Transitive – Not required to be supported by all BGP implementations, but if they are, they should be passed along, unchanged to other BGP peers. 
  • Optional Non-transitive – Not required to be supported by all BGP implementations, if not recognized it is ignored and not passed to other peers.


AS PathWell-Known Mandatory
Local PreferenceWell-Known Discretionary
MED Optional Non-transitive
OrginWell-Known Mandatory
Next HopWell-Known Mandatory
CommunityOptional Transitive
AggregatorOptional Transitive
Atomic AggregatorWell-Known Discretionary
Cluster ListOptional Non-transitive
Originator IDOptional Non-transitive