Community discussions

MikroTik App
 
Anatoly
just joined
Topic Author
Posts: 10
Joined: Tue Feb 17, 2015 12:51 pm

add addres-list in 6.43.16 and older

Fri May 01, 2020 1:59 pm

In scripts and sheduler stopped working:
/ip firewall address-list add list=Control address=192.168.0.1

How now to solve the problem of adding to the list of specific IP addresses through the sheduler?

Offtopic:
Already very tired of redoing ~ 250 routers, scripts and environments every time a new firmware arrives. It has become much easier to use the old ones and hope that the security holes will not affect you. I suspect that we will use 6.43.16 to the stop, and then we will begin to switch to other equipment.
 
accarda
Member Candidate
Member Candidate
Posts: 214
Joined: Fri Apr 05, 2019 4:06 pm
Location: Italy

Re: add addres-list in 6.43.16 and older

Fri May 01, 2020 2:46 pm

Have you checked that the address is not already there ?
I have worked on a script to add IPs to the list and if the list was already containing the IP that I was going to add, it didn't do it and stopped running the script.
In my case I fixed it by removing the address first, then I added them.
 
Anatoly
just joined
Topic Author
Posts: 10
Joined: Tue Feb 17, 2015 12:51 pm

Re: add addres-list in 6.43.16 and older

Fri May 01, 2020 2:59 pm

Yes, I checked everything.

It works on 6.39.3, but not on 6.43.16 and 6.45.8.

Soon, from a Mikrotik fan, I will turn into a Mikrotik hater ...
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3348
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: add addres-list in 6.43.16 and older

Fri May 01, 2020 3:10 pm

This works and was just posted some days ago by me. viewtopic.php?f=9&t=160442&p=789115&hil ... ss#p789115
{
:local newIP 192.168.0.1
if ([:len [/ip firewall address-list find where address=$newIP list=Control]]=0) do {
	/ip firewall address-list add address=$newIP list=Control
	:put ("added entry: $newIP")
}
}
If IP already exists in an address list, just adding it will fail. Doing a test first, makes all works fine.
Testet in 6.45.8 and 6.47 beta

PS the outer {} is just to make it run when you cut/past to terminal windows.
 
Anatoly
just joined
Topic Author
Posts: 10
Joined: Tue Feb 17, 2015 12:51 pm

Re: add addres-list in 6.43.16 and older

Fri May 01, 2020 4:31 pm

Jotne, it works, thank you.
v6.43.16

Now I will cry from how many scripts I have to rewrite and from how much more complicated they become.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3348
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: add addres-list in 6.43.16 and older

Fri May 01, 2020 8:39 pm

You are welcome.

This is why I always run scripts from command line wrapped in {} and change :log to :put, to see all what is going on.