parse_ipv6()

Converts IPv6 or IPv4 string to a canonical IPv6 string representation.

parse_ipv6("127.0.0.1") == '0000:0000:0000:0000:0000:ffff:7f00:0001'
parse_ipv6(":fe80::85d:e82c:9446:7994") == 'fe80:0000:0000:0000:085d:e82c:9446:7994'

Syntax

parse_ipv6(Expr)

Arguments

  • Expr: String expression representing IPv6/IPv4 network address that will be converted to canonical IPv6 representation. String may include net-mask using IP-prefix notation.

IP-prefix notation

IP addresses can be defined with IP-prefix notation using a slash (/) character. The IP address to the LEFT of the slash (/) is the base IP address. The number (1 to 127) to the RIGHT of the slash (/) is the number of contiguous 1 bits in the netmask.

Returns

If conversion is successful, the result will be a string representing a canonical IPv6 network address. If conversion isn't successful, the result will be null.

Example

datatable(ip_string:string, netmask:long)
[
 '192.168.255.255',     32,  // 32-bit netmask is used
 '192.168.255.255/24',  30,  // 24-bit netmask is used, as IPv4 address doesn't use upper 8 bits
 '255.255.255.255',     24,  // 24-bit netmask is used
]
| extend ip_long = parse_ipv4_mask(ip_string, netmask)
ip_string netmask ip_long
192.168.255.255 32 3232301055
192.168.255.255/24 30 3232300800
255.255.255.255 24 4294967040