I had my first real experience with playing with regular expressions in BGP this evening to manipulate traffic. In the instance below, I needed to give a lower preference to traffic that was learned from ‘65002’ and was 4 AS hops out. I did this by creating an as-path access-list, using it in a route-map, and applying it to an eBGP neighbor.

ip as-path access-list 61 permit ^65002_[0-9]+_[0-9]+_[0-9]+$
route-map SomeBGPTransit-in permit 15
 match as-path 61
 set local-preference 90
wr mem

While I’m at it, I figured that I share the two links that have helped me the most with BGP. The first is the BGP cheat sheet from PacketLife.net. The second is an INE blog post on BGP Regular Expressions.

Share on FacebookTweet about this on TwitterShare on LinkedInShare on RedditEmail this to someone
Posted in BGP.