Search code examples
mountsambaoracle-cloud-infrastructureubuntu-22.04zerotier

Ubuntu (Oracle VM) - Mounted Samba shares hang indefinitely


I have a VM instance on Oracle Cloud (Ubuntu 22.04) set up with ZeroTier to act as a web server for some services that should work with my local Synology NAS.

For some of those services I also need to mount three SMB shares from my NAS with the ZeroTier tunnel, but I can't make it work. I used mount and mount.cifs plenty of times with automounting too, this time it acts very strange:

  • running the mount command seems to succeed from the console, but /var/log/syslog reads
CIFS: VFS: \\XXX.XXX.XXX.XXX has not responded in 180 seconds. 
Reconnecting...
  • if trying to access one of the shares (ls or lsof or cd or any other command), it succeeds for only one of the shares (always the same one), but only for the first time any command is given:
$ ls /temp
folder1     folder2     folder3
  • any other following command just "hangs" as if they system is working on something, but it stays like that indefinitely most of the times:
$ ls /temp
█

Just a few times it spits out this error

lsof: WARNING: can't stat() cifs file system /temp
      Output information may be incomplete.
ls        1475                         ubuntu    3r      DIR               0,44        0  123207681 /temp

findmnt reads:

└─/temp                                       //XXX.XXX.XXX.XXX/Downloads cifs        rw,relatime,vers=2.0,cache=strict, username=[redacted],uid=1005,noforceuid,gid=0,noforcegid,addr=XXX.XXX.XXX.XXX,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=65536,wsize=65536,bsize=1048576,echo_interval=60,actimeo=1
  • for the remaining two "mounted" shares, none of them seems to respond to any command, not even the very first command, and they just hang like the one share that, at least, lets me browse for one time;
  • umount and umount -l take at least 2-3 minutes to successfully unmount the shares.

Same behavior when using smbclient and also with NFS shares from the same NAS.

What I have already tried:

  • update kernel and all packages;
  • remove, purge and reinstall cifs-utils, smbclient and so on...
  • tried mounting the same shares in another client / node within the ZeroTier network and it works just fine; also browsing from Windows and Android file manager apps with and without ZeroTier works flawlessly;
  • tried all SMB versions including SMBv3 and SMBv1 (CIFS);
  • tried different browsing or mounting methods / commands including mount, mount.cifs, autofs, smbclient;
  • tried to debug what happens behind the console, but didn't found anything that seems related to this in logs, htop or anything else. During the "hanging" sessions there is no spike in CPU, RAM or Network usage in either the Oracle VM or Synology NAS;
  • checked, reset and reconfigured all permissions on my NAS for shares, folders and files recursively and reconfigured users groups permissions.

What I haven't tried yet (I'll try as soon as possible):

  • reproduce this on another Oracle VM configured the same as the faulty one and another with a different base image (maybe Oracle Linux?);

It seems to me that the mount.cifs process doesn't really succeeds in mounting the share correctly, as it doesn't show as such anywhere. It also seems an issue not related to folder/file permissions, but rather something related to networking?

A note on something that may or may not be related to this: ZeroTier on my Synology NAS does not seems to work with IPv4 only - it remains OFFLINE. The node goes ONLINE only when IPv6 is enabled, but I must say that this is the only node in my ZT network that shows a IPv6 as public IP in the ZT web GUI - the other nodes show IPv4 public addresses.

If anyone has any clue on this, I'll be happy to support and reproduce any advice. Thank you!


Solution

  • I'm using YailScale, but I presume it will work the same.

    You need to add the port 445 to /etc/iptables/rules.v4 just under the SSH setup like below:

    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT (like this)
    

    Then you need to edit the interfaces in /etc/samba/smb.conf to:

    interfaces = lo tailscale0 100.0.0.0/24
    

    Obviously, my interface is tailscale0, but yours will be different. Use ip link show to find yours. You may also need to change your IP range to suit ZeroTeirs, such as 100.0.0.0/24, which is what tailscale uses.

    Then reboot!

    I couldn't get it working without doing this.