Community discussions

MikroTik App
just joined
Topic Author
Posts: 1
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!
User avatar
just joined
Posts: 14
Joined: Tue Oct 01, 2019 9:08 pm
Location: Russian Federation

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"}
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.)
RB951G-2HnD / RouterOS 6.46.8 (Long-term)

Who is online

Users browsing this forum: AminM, Bing [Bot], rushlife and 39 guests