11-22-2017 02:32 PM - edited 02-21-2020 10:40 AM
Hello Members,
I need some help in creating a regex in ACS 5.8 to permit all ip address in the command set.
The commands I want to use in the command set are :
ip address <x.x.x.x> 255.255.255.252
ip mroute vrf mssbdata <x.x.x.x> 255.255.255.255 <x.x.x.x>
neighbor <x.x.x.x> activate
X.X.X.X can be any ip address.
Please suggest !
Solved! Go to Solution.
11-23-2017 02:01 PM - edited 11-23-2017 02:02 PM
How about this one? It does some moderate checking to ensure that some 1-3 digit dotted decimal is entered, but no range checking is done in each decimal.
^([0-9]{1,3}\.){3}[0-9]{1,3}$
11-22-2017 03:16 PM
Regular expression syntax doesn't provide a numerical range checking operator, so we have to build it ourselves. My suggestion below is tailored towards valid IPv4 address ranges as much as possible.
([1-9]|[1-9][0-9]|[12][0-9][0-9])\.([0-9]|[1-9][0-9]|[12][0-9][0-9])\.([0-9]|[1-9][0-9]|[12][0-9][0-9])\.([0-9]|[1-9][0-9]|[12][0-9][0-9])$
Without complicating the regex any more, it will allow examples such as
1.0.0.0 - 299.299.299.299 (but the IOS would flag an error if you entered an illegal IP address - the question is whether you want your regex to guard you from that too? Yes, maybe. Would be nice. But would possibly make the regex look even uglier.
I am open to other suggestions
Test your regex here https://regex101.com/
11-22-2017 03:39 PM - edited 11-22-2017 03:46 PM
I have made v2.0 that now enforces the legal IPv4 syntax
^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$
I told you'd it's gonna get ugly :-)
11-23-2017 11:12 AM
11-23-2017 02:01 PM - edited 11-23-2017 02:02 PM
How about this one? It does some moderate checking to ensure that some 1-3 digit dotted decimal is entered, but no range checking is done in each decimal.
^([0-9]{1,3}\.){3}[0-9]{1,3}$
03-21-2018 07:31 AM
Hello Arne,
Thanks for the regex, It worked like a charm.. Thanks Again...
Regards
Harshdeep Singh
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide