On Sunday 11 March 2018 05:35 PM, Nicolas Kovacs wrote:
Le 11/03/2018 à 12:31, Amos Jeffries a écrit :
OK, I got something that's starting to work.
EXCEPTIONS=$(egrep -v '(^\#)|(^\s+$)' /usr/local/sbin/no-proxy.txt)
for EXCEPTION in $EXCEPTIONS; do
$IPT -A PREROUTING -t nat -i $IFACE_LAN -d $EXCEPTION -j ACCEPT
The problem with this approach might be that domains are looked up for
their IPs at the time of rule creation and not at the time of request.
Since destinations like github.com, google.com, facebook etc use many
large pools of IPs, your rule might not match later in the day or after
a few days.
Better to use "ipset" along with dnsmasq and refer that ipset in the
iptables rule to match dst.
1. ipset create _ipsetname_ bitmap:ip
2. Configure dnsmasq to populate _ipsetname_ by adding following lines
for each domain to dnsmasq.conf:
3. Use dnsmasq as resolver-cache on your proxy machine and ensure that
squid uses your dnsmasq for DNS queries.
4. Add intercept iptables rules to not NAT the traffic to destination
iptables -A PREROUTING -t nat -i $IFACE_LAN -m set --match-set
_ipsetname_ dst -j ACCEPT
Dnsmasq will keep populating the ipset as and when a resolution request
is received for the matched domains. An ipset can hold 65534 entries.
I use this approach extensively to allow Anti-Virus and Windows updates
to the machines which otherwise are not allowed to access Internet
directly without configuring explicit proxy or through proxy.pac/wpad.
squid-users mailing list