Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am setting up an SSH TUN ("-w") VPN using this how-to:

I have the following in my /etc/network/interfaces:

iface tun0 inet static
       pre-up ssh -f -w 0:0 'ifdown tun0; ifup tun0'
       pre-up sleep 10
       up route add -net netmask gw tun0
       up route add gw eth0
       up route add default gw tun0
       up route del default gw eth0
       down route add default gw eth0
       down route del default gw tun0
       down route del -net netmask gw tun0
       down route del gw eth0

Then tun0 on the machine I'm tunneling from (the ssh client) comes up fine, but traffic does not route. This makes some sense, since that code is trying to use (the tun IP of the machine I'm SSHing into) as default gateway instead of the actual remote default gateway. When I put the actual remote gateway IP ( in the routes, the commands fail with a "not found" error.

What should I be doing differently?

share|improve this question
You've left out a lot of information. Using the linked article can you identify which machine you're referring to when you say 'it'. Is it Machine A, or Machine B? Did you set up the config on both ends of the tunnel? Did the manual process work before you tried the automated ifup config? – John Weldon Oct 22 '10 at 16:06
Can you ping when the tunnel is up? – Jimmy Hedman Feb 9 '11 at 14:20

1 Answer 1

up vote 1 down vote accepted

In addition to running:

sysctl -w net.ipv4.ip_forward=1

on Ubuntu it seems you also need to run:

iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
share|improve this answer

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.