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

Defining AS Path Regular Expressions

You can create a named AS path regular expression and then include it in a routing policy with the as-path match condition (described in Table 14). To create a named AS path regular expression, include the as-path statement:

as-path name regular-expression;

You can include this statement at the following hierarchy levels:

To include the AS path regular expression in a routing policy, include the as-path match condition in the from statement:

as-path name regular-expression;
policy-statement policy-name {
term term-name {
from {
names;
}
}
}

Additionally, you can create a named AS path group made up of AS path regular expressions and then include it in a routing policy with the as-path-group match condition. To create a named AS path group, include the as-path-group statement:

as-path-group group-name {
name [ regular-expressions ];
}

You can include this statement at the following hierarchy levels:

To include the AS path regular expressions within the AS path group in a routing policy, include the as-path-group match condition in the from statement:

as-path-group group-name {
name [ regular-expressions ];
}
policy-statement policy-name {
term term-name {
from {
as-path-group group-name;
}
}
}

Note: You cannot have both as-path and as-path-group in the same policy term.

Note: You can include the names of multiple AS path regular expressions in the as-path match condition in the from statement. If you do this, only one AS path regular expression needs to match for a match to occur. The AS path regular expression matching is effectively a logical OR operation.

The AS path name identifies the regular expression. It can contain letters, numbers, and hyphens (-), and can be up to 255 characters. To include spaces in the name, enclose the entire name in quotation marks (“ ”).

The regular expression is used to match all or portions of the AS path. It consists of two components, which you specify in the following format:

term <operator>

You can specify one or more term–operator pairs in a single regular expression.

Table 20 shows examples of how to define regular expressions to match AS paths.

Table 19: AS Path 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 two terms on either side of the pipe.

Between a starting and ending range, inclusive.

^

A character at the beginning of a community attribute regular expression. This character is added implicitly; therefore, the use of it is optional.

$

A character at the end of a community attribute regular expression. This character is added implicitly; therefore, the use of it is optional.

( )

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

[ ]

Set of characters. One character from the set can match. To specify the start and end of a range, use a hyphen (-).

!

The not operator.

Table 20: Examples of Defining AS Path Regular Expressions

AS Path to Match

Regular Expression

Sample Matches

AS path is 1234

1234

1234

Zero or more occurrences of AS number 1234

1234*

1234
1234 1234
1234 1234 1234
Null AS path

Zero or one occurrence of AS number 1234

1234?
or
1234{0,1}

1234
Null AS path

One through four occurrences of AS number 1234

1234{1,4}

1234
1234 1234
1234 1234 1234
1234 1234 1234 1234

One through four occurrences of AS number 12, followed by one occurrence of AS number 34

12{1,4} 34

12 34
12 12 34
12 12 12 34
12 12 12 12 34

Range of AS numbers to match a single AS number

123–125

[123–125]*

123 or 124 or 125

Null AS path
123
124 124
125 125 125

Path whose second AS number must be 56 or 78

(. 56) | (. 78) or
. (56|78)

1234 56
34 78

Path whose second AS number might be 56 or 78

. (56|78)?

1234 56
34

Path whose first AS number is 123 and second AS number is either 56 or 78

123 (56|78)

123 56
123 78

Path of any length, except nonexistent, whose second AS number can be anything, including nonexistent

.* or .{0,}

1234
1234 5678
1234 5 6 7 8

AS path is 1 2 3

1 2 3

1 2 3

One occurrence of the AS numbers 1 and 2, followed by one or more occurrences of the number 3

1 2 3+

1 2 3
1 2 3 3
1 2 3 3 3

One or more occurrences of AS number 1, followed by one or more occurrences of AS number 2, followed by one or more occurrences of AS
number 3

1+ 2+ 3+

1 2 3
1 1 2 3
1 1 2 2 3
1 1 2 2 3 3

Path of any length that begins with AS numbers 4, 5, 6

4 5 6 .*

4 5 6
4 5 6 7 8 9

Path of any length that ends with AS numbers 4, 5, 6

.* 4 5 6

4 5 6
1 2 3 4 5 6

AS path 5, 12, or 18

5 | 12 |18

5
12
18


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