Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • convert whole AS path to string and let regexp operate on the string (ROS v6 or Cisco style)
  • let regexp operate on each entry in the AS path as a number (ROS v7, Juniper style)

The Basically first method is performing the match per character, the second method is performing match per whole AS number. As you would imagine the latter method is much faster and less resource-intensive than the string matching approach.

This change would require administrators to implement new Regex strategies. Old Regex patterns from RouterOS v6 cannot be directly copy/pasted as they will result either in syntax error or unexpected result.

Lets take a very basic AS Path filter rule.As an example, very basic AS Path filter that matchers ASN 1234 anywhere in the middle of the AS-path:

Code Block
languageros
/routing/filter/rule/add 
chain=myChain rule="if (bgp-as-path .1234.) {accept}"

In ROS v7 this Regex pattern will match ASN 1234 anywhere in the middle of the AS-path, the same pattern in ROS v6 would match any AS path than contains ASN consisting of at least 6 characters and contains string of "1234".  Obviously if we directly copy/paste Regex pattern from one implementation to another it will lead to unexpected/dangerous results. Equivalent pattern in ROS v6 would look something like this: "._1234_.".

Let's take another example from ROS v6, say we have a pattern "1234[5-9]" what it does is it matches 12345 to 12349 anywhere in the string, which means that valid matches are AS-path "12345 3434", "11 9123467 22" and so on. If you enter the same pattern in ROS v7 it will match AS path containing exact ASN 1234 followed by ASN in range from 5 to 9 (matching AS-paths would be "1234 7 111", "111 1234 5 222" etc., i twill not match "12345 3434").

Warning

Do not copy Regex patterns directly from ROS v6 or Cisco configurations, they are not directly compatible. It can lead to unexpected or even dangerous configuration in some scenarios.


Supported Operators


OperatorDescriptionExampleExample ExplainedExample Matches
^Represents the beginning of the path^1234 will math AS-path starting with ASN 1234
$Represents the end of the path1234$will match AS-path of origin ASN 1234
*Zero or more occurrences of the  listed ASN^1234*$will math Null as-path or as-path where ASN 1234 may or may not appear multiple times

Math:

1234

1234 1234 1234

Null path

No Match:

1234 5678

+One or more occurrences of the listed ASN1234+will match AS-path where ASN 1234 appears at least once

Match:

1234

3 1234 6

No match:

12345 678

?Zero or one occurrence of the listed ASN^1234? 5678will match AS-path that may or may not start with ASN 1234 appearing once.

Match:

5678

1234 5678

No match:

1234 1234 5678

12345 5678

.One occurrence of any ASN^.$ will match any AS-path with length of one.

Match:

12345

45678

No match:

1234 5678

|Match one of two ASNs on each side^(1234|5678) will match AS-path starting with ASN 1234 or 5678

Match:

1234

5678

1234 5678

No Match:

91011

[ ]

Represents the set of AS numbers where one AS number from the list must match. It is also possible to reference the pre-defined num-sets from 

num-sets with [[numset_name]] 

^[1234 5678 1-100]will match AS-path that starts with 1234 or 5678 or from the range of 1 to 100

Match:

1234

99

5678

No Match:

101

()

Group of regexp terms to match^(1234$|5678)will match AS-path that starts and ends with 1234 or AS-path that starts with 5678

Match:

1234

5678 9999

No Match:

1234 5678

...