To use a BGP community or extended community as a routing policy match condition, you define the community as described in the following sections:
To create a named BGP community and define the community members, include the community statement:
- community name {
- invert-match;
- members [ community-ids ];
- }
You can include this statement at the following hierarchy levels:
name identifies the community. It can contain letters, numbers, and hyphens (-) and can be up to 255 characters long. To include spaces in the name, enclose the entire name in quotation marks (“ ”).
community-ids identifies one or more members of the community. Each community ID consists of two components, which you specify in the following format:
You can also include one of the following well-known community names (defined in RFC 1997, BGP Communities Attribute) in the community-ids option for the members statement:
When specifying the members of a named BGP community (in the members [ community-ids ] statement), you can use UNIX-style regular expressions to specify the AS number and the member identifier. A regular expression consists of two components, which you specify in the following format:
term identifies the string to match.
operator specifies how the term must match. Table 18 lists the regular expression operators supported in community IDs. You place an operator immediately after term with no intervening space, except for the pipe ( | ) and dash (–) operators, which you place between two terms, and parentheses, with which you enclose terms. Table 19 shows examples of how to define community-ids using community regular expressions. The operator is optional.
Community regular expressions are identical to the UNIX regular expressions. Both implement the extended (or modern) regular expressions as defined in POSIX 1003.2.
Community regular expressions evaluate the string specified in term on a character-by-character basis. For example, if you specify 1234:5678 as term, the regular expressions see nine discrete characters, including the colon (:), instead of two sets of numbers (1234 and 5678) separated by a colon.
![]() |
Note: In JUNOS Release 9.1 and later, you can specify 4-byte AS numbers as defined in RFC 4893, BGP Support for Four-octet AS Number Space, as well as the 2-byte AS numbers that are supported in earlier releases of the JUNOS software. For more information about configuring AS numbers, see the JUNOS Routing Protocols Configuration Guide. |
Table 18: Community Attribute Regular Expression Operators
Table 19: Examples of Community Attribute Regular Expressions
To create a named BGP community and define the community members, include the community statement:
- community name {
- invert-match;
- members [ community-ids ];
- }
You can include this statement at the following hierarchy levels:
name identifies the community. It can contain letters, numbers, and hyphens (-) and can be up to 255 characters long. To include spaces in the name, enclose the entire name in quotation marks (“ ”).
community-ids identifies one or more members of the community. Each community ID consists of three components, which you specify in the following format:
type is the type of extended community and can be either the 16-bit numerical identifier of a specific BGP extended community or one of these types:
![]() |
Note: The link bandwidth attribute does not work concurrently with per-prefix load balancing. |
![]() |
Note: You must identify the route by an IP address, not an AS number. |
![]() |
Note: You must identify the AS by an AS number, not an IP address. |
administrator is the administrator. It is either an AS number or an IP version 4 (IPv4) address prefix, depending on the type of extended community.
assigned-number identifies the local provider.
In JUNOS Release 9.1 and later, you can specify 4-byte AS numbers as defined in RFC 4893, BGP Support for Four-octet AS Number Space, as well as the 2-byte AS numbers that are supported in earlier releases of the JUNOS software. In plain-number format, you can configure a value in the range from 1 through 4,294,967,295. To configure a target or origin extended community that includes a 4-byte AS number in the plain-number format, append the letter “L” to the end of number. For example, a target community with the 4-byte AS number 334,324 and an assigned number of 132 is represented as target:334324L:132.
In JUNOS Release 9.2 and later, you can also use AS-dot notation when defining a 4-byte AS number for the target and origin extended communities. Specify two integers joined by a period: 16-bit high-order value in decimal.16-bit low-order value in decimal. For example, the 4-byte AS number represented in plain-number format as 65546 is represented in AS-dot notation as 1.10.
For more information about configuring AS numbers, see the JUNOS Routing Protocols Configuration Guide.
Configure a target community with an administrative field of 10458 and an assigned number of 20:
Configure a target community with an administrative field of 10.1.1.1 and an assigned number of 20:
Configure an origin community with an administrative field of 10.1.1.1 and an assigned number of 20:
To invert the results of the community expression matching, include the invert-match statement:
You can include this statement at the following hierarchy levels: