BGP Communities Explained and Configuration Example [GNS3 Lab]

BGP Communities Explained and Configuration Example [GNS3 Lab]

What are BGP communities

The BGP community is the tagging mechanism we use to mark BGP prefixes.

The BGP community is an Optional, Transitive BGP attribute, meaning that if they exist they should be propagated to all BGP neighbors.

When the neighbor receives the prefix it will examine the community value:

  • it can ignore it (if no route map is configured to match the community and take action)
  • it takes an action whether it is filtering or modifying other attributes.


A BGP prefix (route) can have more than one community. Each community can lead to a specific unique action. (you can attach up to 32 communities to a single route).

BGP Communities Types

* Standard communities: numeric 32-bit tags in (AS: Action) format

The primary purpose of standard communities is to group and tag routes so that actions can perform.

The BGP community can be displayed in 2 ways:

  • The full 32-bit format (5, 658)
  • New-format: as two 16-bit numbers (0-65535):(0-65535)


* Large Communities: numeric 96-bit tags in (Source AS:Action: Target AS) format split into three 32-bit values which can give more identification data including 4-byte AS numbers.

* Extended communities: numeric 64-bit tags in (Type:AS: Membership) format

MPLS VPN is an example where the Route Target (RT) extended community use to control the exporting and importing of VPN routes.


Well-known BGP communities

The four well-known communities that can use to mark prefixes; are listed as follows:

  • Internet: advertise these tagged routes to all neighbors (IBGP & EBGP).               
  • Local-as: prevent sending tagged routes outside the local AS within the confederation. (route will not send to any EBGP neighbor or any intra-confederation external neighbor )
  • No-Advertise: do not advertise this tagged route to any peer, internal or external (IBGP & EBGP) (tell receiving router to keep the tag to yourself and do not pass it to any neighbor).
  • No-Export: do not advertise this tagged route to EBGP peers, in other meaning Only advertise to IBGP neighbors.

BGP community Configuration Example

Topology


I- Prepare BGP peering:

  • R1:
R1(config)#int f0/0
R1(config-if)#ip address 172.31.20.1 255.255.255.252
R1(config-if)#no sh
R1(config-if)#
*Jun 14 14:22:18.755: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Jun 14 14:22:19.755: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f0/1
R1(config-if)#ip address 172.31.30.1 255.255.255.252
R1(config-if)#no sh
R1(config-if)#exit

*Jun 14 14:22:31.783: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Jun 14 14:22:32.783: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#router bgp 65001
R1(config-router)#neighbor 172.31.20.2 remote-as 65002


  • R2:
R2(config)#int f0/0
R2(config-if)#ip address 172.31.20.2 255.255.255.252
R2(config-if)#no sh
R2(config-if)#exit
*Jun 14 14:22:57.007: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Jun 14 14:22:58.007: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R2(config)#router bgp 65002
R2(config-router)#neighbor  172.31.20.1 REMoTe-as 65001


  • R3:
R3(config)#int f0/0
R3(config-if)#ip address 172.31.30.2 255.255.255.252
R3(config-if)#no sh
R3(config-if)#end

*Jun 14 14:23:22.627: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Jun 14 14:23:23.627: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R3#conf t
R3(config)#router bgp 65003
R3(config-router)#neighbor 172.31.30.1 remote-as 65001
R3(config-router)#END


  • Verification of BGP peering establishment:
R1#show ip bgp summary
BGP router identifier 172.31.30.1, local AS number 65001
BGP table version is 1, main routing table version 1

Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.31.20.2     4        65002       5       5        1    0    0 00:01:27        0
172.31.30.2     4        65003       4       2        1    0    0 00:00:38        0


  • Verification of BGP routing table:
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1 subnets
B        4.4.4.4 [20/0] via 172.31.20.2, 00:01:15
      172.31.0.0/16 is variably subnetted, 4 subnets, 2 masks
