Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have an SSH tunnel (ssh -ND, that works fine for browsers if point them to as socks5 proxy, but other traffic is still not going through this tunnel.

How would i make absolutely all traffic go through SSH tunnel?

Any tools, settings i need for that?

The system i am using is Debian and MacOS so better if solution is more or less general for both platforms.

share|improve this question
I think that you're searching for a VPN... ssh is (IMHO) not the right tool for this. – Uwe Plonus Dec 11 '12 at 8:35
@UwePlonus VPN is not available in this case. Sure i am aware of OpenVPN and can set it up myself. But it is just not available. – AlexKey Dec 11 '12 at 8:41
up vote 3 down vote accepted

You can create VPN using ssh. Here is the relevant section from man ssh:

    ssh contains support for Virtual Private Network (VPN) tunnelling using the tun(4) 
    network pseudo-device, allowing two networks to be joined securely.  The sshd_config(5)
    configuration option PermitTunnel controls whether the server supports this,
    and at what level (layer 2 or 3 traffic).

    The following example would connect client network with remote network using a point-to-point connection from to,
    provided that the SSH server running on the gateway to the remote network,
    at, allows it.

    On the client:

           # ssh -f -w 0:1 true
           # ifconfig tun0 netmask
           # route add

    On the server:

           # ifconfig tun1 netmask
           # route add

At the end, you will have tunnel interface which you can use to forward your traffic.

share|improve this answer
This is really cool! I've been using SSH tunnels for quite a while and never knew about this. – Dan Jan 8 '13 at 22:43
Thanks, that's great! – AlexKey Jun 16 '14 at 8:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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