Community discussions

MikroTik App
 
cillininfo
just joined
Topic Author
Posts: 4
Joined: Thu Apr 23, 2020 11:09 am

Please help to see this script for batch adding add-list

Mon Feb 08, 2021 5:40 am

I want to add the following in batches in the add list:
list=user_1
address=172.16.1.1-172.16.1.5
list=user_2
address=172.16.1.6-172.16.1.10
......
list=user_50
address=172.16.1.246-172.16.1.250
I failed to add with the following script, can you help me modify it?
:for i from=1 to 50 do={/ip firewall address-list add list=("user_".$i) address=(("172.16.1.".$i*5-4)"-"( "172.16.1.".$i*5))}
 
2frogs
Long time Member
Long time Member
Posts: 597
Joined: Fri Dec 03, 2010 1:38 am

Re: Please help to see this script for batch adding add-list  [SOLVED]

Mon Feb 08, 2021 3:43 pm

:for i from=1 to=50 do={/ip firewall address-list add list="user_$i" address="172.16.1.$(($i*5)-4)-172.16.1.$($i*5)"}
Last edited by 2frogs on Tue Feb 09, 2021 1:13 pm, edited 1 time in total.
 
cillininfo
just joined
Topic Author
Posts: 4
Joined: Thu Apr 23, 2020 11:09 am

Re: Please help to see this script for batch adding add-list

Mon Feb 08, 2021 5:36 pm

thank you
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1915
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Please help to see this script for batch adding add-list

Tue Feb 09, 2021 12:13 pm

:for i from=1 to=50 do:{/ip firewall address-list add list="user_$i" address="172.16.1.$(($i*5)-4)-172.16.1.$($i*5)"}
At least on bug in you line. Do needs = behind it.
:for i from=1 to=50 do={/ip firewall address-list add list="user_$i" address="172.16.1.$(($i*5)-4)-172.16.1.$($i*5)"}
 
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 21 guests