Configuring the BGP Community Attribute
Context
The Community attribute is a private BGP route attribute. It is transmitted between BGP peers and is not restricted within an AS. The Community attribute allows a group of BGP devices in multiple ASs to share the same routing policies, which simplifies routing policy applications and facilitates routing policy management and maintenance. A BGP device can add or change the community attributes of routes to be advertised.
Procedure
- Run system-view
The system view is displayed.
- Run route-policy route-policy-name { deny | permit } node node
A node is configured for a route-policy, and the view of the route-policy is displayed.
- (Optional) Configure matching rules for the route-policy to change only the community attributes of the routes that meet matching rules.
By default, all routes meet matching rules. For details, see (Optional) Configuring if-match Clauses.
- Run either of the following commands to configure the Community attribute.
Run apply community { community-number | aa:nn | internet | no-advertise | no-export | no-export-subconfed } &<1-32> [ additive ]
Common community attributes are configured for BGP routes.
You can run this command to configure a maximum of 32 community attributes at a time.Run apply extcommunity { rt { as-number:nn | ipv4-address:nn } } &<1-16> [ additive ]
An extended community attribute (route-target) is configured.
Extended community attributes are extensions to community attributes in services. Currently, only the route-target attribute is supported in VPN.
- Run quit
Return to the system view.
- Run bgp { as-number-plain | as-number-dot }
The BGP view is displayed.
- Enter the corresponding address family view based on network type to configure BGP devices on networks.
Run ipv4-family unicast
The BGP-IPv4 unicast address family view is displayed.
Run ipv4-family multicast
The BGP-IPv4 multicast address family view is displayed.
Run ipv4-family vpnv4 [ unicast ]
The BGP-VPNv4 address family view is displayed.
Run ipv4-family vpn-instance vpn-instance-name
The BGP-VPN instance IPv4 address family view is displayed.
Run ipv6-family [ unicast ]
The BGP-IPv6 unicast address family view is displayed.
Run ipv6-family vpnv6 [ unicast ]
The BGP-VPNv6 address family view is displayed.
Run ipv6-family vpn-instance vpn-instance-name
The BGP-VPN instance IPv6 address family view is displayed.
- Add the Community attribute to routes.
The import-route and network commands cannot be executed in the BGP-VPNv4 address family view or BGP-VPNv6 address family view.
- Run peer { ipv4-address | group-name | ipv6-address } route-policy route-policy-name export
The Community attribute is added to the routes advertised to BGP peers or peer groups.
- Run peer { ipv4-address | group-name | ipv6-address } route-policy route-policy-name import
The Community attribute is added to the routes received from BGP peers or peer groups.
- Run import-route protocol [ process-id ] route-policy route-policy-name
The Community attribute is added to the routes imported by BGP in import mode.
- Run network { ipv4-address [ mask | mask-length ] | ipv6-address prefix-length route-policy route-policy-name
The Community attribute is added to the routes imported by BGP in network mode.
Step 9 is required only when the Community attribute needs to be added to the routes advertised to BGP peers or peer groups.
- Run peer { ipv4-address | group-name | ipv6-address } route-policy route-policy-name export
- (Optional) Allow BGP to advertise community attributes when BGP adds community attributes to the routes advertised to BGP peers or peer groups.
Run peer { ipv4-address | group-name | ipv6-address } advertise-community
BGP is allowed to advertise community attributes to BGP peers or peer groups.
By default, BGP does not advertise community attributes to any peer or peer group.
Run peer { ipv4-address | group-name | ipv6-address } advertise-ext-community
BGP is allowed to advertise extended community attributes to BGP peers or peer groups.
By default, BGP does not advertise extended community attributes to any peer or peer group.
- Run commit
The configuration is committed.