Académique Documents
Professionnel Documents
Culture Documents
1 of 7
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
Note: You cannot include both of the as-path and as-path-group statements 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
65,536 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>
termIdenties an AS. You can specify it in one of the following ways:
16/12/2014 2:01 AM
2 of 7
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
AS numberThe entire AS number composes one term. You cannot reference individual characters within an AS
number, which differs from regular expressions as dened in POSIX 1003.2.
Wildcard characterMatches any single AS number. The wildcard character is a period (.). You can specify
multiple wildcard characters.
AS pathA single AS number or a group of AS numbers enclosed in parentheses. Grouping the regular expression
in this way allows you to perform a common operation on the group as a whole and to give the group precedence.
The grouped path can itself include operators.
In Junos OS 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
OS. You can configure a value in the range from 1 through 4,294,967,295.
operator(Optional) An operator specifying how the term must match. Most operators describe how many times
the term must be found to be considered a match (for example, any number of occurrences, or zero, or one
occurrence). Table 1 lists the regular expression operators supported for AS paths. You place operators 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.
You can specify one or more termoperator pairs in a single regular expression.
Table 2 shows examples of how to define regular expressions to match AS paths.
Match Definition
{m,n}
{m}
{m,}
16/12/2014 2:01 AM
3 of 7
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
Operator
Match Definition
( )
[ ]
AS Path to Match
Regular
Expression
Sample Matches
AS path is 1234
1234
1234
1234
Zero or more occurrences of
AS number 1234
1234 1234
1234*
1234 1234 1234
Null AS path
1234? or
1234{0,1}
1234
Null AS path
1234
One through four
occurrences of AS
number 1234
1234 1234
1234{1,4}
1234 1234 1234
1234 1234 1234 1234
16/12/2014 2:01 AM
4 of 7
AS Path to Match
Regular
Expression
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
Sample Matches
12 34
One through four
occurrences of AS
number 12, followed by one
occurrence of AS number 34
12 12 34
12{1,4} 34
12 12 12 34
12 12 12 12 34
123
123125
124
125
Range of AS numbers to
match a single AS number
Null AS path
123
[123125]*
124 124
125 125 125
123 124 125 123
1234 56
Path whose second AS
number must be 56 or 78
(. 56) | (. 78)
or . (56 | 78)
1234 78
9876 56
3857 78
1234 56 52
Path whose second AS
number might be 56 or 78
34 56 1234
. (56 | 78)?
1234 78 39
794 78 2
123 (56|78)
. .* or . .{0,}
AS path is 1 2 3
123
123
123 56
123 78
16/12/2014 2:01 AM
5 of 7
AS Path to Match
Regular
Expression
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
Sample Matches
123
1 2 3+
1233
12333
1+ 2+ 3+
4 5 6 .*
123
1123
11223
112233
456
456789
456
Path of any length that ends
with AS numbers 4, 5, 6
.* 4 5 6
123456
49456
5
AS path 5, 12, or 18
5 | 12 | 18
12
18
16/12/2014 2:01 AM
6 of 7
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
term nothing-else {
then reject;
}
}
protocol {
bgp {
neighbor 10.2.2.6 {
export only-my-routes;
}
}
}
16/12/2014 2:01 AM
7 of 7
http://www.juniper.net/techpubs/en_US/junos14.2/topics/usage-guideline...
Related Documentation
M, MX, PTX, T Series
Example: Using AS Path Regular Expressions
Example: Conguring a Routing Policy to Prepend the AS Path
Published: 2014-10-27
16/12/2014 2:01 AM