Basically a community or communities allow for the grouping of prefixes that share a common set of principles utilizing transitive BGP attribute. These attribute consists of a set of four octet values that specify a community. The attribute values are encoded with an Autonomous System or AS number in the first two octets, with the remaining two octets containing the value. A prefix can have more than one community attribute and often does. The diagram below depicts a scenario with a Multihomed Customer, and a ISP providing two WAN connections one Ethernet, and other much slower Serial connection.   

BGP Community List

If we’re going to use Communities to tag routes with values then we’re going to need a way of controlling or accepting these tagged routes with values on the other end. That’s where BGP Community List come into play. They allow a Customer or Service Provider depending on the direction of the tagged routes to be acted upon when they arrive. Basically it’s like an ACL for tagged routes.  

BGP Community Format

Originally the default communities were formatted with a single large number that didn’t make a lot of sense. Fortunately with new version of IOS there is a new more meaningful and elegant format. This new format is in the form of ASN:VALUE which is much easier to understand.  However this new format must be specified within the configuration if you want to utilize it. I’ll cover this later in the configuration, on all three Routers, but I wanted to cover it before we get started.

Lets start off by getting the two WAN interfaces up and running on Router R1.

R1#configure terminal
R1(config)#interface f0/0
R1(config-if)#ip address 10.0.0.2 255.255.255.252
R1(config-if)#interface s0/0
R1(config-if)#ip address 10.0.1.2 255.255.255.252
R1(config-if)#end
R1#

Let’s get the Ethernet WAN interfaces on Service Provider’s PE Router SP1 up and running.

SP1#configure terminal
SP1(config)#interface f0/0
SP1(config-if)#ip address 10.0.0.1 255.255.255.252
SP1(config-if)#interface f0/1
SP1(config-if)#ip address 10.65.65.1 255.255.255.252
SP1(config-if)#end
SP1#

Now we can do the same with the much slower Serial WAN interfaces on the Service Providers other PE Router SP2 along with the iBGP Ethernet interface between SP2, and SP1. 

SP2#configure terminal
SP2(config)#interface s0/0
SP2(config-if)#ip address 10.0.1.1 255.255.255.252
SP2(config-if)#interface f0/1
SP2(config-if)#ip address 10.65.65.2 255.255.255.252
SP2(config-if)#end
SP2#

We need to create a simple ACL that we can use in conjunction with the Route Maps that will basically cover the three prefixes that we’re going to advertise from Router R1 upstream to Router SP1, and SP2. This is basically a summarized route covering all the loopback interfaces that we’re going to advertise upstream to Router SP1, and SP2.

R1#configure terminal
R1(config)#ip access-list extended 100
R1(config-ext-nacl)#permit ip 0.0.0.0 0.0.0.0 any log
R1(config-ext-nacl)#permit ip 172.16.0.0 0.0.255.255 any log
R1(config-ext-nacl)#exit
R1#  

Lets make sure we enable the BGP new format [ ASN:VALUE ] on Router R1 along with the default route pointed toward the Firewall for ALL internet related traffic as depicted in the the above diagram.

R1#configure terminal
R1(config)#ip bgp-community new-format
R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.4
R1(config)#end
R1#

Now that we basically have a summarized ACL for all the loop back interfaces lets move on with the creation of the Route Maps. The goal of the first Route Map LP-300 is to set the BGP Local Preference on Service Providers PE Router SP1 to 300.

R1#configure terminal 
R1(config)#route-map LP-300 permit 10
R1(config-route-map)#match ip address 100
R1(config-route-map)#set local-preference 300
R1(config-route-map)#exit
R1(config)# 

The goal of the second Route Map LP-200 is to set the BGP Local Preference upstream on the Service Providers PE Router SP2 to 200. By doing this we will assure that the preferred path taken is over the much fast Ethernet WAN connection as opposed tot he much slower Serial WAN connection. 

R1(config)#route-map LP-200 permit 10
R1(config-route-map)#match ip address 100
R1(config-route-map)#set local-preference 200
R1(config-route-map)#end
R1#

Now that we have the ACL in place along with the Route Maps lets jump into the BGP configuration on Router R1. Remember the Route Maps with the extended ACL don’t come into play until we’ve configure them with the Neighbors.

R1#configure terminal
R1(config)#router bgp 65000
R1(config-router)#bgp router-id 10.0.0.2
R1(config-router)#network 0.0.0.0
R1(config-router)#network 172.16.0.0 mask 255.255.255.0
R1(config-router)#network 172.16.1.0 mask 255.255.255.0
R1(config-router)#network 172.16.2.0 mask 255.255.255.0
R1(config-router)#network 172.16.3.0 mask 255.255.255.0
R1(config-router)#neighbor 10.0.0.1 remote-as 500
R1(config-router)#neighbor 10.0.0.1 next-hop-self
R1(config-router)#neighbor 10.0.0.1 send-community both
R1(config-router)#neighbor 10.0.0.1 route-map LP-300 out
R1(config-router)#neighbor 10.0.1.1 remote-as 500
R1(config-router)#neighbor 10.0.1.1 next-hop-self
R1(config-router)#neighbor 10.0.1.1 send-community both
R1(config-router)#neighbor 10.0.1.1 route-map LP-200 out
R1(config-router)#end
R1#

