In all of the examples I mentioned I could have included output from our router to show what I was seeing but I didn't in the interest of brevity. Perhaps the particular show command I was using is a little looser in its matching than other elements of IOS would be.
Also, I think we're using different definitions for the word 'originated'. I use it to differentiate between routes truly originating from a system and routes passing through a transit AS. In our situation AS1239 is one of our providers. In the case of ^1239 .* you mention that it matches only routes originated in AS1239, but this is not the case, at least with the show command. ^1239$ will do this, but the previous expression seems to match a string beginning with 1239 followed by a space and then 0 or more characters, which is as you stated. That means that expression should match the path 1239, but it will also match 1239 5234 5234 701 20, for example. Actually, in my testing (again, with only the IOS show command) ^1239 .* would match any transit routes but would not match a path that contained only AS1239, or ^1239$. It thought that was interesting and it wasn't what I expected to see. Who knows, it may be a feature, but IOS appears to count that space as a literal space, and since there is no space following ^1239$ it isn't matched. Here is some example output: Router>sho ip bgp regex ^1239 .* BGP table version is 8192316, local router ID is 207.109.56.162 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 12.1.83.0/24 160.81.116.1 0 1239 5696 14787 14787 14787 i *> 12.2.6.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.2.7.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.3.33.0/24 160.81.116.1 0 1239 17033 i *> 12.3.59.0/24 160.81.116.1 0 1239 4513 17304 i *> 12.3.194.0/24 160.81.116.1 0 1239 6347 i *> 12.4.96.0/24 160.81.116.1 0 1239 14452 i *> 12.4.96.0/23 160.81.116.1 0 1239 14452 i *> 12.4.97.0/24 160.81.116.1 0 1239 14452 i *> 12.5.39.0/24 160.81.116.1 0 1239 4323 16707 i *> 12.6.121.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.124.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.125.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.171.0/24 160.81.116.1 0 1239 6347 10851 i Notice that there are no routes with only AS1239 in the path. Now, look at this one: Router>sho ip bgp regex ^1239_.* BGP table version is 8192359, local router ID is 207.109.56.162 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 12.1.83.0/24 160.81.116.1 0 1239 5696 14787 14787 14787 i *> 12.2.6.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.2.7.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.3.33.0/24 160.81.116.1 0 1239 17033 i *> 12.3.59.0/24 160.81.116.1 0 1239 4513 17304 i *> 12.3.194.0/24 160.81.116.1 0 1239 6347 i *> 12.4.96.0/24 160.81.116.1 0 1239 14452 i *> 12.4.96.0/23 160.81.116.1 0 1239 14452 i *> 12.4.97.0/24 160.81.116.1 0 1239 14452 i *> 12.4.125.0/24 160.81.116.1 0 1239 i *> 12.5.39.0/24 160.81.116.1 0 1239 4323 16707 i *> 12.6.92.0/24 160.81.116.1 0 1239 i *> 12.6.121.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.124.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.125.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i Notice that this output does include some AS1239-only paths. It appears that IOS treats a space in the expression as a literal space but the underscore can match any character including $. Now, let's try ^1239_.+ Router>sho ip bgp regex ^1239_.+ BGP table version is 8193137, local router ID is 207.109.56.162 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 12.1.83.0/24 160.81.116.1 0 1239 5696 14787 14787 14787 i *> 12.2.6.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.2.7.0/24 160.81.116.1 0 1239 11101 11101 i *> 12.3.33.0/24 160.81.116.1 0 1239 17033 i *> 12.3.59.0/24 160.81.116.1 0 1239 4513 17304 i *> 12.3.194.0/24 160.81.116.1 0 1239 6347 i *> 12.4.96.0/24 160.81.116.1 0 1239 14452 i *> 12.4.96.0/23 160.81.116.1 0 1239 14452 i *> 12.4.97.0/24 160.81.116.1 0 1239 14452 i *> 12.5.39.0/24 160.81.116.1 0 1239 4323 16707 i *> 12.6.121.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.124.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.125.0/24 160.81.116.1 0 1239 16727 16727 16727 16727 i *> 12.6.171.0/24 160.81.116.1 0 1239 6347 10851 i *> 12.6.206.0/24 160.81.116.1 0 1239 20357 i *> 12.6.227.0/24 160.81.116.1 0 1239 7843 16425 i Now, it doesn not match AS1239-originated routes because of the .+. That is expecting one or more occurrences of a characters, where the .* is expecting zero or more. I have no idea whether this is POSIX-compliant or not but it definitely is what is occurring! :-) And I still haven't tried using these expressions elsewhere in the router config. My guess is that you're correct and the router would be more strict in other situations. Okay, I seriously need some more coffee. I'm way too grumpy this morning. :-) Regards, John >>> "Julian Eccli" 11/1/01 12:07:06 AM >>> > ^1239_ would match any route coming from AS1239 *including* routes > originated in AS1239. This is because the underscore can match any > character including whitespace and the $ end-of-path anchor. > Probably work in show command but not in the IOS policy. At the very least the '^1239_' is very sloppy and not POSIX compliant, while '^1239 .*' is. > ^1239 .* would match any route coming through AS1239 but *not* routes > originated in AS1239. This is presumably because I now have included a > specific space between the ^1239 and the .*. This will exclude ^1239$. > Actually '^1239 .*' would only match routes originated in AS1239. ^1239$ would only match the single AS_PATH AS1239 exclusively and so would '^1239 .*'. ^1239$ means... Matched string MUST start with a 1, then be proceeded by a 2, then proceeded by a 3, then proceeded with a 9 and end with a 9 to be true. '^1239 .*' means... Matched string MUST start with a 1, then be proceeded by a 2, then proceeded by a 3, then proceeded with a 9, then proceeded by 0 or more characters of any kind so AS1239 could be the only AS_PATH there. I am not sure how IOS processes the space as a litereal space or just a seperator between AS's. I had always thought IOS processed the AS_PATH as a string of characters so the space may be counted but I think the '_' is what forces the space to be counted as a space. > ^1239_.+ behaves the same way as ^1239 .*. This is because the + sign > expects one or more repetitions of at least one character following ^1239_. > No it does not. Remember * is 0 or more. + is 1 or more. Adding the + means you must have at least one character of any kind while the * could be empty. Makes a HUGE difference depending on the string you are matchinig against. -Julian Message Posted at: http://www.groupstudy.com/form/read.php?f=7&i=24946&t=24460 -------------------------------------------------- FAQ, list archives, and subscription info: http://www.groupstudy.com/list/cisco.html Report misconduct and Nondisclosure violations to [EMAIL PROTECTED]