Skip to main content
Version: v1.2.0



network_of the network of an IP


network_of(val: ip [, mask: net|int|uint]) -> net


The network_of function returns the network of the IP address given by val as determined by the optional mask. If mask is an integer rather than a net, it is presumed to be a network prefix of the indicated length. If mask is ommited, then a class A (8 bit), B (16 bit), or C (24 bit) network is inferred from val, which in this case, must be an IPv4 address.


Compute the network address of an IP given a network mask argument:

echo '' | zq -z 'yield network_of(this,' -


Compute the network address of an IP given an integer prefix argument:

echo '' | zq -z 'yield network_of(this, 25)' -


Compute the network address implied by IP classful addressing:

echo '' | zq -z 'yield network_of(this)' -


The network of a value that is not an IP is an error:

echo 1 | zq -z 'yield network_of(this)' -


error("network_of: not an IP")