BGP

Border Gateway Protocol peering, path selection, and route policy configuration on Cisco platforms.

Basic BGP Configuration

eBGP peering — neighbor in a different AS; TTL is 1 by default (directly connected)
configure terminal
router bgp 65001
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor 10.0.0.2 remote-as 65002
 !
 address-family ipv4 unicast
  neighbor 10.0.0.2 activate
  network 10.50.0.0 mask 255.255.0.0
 exit-address-family
end
iBGP peering — neighbor in the same AS; use loopback as update source for resilience
configure terminal
router bgp 65001
 bgp router-id 1.1.1.1
 neighbor 2.2.2.2 remote-as 65001
 neighbor 2.2.2.2 update-source Loopback0
 !
 address-family ipv4 unicast
  neighbor 2.2.2.2 activate
  neighbor 2.2.2.2 next-hop-self
 exit-address-family
end

iBGP vs eBGP Key Differences

next-hop-self — iBGP does not change next-hop by default; set this on iBGP peers so they can reach external next-hops
configure terminal
router bgp 65001
 address-family ipv4 unicast
  neighbor 2.2.2.2 next-hop-self
 exit-address-family
end
update-source — iBGP peers should source from loopback for redundancy
configure terminal
router bgp 65001
 neighbor 2.2.2.2 update-source Loopback0
end
eBGP multihop — required when eBGP peer is not directly connected
configure terminal
router bgp 65001
 neighbor 10.0.0.2 ebgp-multihop 2
end

BGP Neighbor Verification

Show BGP summary — state should be a number (prefixes received); anything else means not established
show ip bgp summary
Show BGP neighbor detail — uptime, messages sent/received, state machine, configured policies
show ip bgp neighbors 10.0.0.2

BGP Table and Best Path

Show BGP table — > (valid), * (best), i (internal), status codes and path attributes
show ip bgp
show ip bgp 10.50.0.0/16
show ip bgp 10.50.0.0 255.255.0.0
BGP best path selection order — evaluated top to bottom; first difference wins
! 1. Highest WEIGHT (Cisco-local, default 0, set per-neighbor)
! 2. Highest LOCAL_PREF (iBGP, default 100)
! 3. Locally originated (network/aggregate/redistribute)
! 4. Shortest AS_PATH
! 5. Lowest origin type (IGP < EGP < incomplete)
! 6. Lowest MED (inter-AS, compared only from same neighbor AS by default)
! 7. eBGP over iBGP
! 8. Lowest IGP metric to next-hop
! 9. Oldest eBGP route
! 10. Lowest neighbor router-id

Path Attribute Manipulation

WEIGHT — Cisco proprietary; local to router; higher preferred; set via route-map or neighbor command
configure terminal
router bgp 65001
 neighbor 10.0.0.2 weight 200
end

! Or with route-map for granularity
configure terminal
route-map SET-WEIGHT permit 10
 set weight 200
!
router bgp 65001
 neighbor 10.0.0.2 route-map SET-WEIGHT in
end
LOCAL_PREF — propagated within AS via iBGP; higher preferred; default 100
configure terminal
route-map PREFER-ISP1 permit 10
 set local-preference 200
!
router bgp 65001
 neighbor 10.0.0.2 route-map PREFER-ISP1 in
end
AS_PATH prepending — makes path appear longer; used to influence inbound traffic from other ASes
configure terminal
route-map PREPEND-OUT permit 10
 set as-path prepend 65001 65001 65001
!
router bgp 65001
 neighbor 10.0.0.2 route-map PREPEND-OUT out
end
MED (Multi-Exit Discriminator) — suggests preferred entry point to neighbor AS; lower preferred
configure terminal
route-map SET-MED permit 10
 set metric 50
!
router bgp 65001
 neighbor 10.0.0.2 route-map SET-MED out
end

Prefix Lists and Route Maps

ip prefix-list — filter by network and prefix length; ge/le for range
configure terminal
ip prefix-list DENY-DEFAULT seq 5 deny 0.0.0.0/0
ip prefix-list DENY-DEFAULT seq 10 permit 0.0.0.0/0 le 32
end
Route-map applied to BGP neighbor — filter and manipulate inbound/outbound
configure terminal
route-map FILTER-IN deny 10
 match ip address prefix-list BLOCK-THESE
!
route-map FILTER-IN permit 20
!
router bgp 65001
 address-family ipv4 unicast
  neighbor 10.0.0.2 route-map FILTER-IN in
 exit-address-family
end

Route Reflector

Route reflector — solves iBGP full-mesh requirement; RR reflects routes to clients
configure terminal
router bgp 65001
 address-family ipv4 unicast
  neighbor 3.3.3.3 route-reflector-client
  neighbor 4.4.4.4 route-reflector-client
 exit-address-family
end
RR rules — routes from client reflected to all clients and non-clients; routes from non-client reflected to clients only; originator-id and cluster-list prevent loops
show ip bgp 10.50.0.0/16
! Look for: Originator: x.x.x.x, Cluster list: y.y.y.y

Soft Reconfiguration

Soft reset — re-process BGP policies without tearing down the session
clear ip bgp 10.0.0.2 soft in
clear ip bgp 10.0.0.2 soft out
clear ip bgp * soft
Enable storing received routes for soft-reconfiguration inbound — uses memory
configure terminal
router bgp 65001
 address-family ipv4 unicast
  neighbor 10.0.0.2 soft-reconfiguration inbound
 exit-address-family
end
View received routes before and after policy application
show ip bgp neighbors 10.0.0.2 received-routes
show ip bgp neighbors 10.0.0.2 routes
show ip bgp neighbors 10.0.0.2 advertised-routes

Network Statement

BGP network statement — does NOT enable BGP on an interface; advertises a route that already exists in the RIB; mask must match exactly
configure terminal
router bgp 65001
 address-family ipv4 unicast
  network 10.50.0.0 mask 255.255.0.0
 exit-address-family
end

Verification Summary

Key show commands for BGP troubleshooting
show ip bgp summary
show ip bgp
show ip bgp neighbors 10.0.0.2
show ip bgp neighbors 10.0.0.2 advertised-routes
show ip bgp neighbors 10.0.0.2 received-routes
show ip bgp neighbors 10.0.0.2 routes
show ip route bgp