BGP Basics Cheat Sheet

Border Gateway Protocol: autonomous systems, BGP attributes and path selection, eBGP vs iBGP, peering configurations, and common BGP troubleshooting commands.

Last Updated: May 1, 2025

BGP Fundamentals

ItemDescription
Autonomous System (AS)Collection of IP prefixes under one routing policy
AS Number (ASN)Unique identifier: 16-bit (1-64511 public) or 32-bit (131072+)
eBGPExternal BGP — between different AS (peering with other organizations)
iBGPInternal BGP — within same AS (full mesh or route reflectors)
PeeringManual neighbor configuration (not auto-discovered like OSPF)
TCP/179BGP uses TCP — reliable, handshake-based session
Prefix advertisementAnnounce which IP blocks you can reach via your AS

BGP Path Attributes & Selection

1. LOCAL_PREF
Highest wins — controls outbound traffic (local to AS)
2. AS_PATH length
Shortest path wins — prepend your AS to depreference
3. ORIGIN
IGP (i) < EGP (e) < Incomplete (?) — lower is better
4. MED (MULTI_EXIT_DISC)
Lowest wins — tells neighbor which entry point to use
5. eBGP vs iBGP
eBGP routes preferred over iBGP
6. IGP metric to NEXT_HOP
Shortest internal distance to next hop wins
7. Router ID
Lowest router ID wins (tiebreaker)

Common BGP Commands (Cisco/JunOS)

show ip bgp summary
Cisco: BGP neighbor status, prefixes received
show ip bgp
Cisco: BGP routing table
show ip bgp neighbors 10.0.0.1 advertised-routes
What you're sending to neighbor
show ip bgp neighbors 10.0.0.1 routes
What neighbor is sending you
show route protocol bgp
JunOS: BGP routes in routing table
show bgp summary
JunOS: BGP session summary
clear ip bgp 10.0.0.1 soft in
Soft reset — re-process inbound routes without tearing down

BGP Best Practices

ItemDescription
Prefix filteringFilter announcements — accept only expected prefixes from peers
Max-prefix limitProtect against accidental full-table leaks (shut down peer)
AS path filteringFilter routes going through specific AS (regex-based)
Bogon filteringBlock private/reserved prefixes (RFC 1918, 5735, bogon lists)
Peer authenticationMD5/TCP-AO on BGP sessions — prevent hijacking
Route reflectorsScale iBGP without full mesh (every router peers with reflector)
Pro Tip: BGP is the routing protocol of the internet — AS_PATH length is the primary path selection tiebreaker after LOCAL_PREF. BGP is a path-vector protocol, NOT link-state.