BGP notes

This post contains notes about BGP operation and configuration.

 Quick Notes

  1.  A router stores all learned BGP prefixes and PAs in its BGP table (except for any prefixes filtered by an inbound BGP filter).
  2. The router advertises only the best route for each prefix.
  3. If the best path in BGP table is not put inside routing table (for example it has  higher administrative distance than a static route) then it is still advertised to all BGP peers (contrary to what most other distance-vector routing protocols do); you can change that behavior with bgp suppress-inactive option.
  4. When a router learns routes from an iBGP peer, that router does not advertise the
    same routes to another iBGP peer
  5. BGP Router-ID: explicity configured; or highest loopback; or highest other interface. In most configuration/verification commands you will see the neighbor IP address (not neighbor Router-ID).
  6. BGP Router-IDs have to be different to create neighborhood.
  7. BGP uses tcp (port 179)
  8. BGP states – among others:
    • idle – the BGP process is down or awaiting the next try
    • active – the tcp connection is established
    • established (or the number) – the peers exchange Update messages
  9. Administrative distance: eBGP = 20; iBGP = 200

BGP Configuration

The following snippet shows basic BGP configuration.

komo-r001#show run | section bgp

router bgp 65025
 bgp log-neighbor-changes
 neighbor remote-as 65135
 neighbor password cisco

BGP veryfication

komo-r001#show ip bgp summary

BGP router identifier, local AS number 65025
BGP table version is 5, main routing table version 5
4 network entries using 576 bytes of memory
4 path entries using 320 bytes of memory
1/1 BGP path/bestpath attribute entries using 136 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1056 total bytes of memory
BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd    4        65135      86      58        5    0    0 00:48:53        4
komo-r001#show ip bgp neighbors

BGP neighbor is,  remote AS 65135, external link
  BGP version 4, remote router ID
  BGP state = Established, up for 00:49:15
  Last read 00:00:26, last write 00:00:41, hold time is 180, keepalive interval is 60 seconds
  Neighbor sessions:
    1 active, is not multisession capable (disabled)

komo-r001#show tcp brief

TCB       Local Address               Foreign Address             (state)
67BC3198             ESTAB

BGP control

Restart all BGP neighbor relationships

komo-r001#clear ip bgp *

*Jul 13 23:28:01.787: %BGP-5-ADJCHANGE: neighbor Down User reset
*Jul 13 23:28:01.787: %BGP_SESSION-5-ADJCHANGE: neighbor IPv4 Unicast topology base removed from session  User reset
*Jul 13 23:28:02.883: %BGP-5-ADJCHANGE: neighbor Up

You can shutdown communication with neighbor:

router bgp 65025
neighbor shutdown
// no neighbor shutdown 

BGP Table veryfication

komo-r001#show ip bgp // lists the entirety of the BGP routing table

BGP table version is 5, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>             0             0 65135 ?
 *>             0             0 65135 ?
 *>             0             0 65135 ?
 r>             0             0 65135 ?

Note for r> – it means that the BGP route cannot be inserted into the IP routing table (in this case there is a static route for the same prefix with a lower admin distance).

komo-r001#show ip bgp rib-failure

  Network            Next Hop                      RIB-failure   RIB-NH Matches        Higher admin distance              n/a

Other commands:

show ip bgp prefix [subnet-mask] // List possible routes, per prefix.
show ip bgp neighbors ip-address received-routes // routes learned from one neighbor (before inbound filtering)
show ip bgp neighbors ip-address routes // routes learned from one neighbor (after inbound filtering)
show ip bgp neighbors ip-address advertised-routes // routes advertised to a neighbor (after outbound filtering)
show ip bgp summary // number of prefixes learned per neighbor
show ip bgp IP/MASK_LENGTH long-prefixes // display route for IP/MASK_LENGTH and all more specific routes
show ip bgp neighbor neighbor-id advertised-routes // shows the post-filter BGP updates (sent to the neighbor)
show ip bgp neighbor received-routes // shows the pre-filter BGP updates
   (it requires neighbor soft-reconfiguration inbound subcommand -  the router to retain the received BGP Updates from that neighbor [extra memory used]).
show ip bgp neighbors neighbor-id routes // show the post-filter BGP updates

Injecting routes

You can inject routes into BGP table using network Prefix Mask command. – If exactly the same entry (Prefix, Mask) exists in the IP routing table; then this prefix is injected into local BGP table (and advertised to the other BGP peers). Note – this behavior differs if BGP auto-summary is configured.

You can also use redistribute command to inject routes learned from an IGP (ex: OSPF). This command can also be used to inject static or connected routes into BGP table.

router bgp 65025
redistribute connected

BGP reset

You can perform either hard or soft reset of BGP relationship with neighbor (for example, in order to apply new in/out BGP update filters). Hard reset tears down tcp connection and build the relationship from scratch. Soft reset does not kill the BGP neighborhood but resend outgoing updates, reprocess incoming updates (using applied in/out filters). In both cases you can use specific variations of clear command. For example:

clear ip bgp * // hard reset for all neighbors
clear ip bgp neighbor-id soft out // soft reset for one neighbor for out-update direction only

Leave a Reply

Your email address will not be published. Required fields are marked *