IsInCIDR
less than a minute
Overview
The IsInCIDR converter checks whether an IP address falls within one or more CIDR ranges and returns a boolean value. This is useful for classifying traffic as internal or external, enforcing network policies, or tagging logs by network segment.
Syntax
IsInCIDR(ip, cidrs)
- ip: the IP address string to check
- cidrs: an array of CIDR range strings to match against
Examples
Input
{
"_type": "log",
"body": {
"client_ip": "192.168.1.100"
},
"resource": {...},
"attributes": {}
}
Statement
set(attributes["is_private"], IsInCIDR(body["client_ip"], ["192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12"]))
set(attributes["is_cdn"], IsInCIDR(body["client_ip"], ["8.8.0.0/16", "1.1.1.0/24"]))
Output
{
"_type": "log",
"body": {
"client_ip": "192.168.1.100"
},
"resource": {...},
"attributes": {
"is_private": true,
"is_cdn": false
}
}
The IP 192.168.1.100 matched the 192.168.0.0/16 CIDR range, returning true for the private network check. It did not match any of the public CIDR ranges, returning false.