In a script I use following line to find out whether some address is already in a list:
/ip fire addr find where list=$listName address=$logIp
The block looks as follows:
:if ([:len [/ip fire addr find where list=$listName address=$logIp]] < 1) do={ /ip fire addr add address=$logIp list=$listName timeout=7d :log info message="failed src_ip=$logIp" }
The problem is that if I already have a subnet in the list, for example 205.210.31.0/24
, following addresses are still added individually:
- 205.210.31.109
- 205.210.31.164
- 205.210.31.199
because they weren't found by the find command.
How to find out if an address is in an address list, also taking subnets into account? Subnets should be not only /24
, but of any size.