0

I want to share a folder on a computer X to several other nodes, say A, B, C, which are on the same LAN. X is behind a router, and the router's IP address might change over the time (it's DHCP-allocated), and I don't have control on that. A, B, C each has a static IP address, and I can ping A, B, C from X. All the nodes are running Linux. What is the best practice if I want to share a folder on X to A, B, C?

I have known that one approach is workable to some extent, which is to setup NAT on the router to port 22 of X, and then use sshfs on A, B, C to mount the folder of X. However, the drawback is that the IP address of the router might change.

I also tried to use reverse ssh + sshfs. However, it seems that this can only share the folder to one node, e.g. X-->A, not to the entire network (A, B, C).

1
  • "share a folder" is Windows terminology, and usually applies to SMB/CIFS (Samba on Linux), which by default doesn't cross routers unless you configure the routers for that (not sure if you have access to that router). The are various other networked file systems available. If A, B, C have static addresses, I'd try NFS (which you need to setup on all machines). sshfs works by design only between two machines.
    – dirkt
    Commented Jul 5, 2018 at 5:58

1 Answer 1

0

The easiest way is not to use IP addresses at all and use a DDNS (dynamic DNS) entry for the server. There are many free DDNS services available: some are free (e.g. DNSdynamic); others you can pay for if you want additional features (e.g. No-IP). To keep the DDNS entry valid, you then run a program like ddclient which checks the IP address of the router every once in a while and sends an update request to the provider when needed; most providers allow the dyndns2 protocol for updates. Most Linux distributions carry ddclient in their repositories.

Here's a sample ddclient update configuration file (from DNSdynamic, but it will be very similar for other providers):

daemon=60                               # check every 60 seconds
syslog=yes                              # log update msgs to syslog
mail=root                               # mail all msgs to root
mail-failure=root                       # mail failed update msgs to root
pid=/var/run/ddclient.pid               # record PID in file.
ssl=yes                                 # use ssl-support.  Works with
                                        # ssl-library

use=web, web=myip.dnsdynamic.com        # get ip from server.
server=www.dnsdynamic.org               # default server
[email protected]                    # default login
password=password                       # default password
server=www.dnsdynamic.org,  \
protocol=dyndns2            \
awesome.dnsdynamic.com
3
  • Thanks for your reply! I just wonder what if I don't have Internet access from A, B, C?
    – leeyee
    Commented Jul 4, 2018 at 5:45
  • 1
    What is the configuration of this network? I assumed that the hosts were on the Internet because it's very unusual to see NAT being used on anything other than an Internet-facing host.
    – ErikF
    Commented Jul 4, 2018 at 5:51
  • This is a campus network. A, B, C are local nodes which are not allowed to be connected to Internet. The router and the nodes behind the router can access the Internet though.
    – leeyee
    Commented Jul 4, 2018 at 8:11

You must log in to answer this question.

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