cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2735
Views
0
Helpful
6
Replies

BGP Route Map with Regular Expression Issue

jeff6strings
Level 1
Level 1

I have a router connected to two MPLS providers and I'm learning how to use local preference so traffic is preferred by Comcast MPLS over the second MPLS (AS 4321). I have the configuration below on the router but it won't match until I remove the regular expressions and just use 1234 to match the AS #. I tried ^1234$ and ^$ and _1234$ but only 1234 works. Not complaining but not sure why the regular expression doesn't work.

Appreciate any help.

Jeff

router bgp 30
 no synchronization
 bgp log-neighbor-changes
 network 10.3.3.0 mask 255.255.255.0
 neighbor 172.16.3.2 remote-as 4321
 neighbor 172.16.3.2 route-map NO-TRANSIT-AS out
 neighbor 192.168.3.2 remote-as 1234
 neighbor 192.168.3.2 route-map PREFER-Comcast in
 neighbor 192.168.3.2 route-map NO-TRANSIT-AS out
 no auto-summary

ip as-path access-list 1 permit ^1234$
ip as-path access-list 10 permit ^$
!
!
route-map NO-TRANSIT-AS permit 10
 match as-path 10
!
route-map PREFER-Comcast permit 10
 match as-path 1
 set local-preference 200
!
route-map PREFER-Comcast permit 20

1 Accepted Solution

Accepted Solutions

Hi Jeff,

The document you have been studying is doing a somewhat different selection and a different logic.

What they do on Page 52 is this:

  • They assume that the other site of the VPN is AS 65401 - please keep in mind that this is not the ASN of any service provider, rather, it is an ASN of one particular site in the VPN.
  • The create a regexp to influence only routes originated at the other VPN site, hence the regexp _65401$
  • The apply a route-map referring to this regexp to the preferred BGP neighbor, increasing the local preference to 200. Other routes through the preferred BGP neighbor, and all routes through the unpreferred neighbor, will be unchanged.

Your situation seems to be different - you're not matching the preferred routes based on where they were originated but rather which provider they are reachable through.

In fact, and I allowed to let myself get confused as well - note that we are applying a route-map with a regexp of ^1234_ to BGP neighbor 192.168.3.2 that is in AS 1234. But naturally, every route advertised by this neighbor is going to start with 1234 in its AS_PATH! In other words, the whole regexp in the route-map PREFER-Comcast is not necessary at all because it will match any route advertised from 192.168.3.2.

So the easiest way of increasing the local preference of all routes received from 192.168.3.2 is to have a very simple route-map as follows:

route-map PREFER-Comcast permit 10
 set local-preference 200
!
router bgp 30
 neighbor 192.168.3.2 route-map PREFER-Comcast in

Would this make sense?

Best regards,
Peter

View solution in original post

6 Replies 6

Peter Paluch
Cisco Employee
Cisco Employee

Hi Jeff,

If you want to prefer paths that are coming from Comcast, then - assuming that 1234 is Comcast's ASN - all paths from Comcast will have 1234 as their first ASN in the AS_PATH, but there can be an arbitrary number of other ASNs following. Your regexp ^1234$ matches only paths that are local to Comcast and are received directly from it; the regexp _1234$ matches only paths that are local to Comcast and are received either directly or through any intermediary AS.

Correctly, the regexp should be ^1234_

Would you mind trying that out?

Best regards,
Peter

Peter:

^1234_ worked. I'm a little confused as the Cisco MPLS WAN Design Guide (see link below) has _1234$ as the reg exp for the preferred MPLS. I followed the guide but their reg exp doesn't work.

Appreciate the help.

Jeff

fhttp://www.cisco.com/c/dam/en/us/td/docs/solutions/CVD/Aug2014/CVD-MPLSWANDesignGuide-AUG14.pdf

Hi Jeff,

The document you have been studying is doing a somewhat different selection and a different logic.

What they do on Page 52 is this:

  • They assume that the other site of the VPN is AS 65401 - please keep in mind that this is not the ASN of any service provider, rather, it is an ASN of one particular site in the VPN.
  • The create a regexp to influence only routes originated at the other VPN site, hence the regexp _65401$
  • The apply a route-map referring to this regexp to the preferred BGP neighbor, increasing the local preference to 200. Other routes through the preferred BGP neighbor, and all routes through the unpreferred neighbor, will be unchanged.

Your situation seems to be different - you're not matching the preferred routes based on where they were originated but rather which provider they are reachable through.

In fact, and I allowed to let myself get confused as well - note that we are applying a route-map with a regexp of ^1234_ to BGP neighbor 192.168.3.2 that is in AS 1234. But naturally, every route advertised by this neighbor is going to start with 1234 in its AS_PATH! In other words, the whole regexp in the route-map PREFER-Comcast is not necessary at all because it will match any route advertised from 192.168.3.2.

So the easiest way of increasing the local preference of all routes received from 192.168.3.2 is to have a very simple route-map as follows:

route-map PREFER-Comcast permit 10
 set local-preference 200
!
router bgp 30
 neighbor 192.168.3.2 route-map PREFER-Comcast in

Would this make sense?

Best regards,
Peter

Peter:

The route map without the reg exp you works fine and makes perfect sense. I appreciate your time to help me.

Thanks again.

Jeff

Hi Jeff,

It has been a pleasure.

Best regards,
Peter

Peter, once again thanks for your help.

After testing this solution for a while one problem is if MPLS at a site on AS 1234 goes down other sites will still use the preferred carrier causing one site to be transient with a longer AS path. Is there a BGP config that would prefer carrier AS 1234 but if a link on that carrier goes down then the sites will use carrier 4321? Attached is a diagram of our MPLS network.

Thank you for any help.

Jeff