I am trying to write a rule to a mikrotik router via API. I am having the hardest time with it, and have hit a wall as i can can copy/paste the commands and just set the format correctly and it all runs via ssh and script, but i need it to add via API.
All IP's have been scrubbed for anonymity.
Here is the shell command:
/ip firewall filter add chain=input action=accept comment=" FW Rule for remote access" src-address=1.2.3.4/27 place-before=2
I am using vb.net and here is my code for the above command:
'Add Firewall rule for remote access
mk.send("ip/firewall/filter/add")
mk.send("=chain=input")
mk.send("=action=accept")
mk.send("=comment=" & Chr(34) & " FW Rule for remote access" & Chr(34))
mk.send("=src-address=1.2.3.4/27")
'sets at top above all predefined rules
mk.send("=place=before=\*2", True)
This is the error i receive when reading the stream back:
!trap=message=no such command prefix
Here is the formatted excerpt of the actual text sent across the mk.send command:
(cmdSend is just a log identifier i use for the specific excerpt during debugging).
cmdSend: ip/firewall/filter/add
cmdSend: =chain=input
cmdSend: =action=accept
cmdSend: =comment="FW Rule for remote access"
cmdSend: =src-address=1.2.3.4/27
cmdSend: =place=before=\*2
I have had to do some fancy things to make other things happen in this project because of the API weirdness as well, but haven't unlocked this secret.
Any help or insight would be greatly appreciated!! thank you!