Some of us who use web filter at home, such as Sophos XG to filter content, including HTTPS for the purposes of removing ads, malvare and generally unsafe and suspicious content may encounter an issues with some services that refuse to work if they detect MITM situation. Or you may be connecting to your home network from a finite number of places, so you would want to allow connections only from those networks.
Since there is only finite number of such services and locations it is feasible to just whitelist them on a case by case bases.
The guide below explains how to come up with a compact list of IP ranges for a specific organization from a single IP address. The command lines below will work on BSD and macOS; feel free to adjust accordingly for your system.
As an example, consider Netflix. It really does not like my firewall snooping on its traffics, so I had to whitelist it. I’m sure the process can be completely automated, including feeding the resulting network definitions into XG firewall, but for a handful of services it is probably not worth the effort.
Start with a single IP
Find a single IP belonging to the IP range in question. For example, disabling webfilter, turning on logging, and try to use the affected resource. Pick one of the IPs from the log. Lets assume it was
Determine the origin
mbp:~ me$ curl ipinfo.io/126.96.36.199/org AS2906 Netflix Streaming Services Inc. mbp:~ me$ whois -h whois.radb.net -- '-l 188.8.131.52' |grep origin: origin: AS2906
Query all routes
Query the same database for all routes: lets limit to IPv4 for now. To include ipv6 – grep by
mbp:~ me$ whois -h whois.radb.net -- '-i origin AS2906' |grep '^route:' |sed -e 's/route:[[:space:]]*\(\S*\)/\1/' 184.108.40.206/19 220.127.116.11/22 18.104.22.168/21 ... [deleted 38 entries] ... 22.214.171.124/24 126.96.36.199/24 188.8.131.52/24 184.108.40.206/24
Optimize and compact the network ranges
There are a bunch of calculators in existence, both online and command line; I stumbled upon this one TechZoom’s IP Address Calculator and keep using it successfully ever since.
Copy the output from the previous step and paste it into the calculator. You will get the following concatenated and optimized list, presented here in its entirety:
220.127.116.11-18.104.22.168 22.214.171.124-126.96.36.199 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168 22.214.171.124-126.96.36.199 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168 22.214.171.124-126.96.36.199 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168 22.214.171.124-126.96.36.199 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168
This is much more manageable list suitable for even manual entry into a firewall lists.