0

I have a very basic understanding of iptables from reading about 30 different similar questions people have asked and some tutorials. What I am trying to do is forward all of my outgoing traffic through SSH, to have it function as a sort of universal socks proxy. I don't have a way to test this right now, but this is what I've come up with on my own:

iptables -A OUTPUT -i eth0 -p tcp --destination-port 22 -j ACCEPT
iptables -A OUTPUT -i eth0 -p tcp -j REDIRECT --to-port 22

The first rule should automatically accept anything already destined for port 22, while the second rule should redirect any remaining outgoing packets to port 22.

My main issue is that I don't have a complete understanding on the differences between PREROUTING and OUTPUT, because I've seen them both be used in different ways to forward ports like this.

0

Use tsocks

"Through use of the LD_PRELOAD environment variable or the /etc/ld.so.preload file tsocks is automatically loaded into the process space of every executed program. From there it overrides the normal connect() function by providing its own. Thus when an application calls connect() to establish a TCP connection it instead passes control to tsocks"

| improve this answer | |
  • 1
    there's also dante-client doing the same trick with socksify. And for the solution, don't forget to use the "ssh -D" option to create the dynamic tunnel, acting as a socks server for those commands. – A.B Nov 22 '16 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.