Display locally originated BGP routes
Displaying the BGP routes originated in the local AS is simple: you just filter the BGP table with a regular expression matching an empty AS path. Displaying routes originated by the local router is tougher. You could use the fact that the local routes have the weight set to 32768:
PE-A#show ip bgp quote-regexp "^$" | inc Network|32768
Network Next Hop Metric LocPrf Weight Path
*> 10.0.1.1/32 0.0.0.0 0 32768 i
This would work if you don’t play with BGP weights in network statements. If you’ve changed the weights, you should filter the routes based on the BGP next-hop: locally originated routes have the next-hop 0.0.0.0 and all other routes should have a non-zero BGP next-hop. To filter BGP routes based on the next-hop you have to:
- Define an access-list that matches desired next-hop (0.0.0.0)
- Define a route-map that uses the access-list to match IP next hop.
- Display BGP routes matched by a route-map.
A sample configuration and show command printout is included below:
ip access-list standard AllZeros
permit 0.0.0.0
!
route-map NextHopSelf permit 10
match ip next-hop AllZeros
PE-A#show ip bgp route-map NextHopSelf | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 10.0.1.1/32 0.0.0.0 0 32768 i
To make this command simpler to use, define an alias: alias exec mybgp show ip bgp route-map NextHopSelf | begin Network.
show ip bgp neighbors x.x.x.x advertised-routes
This shows all routes you are advertising to a particular neighbour including with BGP and redistributed routes (static, other protocols - EIGRP etc).
The only annoying thing is having to enter the IP address. In my network I have implemented this with alias so I don't need to type the IP address.
Hope this helps!
ADT :)
To catch these routes also use this:
route-map local-only permit 10
match route-type local
show ip bgp route-map local-only