This way one can check if an ip is in the range of a given network. Pretty simple, yeah! But I had the need to query ip address that are not in a specific network range . Well there is no opposite operator – at least I couldn’t find one. So what I did is is the following:

SELECT COUNT(*) FROM ips WHERE CASE WHEN ip <<= inet '192.168.1/24' THEN false ELSE true END