CCNP-Studies
Routing
4-BGP
26 as Path Access Lists

BGP AS_PATH Access Lists: Filtering by Autonomous System Numbers

Introduction to AS_PATH Access Lists

In Border Gateway Protocol (BGP), the AS_PATH attribute plays a crucial role in understanding the path that BGP routes have traversed. AS_PATH Access Lists, often referred to as AS_PATH ACLs, allow network administrators to filter BGP routes based on the Autonomous System Number (ASN) path. This is a powerful tool for managing routing information within a BGP network.

Filtering with AS_PATH Access Lists

AS_PATH Access Lists are used for filtering routes based on specific ASN patterns. They utilize Regular Expressions (REGEX) to match patterns in the AS_PATH attribute. The beauty of AS_PATH Access Lists is that they can be employed directly on the command line, making them practical for real-time filtering and analysis.

For those who want to gain hands-on experience or practice using AS_PATH Access Lists, route servers are valuable resources for experimentation and learning.

Regular Expressions in AS_PATH Access Lists

AS_PATH Access Lists use Regular Expressions, which are powerful pattern-matching tools. Some special characters in Regular Expressions used in AS_PATH Access Lists include:

  • .: Matches any single character.
  • *: Matches 0 or more sequences of a pattern.
  • ?: Matches 0 or one instance of the character or pattern.
  • +: Matches one or more instances of the character or pattern.
  • ^: Matches the start of a string (start of a line).
  • $: Matches the end of a string (end of a line).
  • [ ]: Matches a single instance of one of the numbers inside the brackets.
  • _: Matches a comma, left brace, right brace, left parenthesis, right parenthesis, start of a string, end of a string, or a space.
  • Space: Spaces are used to separate ASNs in the AS_PATH.

Examples of AS_PATH Access Lists

Let's explore a few examples of how AS_PATH Access Lists can be used:

  • Match only NLRI originated in ASN 100:

    • Command: show ip bgp regex _100$
  • Match only LOCALLY sourced routes:

    • Command: show ip bgp regex ^$
  • Match only NLRI that passes through ASN 3477:

    • Command: show ip bgp regex _3477_
  • Match only NLRI that originated in ASNs with ALL/ONLY odd numbers:

    • Command: show ip bgp regex _[13579]*$
  • Match only NLRI that originated from a direct peer/AS:

    • Command: show ip bgp regex $[0-9]*$

Conclusion

AS_PATH Access Lists provide network administrators with a flexible tool to filter BGP routes based on the AS_PATH attribute. By leveraging Regular Expressions, these filters can be tailored to specific routing requirements, ensuring that only the desired routes are allowed into the network.