BGP Best Practices: Complete Configuration Guide

Border Gateway Protocol is the glue of the internet—and the most dangerous tool in your network arsenal. A single misconfiguration can take down continents. This guide provides comprehensive best practices for hybrid cloud connectivity.

⚠️ Warning: BGP changes in production can cause outages. Always test configurations in a lab environment first, have rollback procedures ready, and schedule maintenance windows for significant changes.

1. ASN (Autonomous System Number) Strategy

Public vs Private ASNs

ASNs identify your network to the global routing system. Choosing the right type is critical:

Private ASNs (64512–65534, 4200000000–4294967294)

# AWS Direct Connect uses private ASN by default
# Your on-premise router config (example):
router bgp 65001
  neighbor 169.254.x.x remote-as 64512  # Amazon's private ASN
  neighbor 169.254.x.x local-as 65001   # Your private ASN

Public ASNs

ASN Planning Recommendations

2. Prefix Management and Advertisement

Prefix Sizing Rules

Address Planning for Multi-Homing

If you multi-home (connect to multiple ISPs), you need Provider Independent (PI) address space:

Route Summarization

# Bad: Leaking individual routes
network 10.0.1.0/24
network 10.0.2.0/24
network 10.0.3.0/24
...
network 10.0.254.0/24

# Good: Advertising summary
network 10.0.0.0/16

Summarization reduces routing table size, improves convergence time, and hides internal topology changes from external peers.

3. Route Manipulation and Traffic Engineering

With redundant connections, you must control which path traffic takes. BGP offers several attributes for traffic engineering:

Path Selection Order (Simplified)

  1. Highest Weight (Cisco-specific, local to router)
  2. Highest Local Preference (iBGP, used for outbound traffic)
  3. Locally originated route preferred
  4. Shortest AS-Path
  5. Lowest Origin type (IGP < EGP < Incomplete)
  6. Lowest MED (when received from same AS)
  7. eBGP over iBGP
  8. Lowest IGP metric to next hop
  9. Oldest route
  10. Lowest router ID

Traffic Engineering Techniques

Attribute Scope Controls How It Works
Local Preference Within your AS Outbound traffic Higher value wins; default is 100
AS-Path Prepending Advertised to peers Inbound traffic Prepend your ASN to make path look longer
MED Sent to neighbors Inbound from same AS Lower value preferred; suggests entry point
Communities Signaling to peers Policy delegation Tags routes for special handling

Example: Prefer Primary Link for Outbound

# Set higher local-pref on routes from primary upstream
route-map PRIMARY-IN permit 10
  set local-preference 200

route-map BACKUP-IN permit 10
  set local-preference 100

router bgp 65001
  neighbor 203.0.113.1 route-map PRIMARY-IN in
  neighbor 198.51.100.1 route-map BACKUP-IN in

Example: Deprioritize Inbound via Backup

# Prepend AS-path on backup advertisements
route-map BACKUP-OUT permit 10
  set as-path prepend 65001 65001 65001

router bgp 65001
  neighbor 198.51.100.1 route-map BACKUP-OUT out

4. BGP Communities

Communities are powerful tags that control route handling across networks. They enable complex policies without manual coordination.

Standard Community Format

Communities are 32-bit values written as ASN:VALUE (e.g., 65001:100).

Well-Known Communities

ISP Action Communities (Examples)

Most ISPs publish communities you can attach to routes for special handling:

Always check your ISP's documentation for supported communities.

Large Communities (RFC 8092)

For 32-bit ASNs or more expressive policies, use large communities: ASN:FUNCTION:VALUE.

5. Security: RPKI and Route Filtering

Route hijacking—whether accidental or malicious—is a real threat. Implement these security measures:

RPKI (Resource Public Key Infrastructure)

RPKI enables cryptographic verification of route origins:

ROA (Route Origin Authorization)

# Create ROA (via your RIR portal):
Prefix: 203.0.113.0/24
Origin AS: 65001
Max Length: /24  # Don't allow more-specifics

# Router validation policy:
router bgp 65001
  bgp rpki server tcp 10.0.0.1 port 8282
  
  route-map RPKI-FILTER permit 10
    match rpki valid
    set local-preference 200
  route-map RPKI-FILTER permit 20
    match rpki not-found
    set local-preference 100
  route-map RPKI-FILTER deny 30
    match rpki invalid

Prefix Filtering

Always filter routes from peers—trust no one by default:

Inbound Filtering

Outbound Filtering

# Prefix-list for inbound filtering
ip prefix-list CUSTOMER-PREFIXES seq 10 permit 192.0.2.0/24
ip prefix-list CUSTOMER-PREFIXES seq 100 deny 0.0.0.0/0 le 32

# Apply to neighbor
router bgp 65001
  neighbor 198.51.100.1 prefix-list CUSTOMER-PREFIXES in
  neighbor 198.51.100.1 maximum-prefix 100 warning-only

6. High Availability and Failover

BFD (Bidirectional Forwarding Detection)

BGP's default keepalive (60s) and hold timer (180s) are too slow for production. BFD provides sub-second failure detection:

# Enable BFD on BGP neighbor
router bgp 65001
  neighbor 203.0.113.1 fall-over bfd

# BFD timers (platform-specific)
bfd
  interval 300 min_rx 300 multiplier 3  # 900ms detection

Graceful Restart

When a router restarts (software upgrade, control plane failure), graceful restart preserves forwarding while BGP reconverges:

router bgp 65001
  bgp graceful-restart
  bgp graceful-restart restart-time 120

7. Cloud-Specific BGP Considerations

AWS Direct Connect

Azure ExpressRoute

Google Cloud Interconnect

Learn more in our AWS, Azure, and Google Cloud provider guides.

8. Troubleshooting BGP

Common Issues

Essential Commands

# Check neighbor status
show bgp summary
show bgp neighbors 203.0.113.1

# View routes
show bgp ipv4 unicast
show bgp ipv4 unicast 192.0.2.0/24
show bgp ipv4 unicast neighbors 203.0.113.1 advertised-routes
show bgp ipv4 unicast neighbors 203.0.113.1 received-routes

# Debug (use carefully in production)
debug bgp updates

Key Takeaways

Need BGP Architecture Help?

We specialize in BGP design for hybrid cloud. Contact us for architecture review and implementation support.