Building Community Lists

Personally I struggled with the concept of BGP Communities ( Route Tagging ) that is until I discovered BGP Community List. Lets face it what’s the point in tagging routes, and sending them upstream or downstream if the Router on the other end doesn’t know what do with them.! Once you have a Community List in place that matches the tagging your sending you can begin to put routing policies in place. So with that said lets create a couple of BGP Community List on Service Provider’s router SP1.

SP1#configure terminal
SP1(config)#ip bgp-community new-format
SP1(config)#ip community-list 1 permit 500:300
SP1(config)#

Now lets jump over to the Service Provider router SP2 and do the same thing.

SP2#configure terminal
SP2(config)#ip bgp-community new-format
SP2(config)#ip community-list 1 permit 500:200
SP2(config)#

Now that we have our Community List in place lets move onto configuring the Route Map.

SP1(config)#route-map MATCH permit 10
SP1(config-route-map)#match community 1
SP1(config-route-map)#set local-preference 300
SP1(config-route-map)#exit
SP1(config)#

Now lets jump back over to Service Provider router SP2 and do the opposite inverse. 

SP2(config)#route-map MATCH permit 10
SP2(config-route-map)#match community 1
SP2(config-route-map)#set local-preference 200
SP2(config-route-map)#exit
SP2(config)#

Ok now that we have the preliminary work done we can move onto BGP configuration on SP1, and SP2.

SP1(config)#router bgp 500
SP1(config-router)#bgp router-id 10.0.0.1
SP1(config-router)#redistribute connected
SP1(config-router)#neighbor 10.0.0.2 remote-as 65000
SP1(config-router)#neighbor 10.0.0.2 route-map MATCH in
SP1(config-router)#neighbor 10.65.65.2 remote-as 500
SP1(config-router)#exit
SP1#

Now lets move over to the Service Provider Router SP2 and get BGP up and running.

SP2(config)#router bgp 500
SP2(config-router)#bgp router-id 10.0.1.1
SP2(config-router)#redistribute connected
SP2(config-router)#neighbor 10.0.1.2 remote-as 65000
SP2(config-router)#neighbor 10.0.1.2 route-map MATCH in
SP2(config-router)#neighbor 10.65.65.1 remote-as 500
SP2(config-router)#exit
SP2#

Now lets take a look the BGP Table on Service Provider Router R1.

SP1#show ip bgp | beg Network

Network            Next Hop         Metric  LocPrf  Weight   Path
*> 0.0.0.0         10.0.0.2              0     300       0   65000 i
*> 10.0.0.0/30     0.0.0.0               0           32768   ?
*>i10.0.1.0/30     10.65.65.2            0     100       0   ?
* i10.65.65.0/30   10.65.65.2            0     100       0   ?
*> 0.0.0.0 0                                         32768   ?
*> 172.16.0.0/24   10.0.0.2              0     300       0   65000 i
*> 172.16.1.0/24   10.0.0.2              0     300       0   65000 i
*> 172.16.2.0/24   10.0.0.2              0     300       0   65000 i
*> 172.16.3.0/24   10.0.0.2              0     300       0   65000 i
*> 172.16.4.0/24   10.0.0.2              0     300       0   65000 i

That’s exactly what were looking for a Local Preference of 300  

SP2#show ip bgp | begin Network

 Network           Next Hop         Metric   LocPrf   Weight   Path
*>i0.0.0.0         10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i
*>i10.0.0.0/30     10.65.65.1            0      100        0   ?
*> 10.0.1.0/30     0.0.0.0               0                     32768 ?
*> 10.65.65.0/30   0.0.0.0               0                     32768 ?
* i 10.65.65.1                           0      100        0   ?
*>i172.16.0.0/24   10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i
*>i172.16.1.0/24   10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i
*>i172.16.2.0/24   10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i
*>i172.16.3.0/24   10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i
*>i172.16.4.0/24   10.0.0.2              0      300        0   65000 i
* 10.0.1.2                               0      200        0   65000 i

We can see from the above output of the BGP table on Service Provider Router R2 that it has both the preferred Local Preference of 300 along with the less preferred Local Preference of 200.

I hope you found this post on Building Community helpful and informative. Be sure to let me know what you think by leaving suggestions, and feedback in the comments section below. You can find out more about these and other articles be checking out recent posts and archives. To learn more about me be sure to check out the About page. And as always thanks again for visiting The Packet.