"place before" Mikrotik API

Hi,

Im using Router OS v6x with this API PHP CLASS

Im wondering how can I use “place before” in API ? this is example when I did from Mikrotik terminal

[me@myRo] > /ip firewall filter add chain=input dst-address="192.168.1.1" protocol="tcp" dst-port="81" action="accept" comment="TESTING PLACE BEFORE" place-before=[/ip firewall filter find where comment="SESUATU"]

Is it possible to use “place before” in API Mikrotik ? Please teach me how.

Thx in advance.

First, fetch the id of the rule you want to place the new one before. Then, refer to this id in the add command.

In raw API:

/ip/firewall/filter/print
?comment=SESUATU

!re
=.id=*4
=chain=input
<snip>
!done

/ip/firewall/filter/add
=chain=input
=dst-address=192.168.1.1
=protocol=tcp
=dst-port=81
=action=accept
=comment=TESTING PLACE BEFORE
=place-before=*4

!done
=ret=*3E

It works ! Thx nescafe2002, Really Apreciate it :slight_smile: