05 June 2016

BGP Best Path Selection - OriginCode

Border Gateway Protocol (BGP) routers typically receive multiple paths to the same destination. The BGP best path algorithm decides which is the best path to install in the IP routing table and to use for traffic forwarding. A option is to prefer the path that was locally originated via a network or aggregate BGP subcommand or through redistribution from an IGP. Local paths that are sourced by the network or redistribute commands are preferred over local aggregates that are sourced by the aggregate-address command. Let's dive in a example that you can't use the Weight or LocalPref.

By default the router of choice in towards the 192.168.1.0/24 is the R2:

R1# sh ip bgp
BGP table version is 8, local router ID is 192.168.0.9
...
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   192.168.1.0      10.0.0.6                               0 234 i
 *>                   10.0.0.2                               0 234 i


So, We need to make some BGP manipulations. I'm using the route-map as option:

R1# sh run | s router bgp
router bgp 100
 bgp log-neighbor-changes
 neighbor 10.0.0.2 remote-as 234
 neighbor 10.0.0.2 route-map R2Origin in
 neighbor 10.0.0.6 remote-as 234

R1# sh run | s route-map
 route-map R2Origin permit 10
  set origin incomplete

[+] After the route-map applied..

R1# debug bgp all updates

R1# clear ip bgp 10.0.0.2 soft in
*Jun  5 03:17:30.589: BGP: nbr_topo global 10.0.0.2 IPv4 Unicast:base (0xC908F00:1) rcvd Refresh Start-of-RIB
*Jun  5 03:17:30.590: BGP: nbr_topo global 10.0.0.2 IPv4 Unicast:base (0xC908F00:1) refresh_epoch is 2
*Jun  5 03:17:30.593: BGP(0): 10.0.0.2 rcvd UPDATE w/ attr: nexthop 10.0.0.2, origin i, merged path 234, AS_PATH 
*Jun  5 03:17:30.595: BGP(0): 10.0.0.2 rcvd 192.168.1.0/24
*Jun  5 03:17:30.595: BGP: nbr_topo global 10.0.0.2 IPv4 Unicast:base (0xC908F00:1) rcvd Refresh End-of-RIB
*Jun  5 03:17:30.596: BGP(0): Revise route installing 1 of 1 routes for 192.168.1.0/24 -> 10.0.0.6(global) to main IP table
*Jun  5 03:17:30.598: BGP(0): (base) 10.0.0.2 send UPDATE (format) 192.168.1.0/24, next 10.0.0.1, metric 0, path 234

R1# sh ip bgp              
BGP table version is 4, local router ID is 192.168.0.9
...
Origin codes: i - IGP, e - EGP, ? - incomplete

RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *>  192.168.1.0      10.0.0.6                               0 234 i
 *                    10.0.0.2                               0 234 ?



I Hope you enjoyed.

biOos

No comments: