Windows – Samba not working on LAN without internet connection

centoscentos7sambasamba4windows

I've got a Samba 4 share on a CentOS 7.2 server in my LAN that I access from some Windows 10 clients.

The clients use the server IP to access the share and Samba is configured to be a stand-alone server, not a domain member one.

Everything works fine as expected when internet connection is up, but when there's no internet connection the clients need up to 20 minutes before displaying the login credentials window.

It doesn't seem to be a network related problem: the clients can reach the server, ping it as fast as usual, use other protocols such as HTTP or SSH and in general perform every other network activity over the LAN flawlessly.

Also, the fact that it works after a long waiting, suggests me there's some kind of timeout involved in the process.

If disconnect the WAN cable from my local router and try to access the Samba share from the client, it starts to wait for something (green loading progress on address bar slowly moves), but as soon as I plug in the WAN cable again, the client shows the login window.

The Samba logs (debug level 5) don't show anything abnormal, but there seem to be many connecting attempt which are indeed accepted by the server:


[2016/11/15 16:18:34.378116, 3] ../source3/lib/access.c:338(allow_access)
Allowed connection from 192.168.100.5 (192.168.100.5)
[2016/11/15 16:18:34.436829, 5] ../lib/dbwrap/dbwrap.c:178(dbwrap_check_lock_order)
check lock order 2 for /var/lib/samba/serverid.tdb
[2016/11/15 16:18:34.436924, 5] ../lib/dbwrap/dbwrap.c:146(dbwrap_lock_order_state_destructor)
release lock order 2 for /var/lib/samba/serverid.tdb
...
... this is repeated an unbelievably lot of times ...
...

I'm incline to think it's a Windows 10 related problem more than a network/samba/server one.

Best Answer

I get the exact same situation as yours -- Samba in LAN works well when WAN port is up, but is painfully slow if WAN port is down. I finally figured out why with tcpdump.

Samba tries to resolve its hostname.

My Samba server does not have its own hostname entry in /etc/hosts, so it tries to resolve it on the Internet, this takes a long time if WAN is down.

Add your Samba server's A / PTR record to your LAN nameserver (which is used by Samba), or just add a hostname entry to /etc/hosts on Samba. No more green progress bars!

Related Topic