IPADDR

Represents an IPv4 or IPv6 address.

LITERAL NOTATION:

IPv4 addresses can be expressed using dot-decimal notation:

192.168.1.0

Conversion

1
2
3
4
IPADDR(1)                           // => 0.0.0.1
IPADDR(1L,1L)                       // => ::1:0:0:0:1
IPADDR("192.168.0.1")               // => 192.168.0.1
IPADDR("2a00:1450:4010:c05::69")    // => 2a00:1450:4010:c05::69
  1. converts a numeric value to IPv4 address
  2. converts two 64 bit values to IPV6 address
  3. converts a string with IPv4 address to IPADDR
  4. converts a string with IPv6 address in hextet notation to IPADDR

Functions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ip1=213.44.17.8
ip2=IPADDR('2001:db8:85a3::8a2e:370:7334')

ip1 < ip2                   // => TRUE
ip1 = ip2                   // => FALSE
ip1 > ip2                   // => FALSE
ASN(ip)                     // => 5410
ASNAME(ip)                  // => "AS5410 Bouygues Telecom SA"
CC(ip)                      // => "FR"
DNS_LOOKUP(ip)              // => "i15-lef02-ix2-213-44-17-8.ft.lns.abo.bbox.fr"
IPLOC(ip)                   // => {cc="FR" city="--" geo=48.8582,2.3387}
IPIN(ip, 213.44.17.8/24)    // => TRUE
IS_IPV4(ip)                 // => TRUE
IS_IPV6(ip)                 // => FALSE

Parsing

1
IPADDR:fieldname

Masking IPv4 Addresses

When you need to anonymise octects of IPv4-addresses then you can use bitwise & function:

1
2
3
4
5
dual | select(ipaddr:192.168.234.49)
| select(ipaddr,
             masked_last_oct:ipaddr & 0xFFFFFF00l,
             masked_last_2_oct:ipaddr & 0xFFFF0000l)
;
ipaddr masked_last_oct masked_last_2_oct
192.168.234.49 192.168.234.0 192.168.0.0