CONTAINS

These functions determine whether a specified IPV4 or IPV6 host address is contained by a network.
CONTAINS(network, integer, host_ip)

where network is the IPV4 or IPV6 address of the containing network, integer completes the network IP address by providing the length of the mask (number of leading bits set to 1), and host_ip is a single IPV4 or IPV6 host IP address. The integer must be in the range of 0 to 32 for IPV4 netmasks and 0 to 128 for IPV6 netmasks.

To specify a constant value for the network or host_ip arguments, use the IPV4 or IPV6 keyword.

These functions return a Boolean value (true, false, unknown).

For example:

premdb=# select hostip,contains(ipv4 '10.10.10.0',24,hostip) from myhosts;
   hostip    | contains 
-------------+----------
 10.10.10.5  | t
 10.10.10.6  | t
 10.10.10.10 | t
 10.10.190.1 | f
(4 rows)

premdb=# select contains(ipv6 '684D:1111:222:3333:4444:5555:6:88',64,ipv6 '684D:1111:222:3333:4444:5555:6:77') from sys.const;
 contains 
----------
 t
(1 row)

premdb=# select contains(ipv6 '684D:1111:222:3333:4444:5555:6:88',128,ipv6 '684D:1111:222:3333:4444:5555:6:77') from sys.const;
 contains 
----------
 f
(1 row)