BGP Communities

A community is a group of prefixes that share some common property and can be configured with the transitive BGP community attribute. A prefix can have more than one community attribute. Routers can act on one, some or all the attributes. BGP communities can be thought of as a form of tagging. The following is an example of a BGP communities configuration.

router bgp 12345
: bgp router-id 10.50.165.233
: network 12.34.5.0/24
: network 23.45.6.0/24
: neighbor 10.50.165.228 remote-as 7675
: neighbor 10.50.165.228 send-community
: neighbor 10.50.165.228 route-map comm out
!
access-list 105 permit 12.34.5.0/24
access-list 110 permit 23.45.6.0/24
!
route-map comm permit 10
: match ip address 105
: set community 7675:300
!
route-map comm permit 20
: match ip address 110
: set community 7675:500
!
router bgp 7675
: bgp router-id 10.50.165.228
: network 7.6.7.0/24
: neighbor 10.50.165.233 remote-as 12345
: neighbor 10.50.165.233 route-map shape in
!
ip community-list 1 permit 7675:300
ip community-list 2 permit 7675:500
!
route-map shape permit 10
: match community 1
: set local preference 120
 
route-map shape permit 20
: match community 2
: set local preference 130