Community discussions

MikroTik App
 
Bokous
just joined
Topic Author
Posts: 2
Joined: Tue Oct 06, 2020 12:56 pm

Find and replace IP address in IP services

Fri Nov 20, 2020 4:52 pm

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!
 
Shumkov
just joined
Posts: 15
Joined: Tue Oct 01, 2019 9:08 pm

Re: Find and replace IP address in IP services

Sun Nov 22, 2020 10:17 am

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.)

Who is online

Users browsing this forum: alexantao and 27 guests