BGP_LocPrf_Top

Same Topology, only this time I added a second logical network between R3 and R4 by creating 2 loopback interfaces in the same subnet 210.3.3.0 /24, and removed the previous “All or none” configuration for Local Preference.

So first I want to review R2 and R1 to see if their ip bgp tables look correct:

R2#sh ip bgp
BGP table version is 11, local router ID is 10.1.1.2
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
*> 172.12.34.0/24   10.1.1.4                 0                             0 34 i
* i                              10.1.1.3                 0    100                  0 34 i
* i210.3.3.0              10.1.1.3                 0    100                  0 34 i
*>                              10.1.1.4                 0                            0 34 i
R2#
ASR#1
[Resuming connection 1 to r1 … ]

R1#sh ip bgp
BGP table version is 8, local router ID is 10.1.1.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
* i172.12.34.0/24   10.1.1.4                 0     100                   0 34 i
*>                             10.1.1.3                 0                              0 34 i
* i210.3.3.0              10.1.1.4                 0     100                  0 34 i
*>                              10.1.1.3                 0                             0 34 i
R1#

I did them in reverse with R2 and then R1, but you can see like the physical connection / network, their best path is the next hop IP address.

So we have to go back to our MED lab for a lesson on how to manipulate some but not all routes, by creating ACL’s and Route-Maps! Lets get started:

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#access-list 7 permit 172.12.34.0 0.0.0.255
R1(config)#route-map DoublePref permit 10
R1(config-route-map)#match ip add 7
R1(config-route-map)#set ?
  as-path           Prepend string for a BGP AS-path attribute
  automatic-tag     Automatically compute TAG value
  clns              OSI summary address
  comm-list         set BGP community list (for deletion)
  community         BGP community attribute
  dampening         Set BGP route flap dampening parameters
  default           Set default information
  extcommunity      BGP extended community attribute
  interface         Output interface
  ip                IP specific information
  ipv6              IPv6 specific information
  level             Where to import route
  local-preference  BGP local preference path attribute
  metric            Metric value for destination routing protocol
  metric-type       Type of metric for destination routing protocol
  mpls-label        Set MPLS label for prefix
  nlri              BGP NLRI type
  origin            BGP origin code
  tag               Tag value for destination routing protocol
  traffic-index     BGP traffic classification number for accounting
  vrf               Define VRF name
  weight            BGP weight for routing table

R1(config-route-map)#set local-pref ?
  <0-4294967295>  Preference value
  <cr>

R1(config-route-map)#set local-pref 200
R1(config-route-map)#route-map DoublePref permit 20
R1(config-route-map)#set local-pref 100
R1(config-route-map)#exit
R1(config)#

So as can be seen, I matched the 172.12.34.0 /24 network, the access list required a mask because it is not a host route, and in the route-map the “set” clause in this case is local-preference follow by a number. I also set a “catch-all” clause after that on sequence 20 so any other routes should remain with a default Local Preference of 100.

So now to apply the Route-Map, as with MED, with the neighbor command:

R1(config)#router bgp 12
R1(config-router)#neighbor 10.1.1.2 route-map ?
  WORD  Name of route map

R1(config-router)#neighbor 10.1.1.2 route-map DoublePref ?
  in   Apply map to incoming routes
  out  Apply map to outbound routes

R1(config-router)#neighbor 10.1.1.2 route-map DoublePref out ?
  <cr>

R1(config-router)#neighbor 10.1.1.2 route-map DoublePref out
R1(config-router)#^Z
R1#

R1#clear ip bgp * soft out
R1#

So lets take a look at what R2 now has going on with its ip BGP table:

R2#sh ip bgp
BGP table version is 12, local router ID is 10.1.1.2
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
*  172.12.34.0/24   10.1.1.4                 0                             0 34 i
*>i                           10.1.1.3                 0        200               0 34 i
* i210.3.3.0            10.1.1.3                 0       100                0 34 i
*>                            10.1.1.4                 0                             0 34 i
R2#sh ip bgp 172.12.34.0
BGP routing table entry for 172.12.34.0/24, version 12
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x840
  Advertised to update-groups:
     2
  34
    10.1.1.4 from 10.1.1.4 (10.1.1.4)
      Origin IGP, metric 0, localpref 100, valid, external
  34
    10.1.1.3 from 10.1.1.1 (10.1.1.1)
      Origin IGP, metric 0, localpref 200, valid, internal, best
R2#

So as can be seen and expected from the Route-Maps configuration, the local pref (again #2 determiner of Best Path selection) has broke the tie, and best path to 172.12.34.0/24 is now through 10.1.1.1 while the logical network of 210.3.3.0/24 is still sticking to its Next Hop router R4. This can of course be adjusted by adding more routes to the ACL you are matching on in your Route-Map, or adding additional sequences to the Route-Map for additional clauses to be put in (like the catch all locprf 100 I set), the possibilities are endless (almost)!

Now that is actually really all there is to that, however I’d like to take a look at the Route-Map options we have to manipulate BGP attributes because you can fine tune it inside out with the list of “set” commands listed:

R1(config-route-map)#set ?
  as-path           Prepend string for a BGP AS-path attribute
  automatic-tag     Automatically compute TAG value
  clns              OSI summary address
  comm-list         set BGP community list (for deletion)
  community         BGP community attribute
  dampening         Set BGP route flap dampening parameters
  default           Set default information
  extcommunity      BGP extended community attribute
  interface         Output interface
  ip                IP specific information
  ipv6              IPv6 specific information
  level             Where to import route
  local-preference  BGP local preference path attribute
  metric            Metric value for destination routing protocol
  metric-type       Type of metric for destination routing protocol
  mpls-label        Set MPLS label for prefix
  nlri              BGP NLRI type
  origin            BGP origin code
  tag               Tag value for destination routing protocol
  traffic-index     BGP traffic classification number for accounting
  vrf               Define VRF name
  weight            BGP weight for routing table

Metric for MED, Local-Preference for this scenario, origin (change BGP origin code), AS_PATH, and at the very bottom Weight – Which just happens to be our next topic of discussion as it is the #1 looked at Attribute for Best Path Selection.

I need to re-cable the good ol NBMA and re-configure some things, I will see you on the next post and keep bum rushing through BGP until I cannot takes it any more! 🙂