Table of Contents

Tunnel Interfaces

If you are looking to establish an SSH tunnel between two networks and treat the tunnel as an interface, this may help.

To recap some of the options: “-fw 0:0” forks the ssh process to the background / opens a tunnel and “0:0” picks the local and remote interfaces (ie tun0 and tun0). The “-o” options are used to specify parameters for openSSH.

Results

Now you can access the remote computer using “192.168.5.2” and your communications will go through the ssh tunnel. In the above script you may wish to modify the network and mask to fit your needs. I chose “192.168.5” but your configuration will likely be different.

I'm not going to be able to elaborate on the iptables rules still a little green there, but they work.

Here are a couple usage examples. Directing traffic to the tunnel interface. first example 10.10.132.0-255 second just 10.10.182.15

/sbin/route add -net 10.10.132.0 netmask 255.255.255.0 dev tun0
/sbin/route add -net 10.10.182.15 netmask 255.255.255.255 dev tun0

Sources