Hi everyone,
I have this line
/ip firewall connection print from=[find dst-address="15.15.15.1:9987"]
and return this
Flags: E - expected, S - seen-reply, A - assured, C - confirmed, D - dying, F - fasttrack, s - srcnat, d - dstnat
PROTOCOL SRC-ADDRESS DST-ADDRESS TCP-STATE TIMEOUT ORIG-RATE REPL-RATE ORIG-PACKETS REPL-PACKETS ORIG-BYTES REPL-BYTES
0 SAC s udp 12.12.12.113:51013 15.15.15.1:9987 2m59s 672bps 656bps 1 647 1 645 73 577 97 057
I have this other script
/ip firewall address-list
:foreach ip in=[find] do={
:local add [get $ip address]
:if (:put ([/ip firewall connection find dst-address="15.15.15.1:9987"]!= "") do={
remove $ip
}
}
I need to verify first if that connection exist so far works... and beside compare the src-address with the $ip variable from the loop and if all is true do something
Any idea please....
Thanks for advance
You can’t use put there:
:if (:put ([/ip firewall
Use:
/ip firewall connection remove [find where dst-address="15.15.15.1:9987"]
Hi,
Thanks for the reply..
This line return me TRUE or FALSE, just that
:put ([/ip firewall connection find dst-address="15.15.15.1:9987"]!= ""
By the way, can you help me with my other issue...
Flags: E - expected, S - seen-reply, A - assured, C - confirmed, D - dying, F - fasttrack, s - srcnat, d - dstnat
PROTOCOL SRC-ADDRESS DST-ADDRESS TCP-STATE TIMEOUT ORIG-RATE REPL-RATE ORIG-PACKETS REPL-PACKETS ORIG-BYTES REPL-BYTES
0 SAC s udp 12.12.12.113:51013 15.15.15.1:9987 2m59s 672bps 656bps 1 647 1 645 73 577 97 057
I need to get the src-address and compare with my ip list from the loop, using this sentence /ip firewall connection find dst-address="15.15.15.1:9987"
Best regards,
Jakclyn
:put is there show humans, an :if does not need to see it, it knows what the result is without seeing.
The connections table is table that is shown and you best use “print” to find a value. I had to use also a :pick, which is scanning the lines till it finds what is sought and cut is out.
:set $compare (:get ([:pick [/ip firewall connection print as-value where dst-address~"15.15.15.1"] 0]->"src-address")); :put $compare
You see that I put a “~” between dst-address and the IP address. This way, you don’t need to state the port (9987) and this is handy if you want to match source a src-address. It will match any IP address of 15.15.15.1