Enable Firewall Rule form API ?

Hello

I like to remotely enable/disable a firewall rule in my Mikrotik RB1100, OS6.4 form a VB.net application

in normal script language I use this :" ip firewall filter enable 14" where “14” is the filter number

How do I do in API commands.. since I want to make a VB.net program to do this on a distance, ( par ex in a school, to disable students to go to internet )

Tnx for help

JP

please use search to find examples here on the forums, on what exactly you have to do. Also, http://wiki.mikrotik.com/wiki/API#Queries have useful examples.

Tnx Janisk, for tip, but I allready tried this for a week now…
I cant find the right syntax, I Always get the wrong answer
I must admit that I am very new to this API language
I think this must be a simple thing, since I just have to disable or enable this rule nr 14…
cant you give any tips… ?
Tnx

easiest way to understand RouterOS API would be to migrate to it from CLI with few exceptions:

  • item numbers in API are special ID field that is permanent for entry and never ever changes.
  • there is no scripting support as most of the computational tasks will run faster on general purpose CPU rather than CPU optimized for networking.

From this, to address specific firewall filter you have to somehow identify the entry, for example, by setting up unique comment. Then you do print and from the returned filter find entry with your comment, use .id field to address that rule (make changes to it/disable/remove)

Tnx
I used this message “ip/firewall/filter/getall”
there I see all my firewall rules
for ex I want to disable the last rule :

!re=.id=*A=chain=input=action=drop=in-interface=WAN-1=invalid=false=dynamic=false=disabled=false=comment=Drop ALL
!done

so i give this command, in a VB.net app ( see annex, that I use to test the API )

/ip/firewall/filter/set
=.id=*A
=disabled=true

but it give Always bad command… I’m stuck

JP
API_VB_Mikrotik.rar (109 KB)

I could do also

/ip/firewall/filter/disable=.id=*A

but it gave me error…

I need just a simple API replacement for

“ip firewall filter disable 14”

That is really my problem,

in fact the VB is not the problem… only the API is.. :frowning:

OK Good News.. found it

This syntax works

mk.Send(“/ip/firewall/filter/set”)
mk.Send(“=.id=*A”)
mk.Send(“=disabled=false”, True)

So for Disabling the opposite..

JP

you should look more carefully at what is written here:
http://wiki.mikrotik.com/wiki/API

I’m sorry but I believe its not that clear, and the lack of examples, makes it not easier for a newbie like me…
But OK, we 'v learned something

Also, I see that the proposed Class in VB.net does not work on “Framework 4.0”

Until 3.5 it works flawlessly..

Grtz

JP

this link was in the main API section:
http://wiki.mikrotik.com/wiki/API_command_notes

API examples.. no problem
VB.net examples… with sending some complex sentences… —> something else…