Display locally originated BGP routes

From CT3

Jump to: navigation, search

By Ivan Pepelnjak

Cisco IOS has no show command that would display the BGP routes originated by the local router. You could use the fact that these routes usually have the weight set to 32768 (unless you reset it with a route-map) and use the show ip bgp | include 32768_[i?] show filter to display them. This solution requires that the router generates the whole BGP routing table and filters the printout, which could be a slow operation on a router with full Internet routing.

It’s probably much better to rely on the fact that the locally-originated routes have no BGP next-hop unless you’ve manually set it with the set ip next-hop command within a route-map used in network route-map or redistribute route-map router configuration command. BGP routes with no next-hop can be matched with a route-map using match ip next-hop option that matches the next-hop This route-map is then used to filter the BGP table in the show ip bgp route-map command. The configuration of the route-map and associated IP access-list is shown in the following printout:

route-map LocalBGPRoutes permit 10
 match ip next-hop AllZero
ip access-list standard AllZero
alias exec localbgp show ip bgp route-map LocalBGPRoutes

After configuring a handy alias, you can display the locally-originated BGP routes with a simple localbgp command:

BGP table version is 12, local router ID is
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>                  0         32768 i
*>                  0         32768 ?

Additional Resources  

Configuring BGP on Cisco Routers (BGP) course
Other links
Personal tools


Main menu