Bgp Cheat Sheet

Bgp Cheat Sheet

Overview

TypePath Vector
eBGP AD20
iBGP AD200
StandardRFC 4271
ProtocolsIP
TransportTCP/179
AuthenticationMD5

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

  1. Idle: Initial state.
  2. Connect: Waiting for TCP connection.
  3. Active: Attempting to establish a connection.
  4. OpenSent: Open message sent, waiting for reply.
  5. OpenConfirm: Waiting for Keepalive or Notification.
  6. Established: Session established, routing begins.

BGP Attributes

Well-known Mandatory

  1. AS Path: List of AS numbers a route has traversed.
  2. Origin: Indicates the origin of the route.
  3. Next Hop: IP address to reach the next AS.

Well-known Discretionary

  1. Local Preference: Preference for an exit point.(default 100)
  2. Atomic Aggregate: Includes ASes which have been dropped due to route aggregation

Optional Transitive

  1. Aggregator: ID and AS of summarizing router
  2. Community: Tags routes for specific actions.

Optional Nontransitive

  1. MED (Multi-Exit Discriminator): Suggests preferred route. (default 0)
  2. Originator ID: The originator of a reflected route
  3. Cluster list: List of cluster IDs
  4. Cluster ID: Originating cluster
  5. Weight: Cisco proprietary, highest priority. (default 0)

Path Selection

Nr.DescriptionPreference
1. WeightAdministrative PreverenceHighest
2. Local PreferenceCommunicated between peers within an ASHighest
3. Self-originatedPrefer paths originated locallyTrue
4. AS PathMinimize AS hopsShortest
5. OriginPrefer IGP-learned routes over EGP, and EGP over unknownIGP
6. MEDUsed externally to enter an ASLowest
7. ExternalPrefer eBGP routes over iBGPeBGP
8. IGP CostConsider IGP metricLowest
9. eBGP PeeringFavor more stable routesOldest
10. Router IDTie breakerLowest

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