1

The mission: set a ssh tunnel at port 7777
Use iptables to re-direct port 80 to port 7777
That way my web browsers can use the ssh tunnel

Establish a ssh tunnel:

ssh -D 7777 -fCN user@remote_ip

My iptables:

cat /etc/sysconfig/iptables

*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 7777
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -j ACCEPT
-A FORWARD -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -j ACCEPT
COMMIT

however it does not seem to be working. my web browser is not showing my remote server's IP ( ssh tunnel's )

UPDATE..

forget testing it with web browsers.. this wget command should be printing my ssh tunnel's IP. but it is not. ( it's printing my real IP. )

  wget -qO- http://ipecho.net/plain ; echo

wget uses port 80 also.

  • totally wrong usage of socks proxy protocol. Set socks proxy in your browser's settings not via iptables. – Ipor Sircer Jan 30 '17 at 16:19
  • then use tsocks – Ipor Sircer Jan 30 '17 at 16:35
1

You can add it below *nat block.

*filter means filter table which is the default if you haven't specified any table.

  • where does it go ? I tried. – user213234 Jan 30 '17 at 16:08
  • recreate the file with iptables-save, if you don't understand the format. – Ipor Sircer Jan 30 '17 at 16:08

Your Answer

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