How to configure a tun interface on Linux for SSH port forwarding?

Posted by sarshad on Server Fault See other posts from Server Fault or by sarshad
Published on 2011-04-15T22:15:06Z Indexed on 2012/03/26 11:33 UTC
Read the original article Hit count: 300

Filed under:
|
|

I am trying to forward port 139 from a Windows machine to my Ubuntu SSH server on a tun interface with the ip address 10.0.0.1.

This is so that I can access the windows shares on the machine on my Ubuntu server, through the reverse tunnel.

I can forward ports to 127.0.0.1, but not to 10.0.0.1.

On windows I am using the Tunnelier ssh client.

On my Ubuntu server, the following message is printed in auth.log:

Received disconnect from 124.109.51.154: 11: Server denied request for client-side server-2-client forwarding on 10.0.0.1:139.

So far i have tried the following settings:

GatewayPorts yes
PermitTunnel yes
AllowTcpForwarding yes 

in the /etc/ssh/sshd_config file, but it did not work.

I set up the tun like this:

sudo tunctl -t loc_0 -u myusername
sudo ifconfig loc_0 inet 10.0.0.1 netmask 255.255.255.0 up

The settings in the Tunneler ssh client should not matter because I can forward port 139 successfully to the Microsoft Loopback Adapter on a Windows machine running the WinSSHD server.

Versions: Windows is XP SP3, Ubuntu is 10.10.


Update:

I tried to forward the port to a number greater than 1024 mentioning the IP address of the tun, and it successfully connected but the forwarding was done on 127.0.0.1 instead of the tun's IP address 10.0.0.1.

So there are two separate problems now, when connecting from the Windows machine:

1) Forwarding on ports less than 1024 is probably being denied. How can we allow that on the server?

2) Forwarding is done only on 127.0.0.1 even if I mention 10.0.0.1 which is the tun's IP address.

Another attempt: I also tried to forward port 22 of a Linux machine to the tun's port 55567. It showed success. But when I tried to ssh into that port using both local addresses, on the Linux machine in its debug display I got the error Connection failed: no route to host when using 127.0.0.1 to connect and simply Connection refused when using the tun's IP address.

So the tun is not getting the forwarded port no matter we connect from a Windows client or a Linux client.

© Server Fault or respective owner

Related posts about ssh

Related posts about port-forwarding