Anybody knows how to change firewall rule order with script.
or
Add new firewall rule in the 1st row with script.
Thanks.
[admin@MikroTik] > ip firewall filter print
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; udp
chain=forward protocol=udp action=jump jump-target=udp
1 ;;; icmp
chain=forward protocol=icmp action=jump jump-target=icmp
/ip firewall filter add chain=forward protocol=tcp action=jump jump-target=tcp comment=tcp place-before=0
/ip firewall filter move 1 0
/ip firewall filter move [/ip firewall filter find comment="icmp"] 0
show us your scripts, maybe we can find where the errorThis still doesn't work. If you try to change position with move or place-before the script returns no such item or similar error.
Both commands work in winbox, ssh, etc. It's just a problem on running them from scripts.
What do you mean by internal ID ? Is 32 in the example above internal id ?Because it is the wrong way to do operations with items in scripts.
Proper way is to use find command to get internal IDs and work with those IDs.
[admin@MikroTik] > ip firewall filter print
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; udp
chain=forward protocol=udp action=jump jump-target=udp
1 ;;; icmp
chain=forward protocol=icmp action=jump jump-target=icmp
/ip firewall filter move [find comment="icmp"] [find comment="udp"]
/ip firewall filter move ([/ip firewall filter get [find comment="icmp"]]->".id") ([/ip firewall filter get [find comment="udp"]]->".id")