I want all outgoing to traffic that is directed to a private IP (10.0.0.0 - 10.255.255.255, 172.16.0.0 - 172.31.255.255, 192.168.0.0 - 192.168.255.255) to be untouched. I want all other traffic redirected to localhost:6666 (where I am running a socks5 proxy).
I'm not sure what I need to do to not touch the private IP traffic but for the public traffic do I:
sudo iptables -t nat -A PREROUTING -p tcp -i <interface> -j REDIRECT --to-ports 6666
am I on the right track?
UPDATE: This did the trick:
echo "Flushing previous rules..." iptables -t nat --flush echo "Deleting and recreating the PUBPROXY chain..." iptables -t nat -X PUBPROXY iptables -t nat -N PUBPROXY echo "Setting iptables to ignore traffic directed to private ips..." iptables -t nat -A PUBPROXY -o lo -j RETURN iptables -t nat -A PUBPROXY -m iprange --dst-range 10.0.0.0-10.255.255.255 -j RETURN iptables -t nat -A PUBPROXY -m iprange --dst-range 172.16.0.0-172.31.255.255 -j RETURN iptables -t nat -A PUBPROXY -m iprange --dst-range 192.168.0.0-192.168.255.255 -j RETURN echo "Redirecting other traffic to socks5 proxy running at localhost:6666" iptables -t nat -A PUBPROXY -p tcp -j REDIRECT --to-port 6666