0

I have a synology server behind an unconfigurable NAT, and a linux box behind a configurable NAT. I want to establish an autossh tunnel to mount an NFS drive (shared by the synology box) on the linux box.

From the synology box, I execute the following:

autossh -v -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -i /path/id_rsa -NL 2049:localhost:20049 [email protected] -p <forwarded_ssh_port>

However, I get the following error:

debug1: Local connections to LOCALHOST:2049 forwarded to remote address localhost:20049
debug1: Local forwarding listening on ::1 port 2049.
bind [::1]:2049: Address already in use
debug1: Local forwarding listening on 127.0.0.1 port 2049.
bind [127.0.0.1]:2049: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 2049
Could not request local forwarding.

Indeed (of course), NFS is listening on 2049 on the synology server:

user@synology:~$ netstat -plant|grep 2049
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::2049                 :::*                    LISTEN      -

Any thoughts on how to establish this tunnel, while avoiding the listening port conflict?

Thanks in advance...

2 Answers 2

2

Your tunnel goes backwards: if the Linux server wants to mount the filesystem, then ssh on the Synology doesn't need to listen on any ports at all (why would it, if the real NFS service is already doing so).

Instead the tunnel's "listen" side needs to be on the Linux server (i.e. you want an SSH -R tunnel), which will then connect to the real NFS listener on the Synology.

ssh -R 22049:localhost:2049 [email protected]

(You also have the port specification backwards, too – the listening port goes first, the connect target last.)

1

Ok, think I solved it. Instead of -L, I need to use -R:

autossh -v -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -i /path/id_rsa -NR 2049:localhost:20049 [email protected] -p <forwarded_ssh_port>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .