[Contents] [Prev] [Next] [Index] [Report an Error]

Configuring the Community Attribute Using UNIX Regular Expressions

When specifying community-ids, 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 operator;

term identifies the string to match.

operator specifies how the term must match. Table 21 lists the regular expression operators supported for the community attribute. 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 22 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: Beginning with JUNOS Release 9.1, the range that you can configure for the AS number has been extended to provide BGP support for 4-byte AS numbers. For more information about configuring the AS number, see the JUNOS Routing Protocols Configuration Guide.

Table 21: Community Attribute Regular Expression Operators

Operator

Match Definition

{m,n}

At least m and at most n repetitions of term. Both m and n must be positive integers, and m must be smaller than n.

{m}

Exactly m repetitions of term. m must be a positive integer.

{m,}

m or more repetitions of term. m must be a positive integer.

*

Zero or more repetitions of term. This is equivalent to {0,}.

+

One or more repetitions of term. This is equivalent to {1,}.

?

Zero or one repetition of term. This is equivalent to {0,1}.

|

One of the two terms on either side of the pipe.

Between a starting and ending range, inclusive.

^

Character at the beginning of a community attribute regular expression. We recommend the use of this operator for the clearest interpretation of your community attribute regular expression. If you do not use this operator, the regular expression 123:456 could also match a route tagged with 5123:456.

$

Character at the end of a community attribute regular expression. We recommend the use of this operator for the clearest interpretation of your community attribute regular expression. If you do not use this operator, the regular expression 123:456 could also match a route tagged with 123:4563.

[ ]

Set of characters. One character from the set can match. To specify the start and end of a range, use a hyphen (-). To specify a set of characters that do not match, use the caret (^) as the first character after the opening square bracket ([).

( )

Group of terms that are enclosed in parentheses. If enclosed in quotation marks with no intervening space ("()" ), indicates a null. Intervening space between the parentheses and the terms is ignored.

“ ”

Characters (such as space, tab, question mark, and bracket) that are enclosed within quotation marks in a community attribute regular expression indicate special characters.

Table 22: Examples of Defining Community Attribute Regular Expressions

Community Attribute to Match

Regular Expression

Sample Matches

AS number is 56 or 78. Community value is any number.

^((56) | (78)):(.*)$

56:1000

78:65000

AS number is 56. Community value is any number that starts with 2.

^56:(2.*)$

56:2

56:222

56:234

AS number is any number. Community value is any number that ends with 5, 7, or 9.

^(.*):(.*[579])$

1234:5

78:2357

34:65009

AS number is 56 or 78. Community value is any number that starts with 2 and ends with 2 through 8.

^((56) | (78)):(2.*[2–8])$

56:22

56:21197

78:2678


[Contents] [Prev] [Next] [Index] [Report an Error]