Примерно так:
iptables -t nat -N to_squid
iptables -t nat -A PREROUTING -p tcp --dport 80 -j to_squid
for a in $(host -t a gmail.com | awk '/has address/ {print $4;}'); do
iptables -t nat -A to_squid -j return
done
iptables -t nat -A to_squid --redirect --to-port 3128