isipinsubnet

Table of Contents

Prototype: isipinsubnet(range, ip_address1, ip_address2, ...)

Return type: boolean

Description: Returns whether the given range contains any of the following IP addresses.

Arguments:

  • range: string, in the range: .*

Example:

Run:

bundle agent main
{
  classes:

      "in_192" expression => isipinsubnet("192.0.0.0/8", "192.1.2.3");
      "in_192_2_2_2" expression => isipinsubnet("192.2.2.0/24", "192.1.2.3");

  reports:

    in_192::
      "The address 192.1.2.3 is in the 192/8 subnet";
    !in_192_2_2_2::
      "The address 192.1.2.3 is not in the 192.2.2/24 subnet";
}

Output:

R: The address 192.1.2.3 is in the 192/8 subnet
R: The address 192.1.2.3 is not in the 192.2.2/24 subnet

History: Was introduced in CFEngine 3.10.

See also: iprange()