Page 1 of 1

Find and replace IP address in IP services

Posted: Fri Nov 20, 2020 4:52 pm
by Bokous
Hi folks,
I can't create script to change mask range in services. I need to find the searched ip address (X.X.X.X/29) and change the given range (X.X.X.X/28). Is this variant possible?
Thank you for your help!

Re: Find and replace IP address in IP services

Posted: Sun Nov 22, 2020 10:17 am
by Shumkov
ip service
:foreach value in=[find address] do={
:foreach address in=[get $value address] do={:put "$address -> $[:pick $address 0 [:find $address /]]/28"}
}
Output:
X.X.X.X/X -> X.X.X.X/28

This is the basic algorithm. Now you can modify the script according to your requirements (replace "put" with "set", change the search condition, etc.)