C        172.31.20.0/30 is directly connected, FastEthernet0/0
L        172.31.20.1/32 is directly connected, FastEthernet0/0
C        172.31.30.0/30 is directly connected, FastEthernet0/1
L        172.31.30.1/32 is directly connected, FastEthernet0/1

R1#show ip bgp
BGP table version is 6, local router ID is 172.31.30.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   4.4.4.4/32       172.31.30.2              0             0 65003 i
 *>                   172.31.20.2              0             0 65002 i



II-Define the BGP communities on R2 and R3:

  • R2:
ip prefix-list Low_quality seq 5 permit 4.4.4.4/32

route-map Low_q permit 10
 match ip address prefix-list Low_quality
 set community 10:100

ip bgp-community new-format

router bgp 65002
 neighbor 172.31.20.1 send-community
 neighbor 172.31.20.1 send-community extended
 neighbor 172.31.20.1 route-map Low_q out


  • R3:

ip prefix-list high_quality seq 5 permit 4.4.4.4/32

route-map high_q permit 10
 match ip address prefix-list high_quality
 set community 10:200

ip bgp-community new-format

router bgp 65003
 neighbor 172.31.30.1 send-community
 neighbor 172.31.30.1 send-community extended
 neighbor 172.31.30.1 route-map high_q out


III-Verify the BGP communities on R1:

We can see on R1 that the prefix 4.4.4.4/32 is received in R1 with a different community (tag) for each peer:

  • 172.31.20.2 with community 10:100
  • 172.31.30.2 with community 10:200


R1#show ip bgp 4.4.4.4
BGP routing table entry for 4.4.4.4/32, version 7
Paths: (2 available, best #2, table default)
  Advertised to update-groups:
     1
  Refresh Epoch 1

  65003
    172.31.30.2 from 172.31.30.2 (172.31.30.2)
      Origin IGP, metric 0, localpref 100, valid, external
      Community: 10:200
      rx pathid: 0, tx pathid: 0
  Refresh Epoch 1

  65002
    172.31.20.2 from 172.31.20.2 (172.31.20.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 10:100
      rx pathid: 0, tx pathid: 0x0


IV- Specify Actions (policies) for the received communities on R1:

Now, we can assign a specific action for each Community tag:

for Example:

  • Assign high-weight attribute to the community 10:200
  • Assign low weight attribute to the community 10:100

This configuration will make R3 a preferred neighbor for the 4.4.4.4/32 prefix ( and all prefixes with the same community)

ip bgp-community new-format
ip community-list expanded High_W permit 10:200
ip community-list expanded Low_W permit 10:100

route-map Prefer3 permit 10
 match community High_W
 set weight 100

route-map Prefer3 permit 20
 match community Low_W
 set weight 10

router bgp 65001
 neighbor 172.31.20.2 route-map Prefer3 in
 neighbor 172.31.30.2 route-map Prefer3 in


V- Verifications

We can see that the Preferred BGP neighbor for the subnet 4.4.4.4/32 has been influenced by the actions associated with the BGP communities received from the neighbors.

R1#show ip bgp
BGP table version is 2, local router ID is 172.31.30.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
 *   4.4.4.4/32       172.31.20.2              0            10 65002 i
 *>                   172.31.30.2              0           100 65003 i


R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1 subnets
B        4.4.4.4 [20/0] via 172.31.30.2, 00:01:06
      172.31.0.0/16 is variably subnetted, 4 subnets, 2 masks
C        172.31.20.0/30 is directly connected, FastEthernet0/0
L        172.31.20.1/32 is directly connected, FastEthernet0/0
C        172.31.30.0/30 is directly connected, FastEthernet0/1
L        172.31.30.1/32 is directly connected, FastEthernet0/1



https://learningnetwork.cisco.com/s/article/BGP-Zero-to-Hero-Part-7–BGP-Communities

Bilel

Bilel

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x