BGP Cheat Sheet: Full Configuration Guide
Here’s a comprehensive BGP configuration cheat sheet that can be directly applied to routers. It includes eBGP, iBGP, route advertisement, redistribution, filtering, and useful commands.
General BGP Configuration Template
Global BGP Configuration
router bgp <asn> ! Configure the router's AS number
bgp log-neighbor-changes ! Logs neighbor changes (optional)
Neighbor Configuration
router bgp <asn>
neighbor <neighbor-ip> remote-as <asn> ! Establish BGP peering
neighbor <neighbor-ip> description <description> ! Optional: Add a description
neighbor <neighbor-ip> update-source <interface> ! Use a specific source interface neighbor <neighbor-ip>
next-hop-self ! iBGP: Ensure next-hop-self
Network Advertisement
router bgp <asn>
network <network> mask <subnet-mask> ! Advertise a network in BGP
Route Redistribution
router bgp <asn>
redistribute <protocol> ! Redistribute routes (e.g., OSPF, static)
redistribute connected ! Redistribute directly connected networks
Full BGP Configuration for Multi-AS Topology
Topology Overview
R1 (AS 65001): eBGP with R2 (AS 65002) and R3 (AS 65003).
R2 (AS 65002): eBGP with R1.
R3 (AS 65003): eBGP with R1, iBGP with R4.
R4 (AS 65003): iBGP with R3.
R1 (AS 65001) Configuration
router bgp 65001
bgp log-neighbor-changes
neighbor 192.168.12.2 remote-as 65002 ! eBGP with R2
neighbor 192.168.13.3 remote-as 65003 ! eBGP with R3
! Advertise Loopback and Connected Networks
network 10.1.1.1 mask 255.255.255.255
network 192.168.12.0 mask 255.255.255.0
network 192.168.13.0 mask 255.255.255.0
R2 (AS 65002) Configuration
router bgp 65002
bgp log-neighbor-changes
neighbor 192.168.12.1 remote-as 65001 ! eBGP with R1
! Advertise Loopback and Connected Networks
network 10.2.2.2 mask 255.255.255.255
network 192.168.12.0 mask 255.255.255.0
R3 (AS 65003) Configuration
router bgp 65003
bgp log-neighbor-changes
neighbor 192.168.13.1 remote-as 65001 ! eBGP with R1
neighbor 10.3.3.4 remote-as 65003 ! iBGP with R4 (loopback)
! Advertise Loopback and Connected Networks
network 10.3.3.3 mask 255.255.255.255
network 192.168.13.0 mask 255.255.255.0
! Use Loopback for iBGP
neighbor 10.3.3.4 update-source Loopback0
R4 (AS 65003) Configuration
router bgp 65003 bgp
log-neighbor-changes
neighbor 10.3.3.3 remote-as 65003 ! iBGP with R3 (loopback)
! Advertise Loopback
network 10.4.4.4 mask 255.255.255.255
! Use Loopback for iBGP
neighbor 10.3.3.3 update-source Loopback0
Advanced BGP Configuration
Route Filtering
Filter incoming or outgoing routes using prefix-lists or route-maps.
Prefix-List Example:
ip prefix-list BLOCK_ROUTES seq 10 deny 192.168.0.0/16 le 32
ip prefix-list BLOCK_ROUTES seq 20 permit 0.0.0.0/0 le 32
router bgp <asn>
neighbor <neighbor-ip> prefix-list BLOCK_ROUTES in ! Apply prefix-list to neighbor
Route-Map Example:
route-map SET_LOCAL_PREF permit 10
set local-preference 200
router bgp <asn>
neighbor <neighbor-ip> route-map SET_LOCAL_PREF in
Load Balancing with Multipath
Enable multipath load balancing for BGP.
router bgp <asn>
maximum-paths <number> ! Enable load balancing
BGP Timers
Adjust BGP timers for quicker convergence.
router bgp
<asn> neighbor <neighbor-ip> timers 10 30 ! Hello and hold timers (e.g., 10 seconds hello, 30 seconds hold)
Verification Commands
Check BGP Neighbors:
show ip bgp summary
Check BGP Routes:
show ip bgp
Inspect Neighbor Routes:
show ip bgp neighbors <neighbor-ip> advertised-routes
show ip bgp neighbors <neighbor-ip> received-routes
Check BGP Configuration:
show running-config | section bgp
Debug BGP Events:
debug ip bgp
debug ip bgp updates
This cheat sheet is structured to guide you through configuring, troubleshooting, and optimizing BGP in various scenarios. Let me know if you need more examples or a specific scenario explained!