Bgp Cheat Sheet
Overview
Type | Path Vector |
---|---|
eBGP AD | 20 |
iBGP AD | 200 |
Standard | RFC 4271 |
Protocols | IP |
Transport | TCP/179 |
Authentication | MD5 |
Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information between autonomous systems (AS) on the Internet.
BGP Messages
- Open: Establishes a BGP session.
- Update: Transfers routing information.
- Keepalive: Ensures the connection is alive.
- Notification: Indicates errors.
BGP States
- Idle: Initial state.
- Connect: Waiting for TCP connection.
- Active: Attempting to establish a connection.
- OpenSent: Open message sent, waiting for reply.
- OpenConfirm: Waiting for Keepalive or Notification.
- Established: Session established, routing begins.
BGP Attributes
Well-known Mandatory
- AS Path: List of AS numbers a route has traversed.
- Origin: Indicates the origin of the route.
- Next Hop: IP address to reach the next AS.
Well-known Discretionary
- Local Preference: Preference for an exit point.(default 100)
- Atomic Aggregate: Includes ASes which have been dropped due to route aggregation
Optional Transitive
- Aggregator: ID and AS of summarizing router
- Community: Tags routes for specific actions.
Optional Nontransitive
- MED (Multi-Exit Discriminator): Suggests preferred route. (default 0)
- Originator ID: The originator of a reflected route
- Cluster list: List of cluster IDs
- Cluster ID: Originating cluster
- Weight: Cisco proprietary, highest priority. (default 0)
Path Selection
Nr. | Description | Preference |
---|---|---|
1. Weight | Administrative Preverence | Highest |
2. Local Preference | Communicated between peers within an AS | Highest |
3. Self-originated | Prefer paths originated locally | True |
4. AS Path | Minimize AS hops | Shortest |
5. Origin | Prefer IGP-learned routes over EGP, and EGP over unknown | IGP |
6. MED | Used externally to enter an AS | Lowest |
7. External | Prefer eBGP routes over iBGP | eBGP |
8. IGP Cost | Consider IGP metric | Lowest |
9. eBGP Peering | Favor more stable routes | Oldest |
10. Router ID | Tie breaker | Lowest |
Common Commands
- Show BGP Summary: show ip bgp summary
- Show BGP Neighbors: show ip bgp neighbors
- Show BGP Routes: show ip bgp
- Clear BGP Session: clear ip bgp <NEIGHBOR_IP> in/out
Troubleshooting
- Check BGP State: show ip bgp neighbors <NEIGHBOR_IP> | include BGP state
- Check Route Advertisement: show ip bgp
- Debug BGP Events: debug ip bgp events
Best Practices
- Use Route Filtering: Prevent unwanted routes.
- Monitor BGP Sessions: Regularly check session states.
- Secure BGP: Implement MD5 authentication.
Configuration Example
ip as-path access-list 10 permit ^$
route-map SET_LOCAL_PREF_INBOUND permit 10
set local-preference 400
route-map FILTER_AS_PATH_OUTBOUND permit 10
match as-path 10
router bgp 65001
bgp log-neighbor-changes
address-family ipv4 vrf VRF1
neighbor 192.168.1.1 remote-as 65002
neighbor 192.168.1.1 activate
neighbor 192.168.1.1 route-map SET_LOCAL_PREF_INBOUND in
neighbor 192.168.1.1 route-map FILTER_AS_PATH_OUTBOUND out
network 10.0.1.0 mask 255.255.255.0
exit-address-family
address-family ipv4 vrf VRF2
neighbor 192.168.2.1 remote-as 65003
neighbor 192.168.2.1 activate
network 10.0.2.0 mask 255.255.255.0
exit-address-family
Last updated on