BGP Essentials: BGP Communities

BGP communities are extra attributes you can attach to an IP route carried by BGP. You can use communities to indicate which routes should be propagated or filtered (for example, the well-known NO_EXPORT community signifies that the route it’s attached to shall not be sent outside of the local AS), to influence route selection on remote routers or to trigger other BGP-dependent IOS features (for example, quality-of-service marking based on BGP).

Each BGP community is a 32-bit value. The best practice dictates that the top 16 bits should be the AS number of the network defining the community meaning and the bottom 16 bits are defined by the network administrator.

For example, if you use BGP communities to control QoS marking within your network, the top 16 bits should be your AS number. If you’re using a BGP community to mark backup BGP routes before they are sent to your ISP, you should use the BGP community defined by your ISP (and thus the top 16 bits are the ISP’s AS number).

The only mechanism to set BGP community in Cisco IOS is the set community command in a route-map.

Important: The set community command erases existing communities attached to a route and replaces them with the new set of communities unless you specify the additive option.

You can set BGP communities in any point where you can use a route-map within BGP:

  • on routes you’re receiving from a neighbor with the neighbor route-map in router configuration command;
  • on routes you’re sending to a neighbor with the neighbor route-map out router configuration command;
  • on routes originated into BGP with the network route-map router configuration command;
  • on routes redistributed into BGP with the redistribute route-map router configuration command.

The BGP communities are transitive BGP attribute, meaning that they should be propagated to all BGP neighbors.

Important: Cisco IOS does not propagate BGP communities unless you manually configure community propagation for each neighbor with the neighbor send-community configuration command. BGP peer groups or peer templates are an excellent way to configure BGP community propagation for a large number of peers.

If you're looking for more in-depth BGP knowledge, try our Configuring BGP on Cisco Routers e-learning solution. If you just need to enhance your hands-on skill, the BGP Remote Lab Bundle is the perfect choice.

12 comments:

  1. Nice one...helped a lot

    ReplyDelete
  2. Yap Chin Hoong11 June, 2010 03:14

    Hi Ivan, the 3rd bullet point should be "network route-map in" instead of simply "network route-map". Thanks. 8-)

    ReplyDelete
  3. Ivan Pepelnjak11 June, 2010 21:24

    Nope, it's correct syntax. It's a route map applied to a network statement, not to a neighbor.

    ReplyDelete
  4. Thanks for this post ; I was wondering if there was some restriction for the "set community" with the route-maps (ie, in input or output), this make things very clear :)

    ReplyDelete
  5. Mohamed Kamal09 July, 2010 16:02

    Hi Ivan,

    I appreciate if you can write a short form of a post about the usage of "network route-map" command, as it's unclear to many people. In addition, there are very few and rare documents which explain the usage of route-map with the network command.

    Thanks Ivan :)

    ReplyDelete
  6. Ivan Pepelnjak09 July, 2010 19:52

    "network route-map" allows you to set attributes of the BGP network you're originating. In most cases you'd use it to set BGP community or MED.

    ReplyDelete
  7. ip bgp new-format can be done to show the community format in the 65001:17 format instead of the long format.

    You can also create a community list which permits only a specified community... sorta like an as-path access-list.

    Ex. #ip community-list 1 permit 65001:17

    Then you wan to match on that community-list.

    #route-map CLIST_IN permit 10
    #match community 1 (leave off the -list)

    ReplyDelete
  8. need more details..

    ReplyDelete
  9. need more detail on match list

    ReplyDelete
  10. My query is basically in the context of vrf. Suppose a CE comprises multiple VRF to connect to different customers and eBGP is used as an PE-CE routing protocol.

    Consider an eBGP route update (without a RT value) is received by a BGP peer in a VRF and successfully installed in the VRF routing table.
    Also consider that the same VRF is configured with a export map which has a match criteria for this received prefix and set action to attach an RT vlaue (65500:5).

    If there is no requirement exist in this VRF to advertise this received prefix to any other BGP peer, will the configured export map come in action to set the RT vlaue (6500:5) with the received and already existing prefix entry in the BGP table?

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.