This document describes how to use BGP community attributes on Huawei devices, including using the ip community-filter tool and applying a route-policy.
· BGP community is used to tag routes for route filtering.
· Community attributes are optional transitive attributes. The BGP routers that do not support these attributes will transmit the community attributes to downstream BGP peers.
· For more details about community attributes, see the path attribute sections.
![]()
route-policy
xxx permit node 10
apply community ?
INTEGER <0-4294967295> Specify community
number
STRING
<3-11>
Specify aa<0-65535>:nn<0-65535>
internet
Internet (well-known community attributes)
no-advertise
Do not advertise to any peer (well-known community attributes)
no-export
Do not export to external peers(well-known community attributes)
no-export-subconfed
Do not send outside a sub-confederation(well-known community attributes)
none
No community attribute
1. Assigning a Community Attribute to a Route Prefix
R1 advertises two routes: 1.0.1.0/24 and 1.0.2.0/24. In a BGP process, an export policy is applied to R2 and the community attribute 100:1 is set for the route 1.0.1.0/24 so that downstream peers can use this community attribute to deploy routing policies.
By default, the community attribute is not advertised to peers along with the route prefix. Therefore, you need to run the peer x.x.x.x advertise-community command on R1. This command also needs to be configured on R2.
In the preceding configuration, theroute-policy RP permit node 20 command permits the routes that do not match node 10. If this command is not configured, the route 1.0.2.0/24 will not be transmitted to R2. Therefore, do not forget to configure this command.
2. Add a Community Attribute to a Route Prefix
![]()
R1 updates two routes to R2: 1.0.1.0/24 and 1.0.2.0/24. The route 1.0.1.0/24 carries a community attribute 100:1. To meet certain requirements, R2 needs to add a no-export community attribute to this route. In this case, you can perform the preceding configuration on R2. The key point is the additive keyword. If this keyword is not specified, the no-export community attribute will override the existing community attribute 100:1.
R3 configuration:
R3
display bgp routing-table 1.0.1.0
BGP local router ID : 10.1.23.3
Local AS number : 300
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 1.0.1.0/24:
From: 10.1.23.2 (1.1.1.1)
Route Duration: 00h00m53s
Direct Out-interface: Vlanif1
Original nexthop: 10.1.23.2
Qos information : 0x0
Community:<100:1>, no-export
AS-path 200 100, origin igp, pref-val 0, valid, external, best, select,
active, pre 255
3. Using the ip community-filter to Match the Community Attribute
The upstream router sets the community attributes for routes. These attributes will be transmitted along with the routes. Then downstream routers can match the routes based on the community attributes or capture the routes to enforce routing policies. BGP provides a tool, ip community-filter, for matching community attributes.
![]()
4. Using the ip community-filter to Match the Community Attribute (Internet Attribute)
![]()
5. Using the ip community-filter to Match the Community Attribute (Exact Match)
![]()
6. Deleting a Specific Community Attribute
![]()
7. Deleting Multiple Community Attributes
![]()
8. Related Commands
![]()
If you have any problems, please post them in our Community. We are happy to solve them for you!