cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
118
Views
0
Helpful
0
Comments
aghufran
Level 1
Level 1
 

Hi All,

For a requirement I had, I wanted to test various regex combinations of AS-PATH Prepend matches using IOSXR RPL. 

In case, someone else also has a similar situation, I thought of sharing the results.

Iosxr regex syntax: ([0-9]+)(_\1)(_\1)(_\1)$

  • Matches a single AS
  • Matches repeat (prepend)
  • You can test with ^, $, [0-9]+, [0-9]* and (64514).

 

 

!---Test_AS-PATH-PREPENDed-Advertisement---!

RP/0/RP0/CPU0:rr-1#sh bgp ipv4 u neighbors 172.16.10.10 received routes 
.......
Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*  1.1.1.1/32         172.16.10.10             0             0 64514 64514 64514 64514 i
*  2.2.2.2/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 i
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i

Processed 3 prefixes, 3 paths

!--------------------------------------------------------------------------------------------------------!
REGEX Pattern: '^([0-9]+).........$'
!--------------------------------------------------------------------------------------------------------!
1)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^([0-9]+)(_\1)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches: 
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
2)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^([0-9]+)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  2.2.2.2/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
3)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^([0-9]+)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  1.1.1.1/32         172.16.10.10             0             0 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
REGEX Pattern: '^(64514).........$'
!--------------------------------------------------------------------------------------------------------!
1a)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^(64514)(_\1)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches: 
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
2a)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^(64514)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  2.2.2.2/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
3a)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '^(64514)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  1.1.1.1/32         172.16.10.10             0             0 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
REGEX Pattern: '([0-9]+).........$'
!--------------------------------------------------------------------------------------------------------!
1b)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '([0-9]+)(_\1)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches: 
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
2b)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '([0-9]+)(_\1)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  2.2.2.2/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 i
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i

!--------------------------------------------------------------------------------------------------------!
3b)
conf t
route-policy AS-PREPEND
  if as-path in (ios-regex '([0-9]+)(_\1)(_\1)(_\1)$') then 
    set community (64514:64514)
  endif
end-policy
commit
exit

Matches:
*  1.1.1.1/32         172.16.10.10             0             0 64514 64514 64514 64514 i
*  2.2.2.2/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 i
*  3.3.3.3/32         172.16.10.10             0             0 64514 64514 64514 64514 64514 64514 i
!--------------------------------------------------------------------------------------------------------!

 

 

What I also wanted to test was {min,max} but could not get that working. I was trying it on 7.1.2 so not sure if this is not supported at all or may be in a different version. If any has any experience of using that, please do share.

Kind regards,

Abid Ghufran

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links