12.25 Implementing AS Path Access Lists

AS Path access-lists have several use cases. First, note the following regular expressions:

  • _ matches any delimiter, including beginning, end, space, tab, and comma
  • ^ matches the beginning of a string
  • $ matches the end of a string

Scenarios and examples:

  • To announce only locally-originated routes (to prevent transit AS), this filter provides an empty AS Path with the following syntax:

ip as-path access-list 1 permit ^$

  • To show only bgp routes in the forwarding table that contain AS 3257:

show ip bgp regexp _3257_

  • To filter for only AS Paths that begin with AS 11221:

ip as-path access-list 1 permit ^11221_

To apply this to a BGP neighbor, enter the BGP routing process and use the following syntax:

neighbor <neighbor IP> filter-list <list number> out