Community discussions

MikroTik App
 
LennyLip
just joined
Topic Author
Posts: 2
Joined: Wed Oct 14, 2020 10:06 pm

Got ip firewall rules state/flag

Wed Oct 14, 2020 10:16 pm

Hello all, I am tried to find my issue but with no success.

So, I have a custom application with a Switch button. I want to allow this button to enable and disable the firewall filter rule with id=1.

Enable event:
ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no ha@192.168.1.1 '/ip firewall filter enable 1'
1
Disable event:
ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no ha@192.168.1.1 '/ip firewall filter disable 1' 
1

check state event: ????

What's the best way to get state enabled/disabled of rule?
Thanks in advance!
Last edited by LennyLip on Thu Oct 15, 2020 11:55 am, edited 2 times in total.
 
LennyLip
just joined
Topic Author
Posts: 2
Joined: Wed Oct 14, 2020 10:06 pm

Re: Got ip firewall rules state/flag

Thu Oct 15, 2020 11:51 am

ok, I already found it.:
/put [ip firewall filter get number=1 disabled]
 
User avatar
eworm
Long time Member
Long time Member
Posts: 686
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Got ip firewall rules state/flag

Thu Oct 15, 2020 11:27 pm

ok, I already found it.:
/put [ip firewall filter get number=1 disabled]
You should never use index in scripts, that will break! Instead find the correct rule with whatever criteria it has, for example giving it the comment "first":
:put [ /ip firewall filter get [ find where comment="first" ] disabled ]
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts

Who is online

Users browsing this forum: No registered users and 30 guests