parse_ipv4()

Applies to: ✅ Azure Data ExplorerAzure MonitorMicrosoft Sentinel

Converts IPv4 string to a signed 64-bit wide long number representation in big-endian order.

Syntax

parse_ipv4(ip)

Learn more about syntax conventions.

Parameters

Name Type Required Description
ip string ✔️ The IPv4 that is converted to long. The value may include net-mask using IP-prefix notation.

IP-prefix notation

IP-prefix notation (also known as CIDR notation) is a concise way of representing an IP address and its associated network mask. The format is <base IP>/<prefix length>, where the prefix length is the number of leading 1 bits in the netmask. The prefix length determines the range of IP addresses that belong to the network.

For IPv4, the prefix length is a number between 0 and 32. So the notation 192.168.2.0/24 represents the IP address 192.168.2.0 with a netmask of 255.255.255.0. This netmask has 24 leading 1 bits, or a prefix length of 24.

For IPv6, the prefix length is a number between 0 and 128. So the notation fe80::85d:e82c:9446:7994/120 represents the IP address fe80::85d:e82c:9446:7994 with a netmask of ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00. This netmask has 120 leading 1 bits, or a prefix length of 120.

Returns

If conversion is successful, the result is a long number. If conversion isn't successful, the result is null.

Example

datatable(ip_string: string)
[
    '192.168.1.1', '192.168.1.1/24', '255.255.255.255/31'
]
| extend ip_long = parse_ipv4(ip_string)

Output

ip_string ip_long
192.168.1.1 3232235777
192.168.1.1/24 3232235776
255.255.255.255/31 4294967294