samedi 15 novembre 2014

Iptables - Redirecting from outgoing loopback traffic - is it possible?


Vote count:

0




I have 2 kinds of proxies in my local machine : stunnel and TOR-VPN.



  • stunnel is listening on port 6666

  • TOR-VPN is listening on port 9040


I want to get web traffic to go to stunnel first and the output traffic of stunnel go to tor-vpn. This needs double redirecting. is it possible to do it with iptables? I mean by using "table nat chain OUTPUT".


Because as far as I know "table nat chain OUTPUT" cant be called twice.


web traffic = browser listening on 127.0.0.1:6666


these are my rules:



iptables -t nat -A OUTPUT -p tcp -j REDIRECT --to-ports 6666


iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner bob -m tcp -j REDIRECT --to-ports 9040


iptables -t nat -A OUTPUT -p udp -m owner --uid-owner bob -m udp --dport 53 -j REDIRECT --to-ports 53


iptables -t filter -A OUTPUT -p tcp --dport 6666 -j ACCEPT


iptables -t filter -A OUTPUT -p tcp -m owner --uid-owner bob -m tcp --dport 9040 -j ACCEPT


iptables -t filter -A OUTPUT -p udp -m owner --uid-owner bob -m udp --dport 53 -j ACCEPT


iptables -t filter -A OUTPUT -m owner --uid-owner bob -j DROP



the above rules make stunnel work independently from TOR/VPN. i mean when browser is set with proxy, no traffic will go through TOR/VPN but if i turn off the proxy in browser, all traffic will go through TOR/VPN.


now i want to let browser have the proxy on and all web traffic go to stunnel first, but outgoing stunnel traffic(outgoing loopback traffic) can be redirected to TOR/VPN(127.0.0.1:9040)


is it possible ? how can i do that? somehow i mean double redirecting inside system.



asked 21 secs ago







Iptables - Redirecting from outgoing loopback traffic - is it possible?

Aucun commentaire:

Enregistrer un commentaire