BGP Communities

By | May 16, 2012
Warning: Trying to access array offset on value of type null in /customers/3/0/4/ on line 72

In this post we are going to use the BGP community PA to set the Local preference for our routes. We will be using the following diagram

The Local Preference is a BGP Path Attribute (PA) which is a well-known discretionary PA. The route with the highest Local Preference is preferred over the route with the lower Local Preference.

Our objective for this lab is to make sure our traffic uses our main line and not the backup line. The focus of this lab is on R1 which is in our Autonomous System.

Once we have set up our neighbors we need to check the BGP table to see what we have. This is done using the “show ip bgp” command.

The table show that the best path to the 10.1.x.x networks are from our neighbor which is R2 in our example. Let’s check this by doing a traceroute.

We can see that we are using the route from R2 to get to 10.1.x.x network. Now let’s check if we are getting the communities from R2 and R3.

We can see we are getting communities from R2 and R3. For this example we are going to use the RFC 1997 which defines BGP communities in a new format as AA:NN. To do this we will use the following command in config mode.

ip bgp-community new-format

Now lets see what the difference is.

The community string is now displayed as AA:NN instead of a long number. Now we want to match theses communities and set the Local Preference to 200 for R2 and 300 for R3. We can do this using a community list and a route map.

ip bgp-community new-format
ip community-list standard R2 permit 2:200
ip community-list standard R3 permit 3:200
route-map R2-COM permit 10
 match community R2
 set local-preference 200
route-map R2-COM permit 20
route-map R3-COM permit 10
 match community R3
 set local-preference 300
route-map R3-COM permit 20

Now we need to apply this to our neighbours in the inbound direction. before the changes take effect we need to used the following command for exec mode.

clear ip bgp * soft in

now let’s have a look at the BGP table once again.

We can now see that the Local Preference has been added to meet our requirements and neighbour is now our best part in the BGP table. Let’s do a traceroute to see how our packets are going across.

We can see we are now using R3 to send our traffic to the 10.1.x.x networks and have successfully met our objectives.

Appendix (BGP Load Balancing).

Rather then doing a complete new post I thought I would add BGP load balancing to the end of this one as its just a single command. To configure load balancing for our network we need to first remove the route maps from the neighbours and then simply add this command under the BGP process.

 maximum-paths 2

Lets verify if this is working by checking the routing table.

We can see each network has 2 paths. Now let’s check if it’s working using a tracroute

We can see that it is using both paths and we have successfully configured load balancing.