theopolis
WITH routes_to_corporate_network AS (
SELECT * FROM routes WHERE interface NOT IN (
SELECT interface FROM (
SELECT
interface,
address,
inet_aton(address) AS n,
inet_aton('192.168.0.0') min,
inet_aton('192.168.0.255') as max
FROM interface_addresses
WHERE n > min AND n < max)
) AND type = 'static' AND gateway <> '127.0.0.1')
SELECT destination rd, gateway rg FROM routes
WHERE destination = '0.0.0.0' AND gateway NOT IN (
select gateway FROM routes_to_corporate_network);
I'm sure it can be improved 😕