Skip to content

IP Address expressions¤

IP addresses are represented internally as a number, 128bit unsigned integer. Such a type can contain both IPv6 and IPv4. IPv4 are mapped into IPv6 space, using RFC 4291 "IPv4-Mapped IPv6 Address".


!IP.FORMAT: Convert an IP address into a string¤

Type: Mapping.

Synopsis:

!IP.FORMAT
what: <ip>

Convert the internal representation of the IP address into a string.


!IP.INSUBNET: Check if IP address falls into a subnet¤

Type: Mapping.

Synopsis:

!IP.INSUBNET
what: <ip>
subnet: <subnet>
!IP.INSUBNET
what: <ip>
subnet:
  - <string>
  - <string>
  - <string>

Test if what IP address belongs to a subnet or subnets , returns true if yes otherwise false.

Example with a single subnet

!IP.INSUBNET
what: 192.168.1.1
subnet: 192.168.0.0/16

Example with multiple subnets

!IP.INSUBNET
what: 1.2.3.4
subnet:
    - 10.0.0.0/8
    - 172.16.0.0/12
    - 192.168.0.0/16

The test that check if IP address is from IPv4 private address space as defined in RFC 1918.

More compact form:

!IP.INSUBNET
what: 1.2.3.4
subnet: [10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16]

Parse of the IP address¤

IP address is parsed automatically from a string. If needed, you may explicitly cast string-based IP address into the ip type:

!CAST
type: ip
what: 192.168.1.1

Parse of the IP subnet¤

IP subnet is parsed automatically from a string. If needed, you may explicitly cast string-based IP address into the ipsubnet type:

!CAST
type: ipsubnet
what: 192.168.1.1/16