I would love to hear your ideas on this.
Goal - check if example IP 158.69.17.240 is in 200+ list of CIDR ranges (for example 158.69.17.0/24)
I would love to hear your ideas on this.
Goal - check if example IP 158.69.17.240 is in 200+ list of CIDR ranges (for example 158.69.17.0/24)
Hi Hayden - we do not currently have a plugin that can return output showing whether or not an IP address was within a specific CIDR range. It would be useful to have as a plugin, though!
For now your best bet would be to write a Python Script step to check for this. Python includes a library for IP address manipulation that can help with this
how do import that mod into the python script action? didnāt work just now āimport ipaddressā or from ipaddress import ip_network, ip_address
It should work - is your import within the run
function? It should look something like
def run(params={}):
import ipaddress
# Do something with ipaddress here
that was itā¦
now to check against a big list of ranges.
def run(params={}):
import ipaddress
an_address = ipaddress.ip_address(ā192.168.0.1ā)
a_network = ipaddress.ip_network(ā192.168.0.0/24ā)
address_in_network = an_address in a_network
return {"output":str(address_in_network)}
Is this how you would do it? I need to refactor this 4sureā¦
def run(params={}):
import ipaddress
networks = ["1.1.1.1/24".... etc]
an_address = ipaddress.ip_address("{{["loop over ips"].[$item]}}")
s = set(networks)
trues = []
for n in s:
if an_address in ipaddress.ip_network(n):
trues.append("true")
return {"output":trues}
Hi Hayden -
That is very similar to how I would do it! Let us know how that ends up working for you!