BGP Community Attribute

L’attribut « Community » est un nombre de 32bits positionné sur chaque prefix ( un tag ) qui est transmis au voisin BGP afin permettre divers action sur ces routes (filtrage, route-policy , …)

  • Valeur numérique de 1 à 4294967295
  • Souvent représenté par x:y , où x est le numéro d’AS (1-65535) et y une valeur propre à l’AS (1-65535)
  • Par défaut, l’attribut « Community » n’est envoyé

L’attribut « Community » peut également prendre un valeur prédéfinie :

  • Internet
  • Local-as
  • No-advertise
  • No-export

Par défaut, l’attribut n’existe pas:

R2#show ip bgp 1.0.0.0
BGP routing table entry for 1.0.0.0/8, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1
  100
    10.1.1.1 from 10.1.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best

 

no-advertise

R1 
access-list 1 permit 1.0.0.0 0.255.255.255
!
route-map TEST permit 10
 match ip address 1
 set community no-advertise
!
route-map TEST permit 20
!

router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 1.0.0.0
 neighbor 10.1.12.2 remote-as 2300
 neighbor 10.1.12.2 send-community
 neighbor 10.1.12.2 route-map TEST out
 no auto-summary
R2
R2#show ip bgp 1.0.0.0
BGP routing table entry for 1.0.0.0/8, version 8
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to any peer)
  Not advertised to any peer
  100
    10.1.12.1 from 10.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-advertise

no-export

R5
access-list 1 permit 5.0.0.0 0.255.255.255
!
route-map TEST permit 10
 match ip address 1
 set community no-export
!
route-map TEST permit 20
!
router bgp 500
 no synchronization
 bgp router-id 5.5.5.5
 bgp log-neighbor-changes
 network 5.0.0.0
 neighbor 10.1.35.3 remote-as 2300
 neighbor 10.1.35.3 send-community
 neighbor 10.1.35.3 route-map TEST out
 no auto-summary
R3
R3#show ip bgp 5.0.0.0
BGP routing table entry for 5.0.0.0/8, version 12
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
  Advertised to update-groups:
     1
  500
    10.1.35.5 from 10.1.35.5 (5.5.5.5)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: no-export

local-AS

R3#show ip bgp 3.0.0.0
BGP routing table entry for 3.0.0.0/8, version 19
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised outside local AS)
  Advertised to update-groups:
     1
  Local
    0.0.0.0 from 0.0.0.0 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
      Community: local-AS

 

internet

R2#show ip bgp 1.0.0.0
BGP routing table entry for 1.0.0.0/8, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1          2
  100
    10.1.12.1 from 10.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: internet

Exemple

R2 renseigne l’attribut de communauté des prefix qu’il annonce à R1 20.1.2.0 -> 2 , 20.1.3.0 -> 3

access-list 2 permit 20.1.2.0 0.0.0.255
access-list 3 permit 20.1.3.0 0.0.0.255
!
route-map TEST permit 10
 match ip address 2
 set community 2
!
route-map TEST permit 20
 match ip address 3
 set community 3
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 20.1.2.0 mask 255.255.255.0
 network 20.1.3.0 mask 255.255.255.0
 neighbor 10.1.12.1 remote-as 100
 neighbor 10.1.12.1 send-community
 neighbor 10.1.12.1 route-map TEST out
 no auto-summary

R3 renseigne l’attribut de communauté des prefix qu’il annonce à R1 30.1.2.0 -> 2 , 30.1.3.0 -> 3

access-list 2 permit 30.1.2.0 0.0.0.255
access-list 3 permit 30.1.3.0 0.0.0.255
!
route-map TEST permit 10
 match ip address 2
 set community 2
!
route-map TEST permit 20
 match ip address 3
 set community 3
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 30.1.2.0 mask 255.255.255.0
 network 30.1.3.0 mask 255.255.255.0
 neighbor 10.1.13.1 remote-as 100
 neighbor 10.1.13.1 send-community
 neighbor 10.1.13.1 route-map TEST out
 no auto-summary

Utilisation de l’attribut « community »

  • 10.1.12.2 = R1
  • 10.1.13.2 = R2
R1#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*> 20.1.2.0/24      10.1.12.2                0             0 200 i
*> 20.1.3.0/24      10.1.12.2                0             0 200 i
*> 30.1.2.0/24      10.1.13.3                0             0 300 i
*> 30.1.3.0/24      10.1.13.3                0             0 300 i
R1#show ip bgp community 2
   Network          Next Hop            Metric LocPrf Weight Path
*> 20.1.2.0/24      10.1.12.2                0             0 200 i
*> 30.1.2.0/24      10.1.13.3                0             0 300 i
R1#show ip bgp community 3
   Network          Next Hop            Metric LocPrf Weight Path
*> 20.1.3.0/24      10.1.12.2                0             0 200 i
*> 30.1.3.0/24      10.1.13.3                0             0 300 i

Les prefix 20.x.x.x ont comme next hop R2 , les prefix 30.x.x.x ont comme next hop R3

R1 modifie le Next Hop en se basant sur la communauté :

ip community-list standard TEST2 permit 2
ip community-list standard TEST3 permit 3
!
!
route-map TEST permit 10
 match community TEST2
 set ip next-hop 10.1.12.2
!
route-map TEST permit 20
 match community TEST3
 set ip next-hop 10.1.13.3
!
route-map TEST permit 30
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 1.0.0.0
 neighbor 10.1.12.2 remote-as 200
 neighbor 10.1.12.2 route-map TEST in
 neighbor 10.1.13.3 remote-as 300
 neighbor 10.1.13.3 route-map TEST in
 no auto-summary

Vérifications :

R1#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*> 20.1.2.0/24      10.1.12.2                0             0 200 i
*> 20.1.3.0/24      10.1.13.3                0             0 200 i
*> 30.1.2.0/24      10.1.12.2                0             0 300 i
*> 30.1.3.0/24      10.1.13.3                0             0 300 i
  • 10.1.12.2 = R1
  • 10.1.13.2 = R2
This entry was posted in BGP. Bookmark the permalink.

Comments are closed.