Saturday, March 19, 2011

WYSINWYRG - The 'show ip bgp neighbors ip-addr advertised-routes' Command

What You See Is Not What You Really Get (WYSINWYRG). :-)

First of all, let's see what's the advertised-routes option of the show ip bgp neighbors {ip-addr} command claims to be.
Router#sh ip bgp neighbors 2.2.2.2 ?
  advertised-routes  Display the routes advertised to a BGP neighbor
  dampened-routes    Display the dampened routes received from neighbor
  flap-statistics    Display flap statistics of the routes learned from
                     neighbor
  paths              Display AS paths learned from neighbor
  received           Display information received from a BGP neighbor
  received-routes    Display the received routes from neighbor
  routes             Display routes learned from neighbor
  |                  Output modifiers
  <cr>

Router#

So it says "the routes advertised to a neighbor", hmm... let's see...


Above shows the network topology used for this demonstration.
RT1 is configured with a route map to set the MED for its locally originated routes in AS 65001 to 100.
The MED attribute only being exchanged between neighbors ASes and not be propagated further to downstream or upstream ASes. So RT3 won't be able to see the MED value for 192.168.1.0/24 originated from AS 65001.
RT3#sh ip bgp
BGP table version is 8, local router ID is 192.168.3.1
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
*> 192.168.1.0      23.23.23.2                             0 65002 65001 i
*> 192.168.2.0      23.23.23.2               0             0 65002 i
*> 192.168.3.0      0.0.0.0                  0         32768 i
RT3#
Notice the blank value in the Metric column for 192.168.1.0/24? So far, so good...

Now let's issue the command in question on RT2. :-)
RT2#sh ip bgp neighbors 23.23.23.3 advertised-routes
BGP table version is 11, local router ID is 192.168.2.1
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
*> 192.168.1.0      12.12.12.1             100             0 65001 i
*> 192.168.2.0      0.0.0.0                  0         32768 i
RT2#

hey, RT2 claims that it advertised the MED value for 192.168.1.0/24 to RT3.
WHAT!?! What I see is not what I really get!?! ~!@#$%^&*()

Conclusion:
The output of the show ip bgp neighbors {ip-addr} advertised-routes is actually displaying the routes in the Loc-RIB instead of the Adj-RIB-Out, which means that the routes that are yet to be processed by the output policy engine that performs the actions for manipulating routes, eg: MED, AS path prepending, etc. Period. :-)

So, this should be the way. :-)
Router#sh ip bgp neighbors 2.2.2.2 ?
  advertised-routes  Display the routes that are going to be advertised to a BGP neighbor
  dampened-routes    Display the dampened routes received from neighbor
  flap-statistics    Display flap statistics of the routes learned from
                     neighbor
  paths              Display AS paths learned from neighbor
  received           Display information received from a BGP neighbor
  received-routes    Display the received routes from neighbor
  routes             Display routes learned from neighbor
  |                  Output modifiers
  <cr>

Router#

P/S: The values in the AS path column further support our conclusion.

No comments:

Post a Comment