BGP Basics – modifying attributes

By | May 21, 2014

The previous post in this series looked at the exchange of routes between BGP peers, and this post takes this a step further by looking at two BGP attributes that can be modified to influence how a router decides which routes to place in it’s routing table – WEIGHT and LOCAL PREFERENCE

Here’s our example network and initial BGP configs:

BGP Basics - Modifying Attributes

R1#sh run | s router 
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 123
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary

R2#sh run | s router
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 123
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 1.1.1.1 next-hop-self
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 update-source Loopback0
 neighbor 4.4.4.4 remote-as 4
 neighbor 4.4.4.4 ebgp-multihop 2
 neighbor 4.4.4.4 update-source Loopback0
 no auto-summary

R3#sh run | s router
router bgp 123
 no synchronization
 bgp log-neighbor-changes
 network 192.168.3.0
 neighbor 1.1.1.1 remote-as 123
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 1.1.1.1 next-hop-self
 neighbor 2.2.2.2 remote-as 123
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 4.4.4.4 remote-as 4
 neighbor 4.4.4.4 ebgp-multihop 2
 neighbor 4.4.4.4 update-source Loopback0
 no auto-summary

R4#sh run | s router
router bgp 4
 no synchronization
 bgp log-neighbor-changes
 network 192.168.4.0
 neighbor 2.2.2.2 remote-as 123
 neighbor 2.2.2.2 ebgp-multihop 2
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 3.3.3.3 remote-as 123
 neighbor 3.3.3.3 ebgp-multihop 2
 neighbor 3.3.3.3 update-source Loopback0
 no auto-summary

We can see that R1 has 2 valid paths to the 192.168.4.0/24 network and the best route (via R2) has been placed in it’s routing table:

R1#sh ip bgp
BGP table version is 4, local router ID is 1.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
*>i192.168.4.0      2.2.2.2                  0    100      0 4 i
* i                 3.3.3.3                  0    100      0 4 i

R1#sh ip route bgp
B    192.168.4.0/24 [200/0] via 2.2.2.2, 00:05:48

WEIGHT

WEIGHT is an attribute local to the router it is configured on, and is set per neighbour. As we can see from R1’s BGP table above, the default value for WEIGHT is 0. In this example we’ll set R1’s WEIGHT attribute for R3 to 100 so that R3 becomes the preferred path to the 192.168.4.0/24 network:

R1(config)#router bgp 123               
R1(config-router)#neighbor 3.3.3.3 weight 100

Reset the peers to see the effect of this on R1’s BGP table:

R1#clear ip bgp *

R1#sh ip bgp      
BGP table version is 2, local router ID is 1.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
*>i192.168.4.0      3.3.3.3                  0    100    100 4 i
* i                 2.2.2.2                  0    100      0 4 i

The Weight for R3 is now 100, so the best path is now via R3. R1 places this route in it’s routing table:

R1#sh ip route bgp
B    192.168.4.0/24 [200/0] via 3.3.3.3, 00:00:14

LOCAL PREFERENCE

This can be advertised from a router to other routers within same (local) AS, and has a value of 100 by default. In this example we’ll configure a local preference on R3 of 200, to achieve the same end result as before.

First we’ll remove the WEIGHT config from the first example:

R1(config)#router bgp 123
R1(config-router)#no neighbor 3.3.3.3 weight 100
R1(config-router)#do clear ip bgp * 

Next, we’ll configure R3 so it has a LOCAL PREFERENCE of 200:

R3(config)#router bgp 123                  
R3(config-router)#bgp default local-preference 200
R3(config-router)#do clear bgp *

Remember that this attribute is local to the AS (123 in this case) so to verify this we can check R1’s bgp and routing tables:

R1#sh ip bgp      
BGP table version is 9, local router ID is 1.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
*>i192.168.4.0      3.3.3.3                  0    200      0 4 i

R1#sh ip route bgp
B    192.168.4.0/24 [200/0] via 3.3.3.3, 00:01:36

From the output above we can see that R1 now only has 1 valid and best path to 192.168.4.0/24, and it is via R3.

I hope this has been a useful explanation. Thanks for reading, and good luck with your CCNP studies!

Rich

Follow Rich on Twitter

2 thoughts on “BGP Basics – modifying attributes

  1. Larry Mason

    Thank you Rich!! Best I’ve seen so far! Can you please post a BGP community article?

    Reply
    1. Rich Bibby Post author

      Thanks Larry! I’ve not written any more BGP articles for a few years now

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *