BGP Communities

This is small topic about using the communities in BGP. I’m going to use the topology from previous topic, which was about “MPLS VPN”.
As you remember, R1 had generated an aggregate route to R3. But customer B’s router, R2, had advertised routes to R3 as they were, without summarization. What I want to do is generating communities on R1 and R2 and test routes on other sites to see if they are there. First we need a route-map on R1 and R2 to attach communities to routes. This route-map is used with “network” command in BGP router configuration mode. Our route-maps can be like these:

R1(config-router)#do sh route-map
route-map SET_COM, permit, sequence 10
  Match clauses:
  Set clauses:
    community 1:1111 1:1112
  Policy routing matches: 0 packets, 0 bytes
R1(config-router)#
R2(config-router)#do sh route-map
route-map SET_COM, permit, sequence 10
  Match clauses:
  Set clauses:
    community 2:2222 2:2223
  Policy routing matches: 0 packets, 0 bytes
R2(config-router)#

By default, the community values are shown in old-format and if you need to see them in new-format which is 4-byte format, you must use “ip bgp-community new-format” in global configuration mode. Now we need to apply the route-map to the routes advertised by “network” command into BGP.

R2(config-router)#do sh run
router bgp 2
address-family ipv4 vrf B
  neighbor 123.123.123.3 remote-as 345
  neighbor 123.123.123.3 send-community
  network 2.2.2.2 mask 255.255.255.255 route-map SET_COM
  network 2.2.2.3 mask 255.255.255.255 route-map SET_COM
 exit-address-family

I applied route-map just on the routes in VRF B and don’t want the global prefixes to be affected by our route-map. By default, communities don’t pass to peers, and we need to use “send-community” command too.
An important trick is, if you want to aggregate route to inherit the community values from its subnets, you should preserve the details of individual subnets with “as-set” command or by using attribute-map. Without these, the inheritance doesn’t apply to summary route. With these in mind, let’s apply our route-map in R1:

R1(config-router)#do sh run  | sec bgp
router bgp 1
address-family ipv4 vrf A
  neighbor 133.133.133.3 remote-as 345
  neighbor 133.133.133.3 activate
  neighbor 133.133.133.3 send-community
  no synchronization
  network 1.1.1.1 mask 255.255.255.255 route-map SET_COM
  network 1.1.1.2 mask 255.255.255.255 route-map SET_COM
  aggregate-address 1.1.1.0 255.255.255.252 summary-only
 exit-address-family

To see if the communities are present on R3, we need to see the details of routes received by R3.

R3(config)#do sh ip bgp vpnv4 vrf A 1.1.1.1
BGP routing table entry for 1:1:1.1.1.0/30, version 65
Paths: (1 available, best #1, table A)
Flag: 0x820
  Advertised to update-groups:
        3
  1, (aggregated by 1 1.1.1.4)
    133.133.133.1 from 133.133.133.1 (1.1.1.4)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 1:1111 1:1112
      Extended Community: RT:1:1
      mpls labels in/out 16/nolabel
R3(config)#
R3(config)#do sh ip bgp vpnv4 vrf B 2.2.2.2
BGP routing table entry for 2:2:2.2.2.2/32, version 28
Paths: (1 available, best #1, table B)
  Advertised to update-groups:
        3
  2
    123.123.123.2 from 123.123.123.2 (2.2.2.5)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 2:2222 2:2223
      Extended Community: RT:2:2
      mpls labels in/out 24/nolabel

And we did! At the second phase we need to configure R3 to pass the communities to its peers too toward R6 and R7. This was done before while we were configuring MP-BGP and R5 should get the communities by now:

R5(config-router)#do sh ip bgp vpnv4 vrf A 1.1.1.1
BGP routing table entry for 1:1:1.1.1.0/30, version 70
Paths: (1 available, best #1, table A)
Flag: 0x820
  Advertised to update-groups:
        1
  1, (aggregated by 1 1.1.1.4)
    3.3.3.3 (metric 21) from 3.3.3.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: 1:1111 1:1112
      Extended Community: RT:1:1
      mpls labels in/out nolabel/16
R5(config-router)#do sh ip bgp vpnv4 vrf A 2.2.2.2
BGP routing table entry for 2:2:2.2.2.2/32, version 68
Paths: (1 available, best #1, table B)
  Advertised to update-groups:
        2
  2
    3.3.3.3 (metric 21) from 3.3.3.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Community: 2:2222 2:2223
      Extended Community: RT:2:2
      mpls labels in/out nolabel/24

Everything is good. Now we need to configure R5 for passing communities to R6 and R7.

R5(config-router)#do sh run  | sec bgp
router bgp 345
address-family ipv4 vrf B
  neighbor 156.156.156.6 remote-as 2
  neighbor 156.156.156.6 activate
  neighbor 156.156.156.6 send-community
  neighbor 156.156.156.6 as-override
  no synchronization
 exit-address-family
 !        
 address-family ipv4 vrf A
  neighbor 157.157.157.7 remote-as 1
  neighbor 157.157.157.7 activate
  neighbor 157.157.157.7 send-community
  neighbor 157.157.157.7 as-override
  no synchronization
 exit-address-family

Final test on R6 and R7 for communities:

R6(config)#do sh ip bgp vpnv4 vrf B 2.2.2.2
BGP routing table entry for 2:2:2.2.2.2/32, version 45
Paths: (1 available, best #1, table B)
  Not advertised to any peer
  345 345
    156.156.156.5 from 156.156.156.5 (5.5.5.5)
      Origin IGP, localpref 100, weight 0, valid, external, best
      Community: 0:2222 2:2223
      mpls labels in/out 19/nolabel
R7(config-router)#ip bgp new
R7(config)#do sh ip bgp vpnv4 vrf A 1.1.1.1
BGP routing table entry for 1:1:1.1.1.0/30, version 25
Paths: (1 available, best #1, table A)
Flag: 0x820
  Not advertised to any peer
  345 345, (aggregated by 1 1.1.1.4)
    157.157.157.5 from 157.157.157.5 (5.5.5.5)
      Origin IGP, localpref 100, valid, external, best
      Community: 1:1111 1:1112
      mpls labels in/out 17/nolabel

OK! We finished our configuration here. If you’re thinking of applicability of communities, I’m going to show a simple scenario about them here for bonus! Communities are like some kinds of labels and we can use them to categorize routes and do what we need to do with classified routes based on communities. For example, I want to use communities on R6 to increase the Weight value of routes. Matching routes based on their community values is done by community lists. So what we are going to write is a community list that points to our community value on R6:

ip community-list 1 permit 2:2222
!
route-map MATCH_COM permit 10
 match community 1
 set weight 2222
 set comm-list 1 delete
 set community 0:2000 additive

With this route-map we selected routes with community-list “1” which points to routes that have “2:2222” community and then set their weight to “2222”. So what’s the last 2 lines? These lines manipulate the community values. Actually the “set comm-list” command deletes whatever community values mentioned by community list 1. The community list 1 has community value of “2:2222”, so “set comm- list 1 delete” command will delete “2:2222” value from routes. Then the “set community 0:2000 additive” command adds another community value of “0:2000” to the routes. By rules, if both of commands “set comm-list” and “set community” are presented simultaneously inside a route-map, the “set comm-list” command takes precedence. Final step is applying this route-map to the VRF routes received by R5 router.

R6(config)#do sh run
router bgp 2
 address-family ipv4 vrf B
  neighbor 156.156.156.5 route-map MATCH_COM in

After resetting the BGP relationship, now we will have our changes in place:

R6(config)#do sh ip bgp vpnv4 vrf B 2.2.2.2
BGP routing table entry for 2:2:2.2.2.2/32, version 45
Paths: (1 available, best #1, table B)
  Not advertised to any peer
  345 345
    156.156.156.5 from 156.156.156.5 (5.5.5.5)
      Origin IGP, localpref 100, weight 2222, valid, external, best
      Community: 0:2000 2:2223
      mpls labels in/out 19/nolabel

You see that the Weight value is set to 2222 and the community values are “0:2000 2:2223”.

Leave a Comment

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

* Copy This Password *

* Type Or Paste Password Here *

2,050 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>