Author Topic: Samba - cached server IP address?  (Read 643 times)

Dariusz Piatkowski

  • Hero Member
  • *****
  • Thank You
  • -Given: 13
  • -Receive: 10
  • Posts: 601
    • View Profile
Samba - cached server IP address?
« on: September 05, 2019, 04:08:35 am »
I run static IP addresses on my LAN, all of it served out by the router where the MAC address to IP address assignment is made. Most devices (where possible) are set to DYNAMIC IP, but of course the router serves up the pre-defined static IP out to the device. If that is not possible some devices actually have the IP address set to STATIC and it's directly updated on the device itself.

OK, all good.

The other day we picked up a Google Home Hub Display device, my wife wanted to have something in the kitchen that would serve up the cooking recipes and give her easy access to on-line stuff w/o having to rely on a laptop or another display. Easy enough right?

Well, I pre-allocate my IP blocks per groups of devices, meaning: media devices are lumped into an IP address range, as are the PCs, the mobile devices, and so on.

I needed to make room for the Google Hub and that meant I had to bump my NAS box from it's IP address to something new. No problem there, router was updated, NAS re-booted, it picked up the new IP.

I then updated my HOSTS file to reflect the new addresses, re-booted (just to be safe) only to discover upon a re-boot that my NetDrive mapping would no longer find the NAS box. So off I went investigating and found that if I replace the alias I was using in the NetDrive resource mapping with an actual IP address the connectivity is back up (see this logging in the debug listing below).

That leads me to believe that the Samba client is maintaining a mapping of the actual IP address the alias was previously pointing to and re-using it instead of querrying it up each time.

The question therefore is: does anyone know where that alias to IP address mapping is cached in the Samba configuration?

While the static IP address setup works, I really do not want to use that in the NetDrive resource setups and would prefer to use the alias instead and rely on the HOSTS file driven mapping.

btw: doing 'ping nas' from CLI successfully shows the new IP address, I can also point the browser to that nas box and reach it successfully.

Code: [Select]
Samba client 3.6.0 build 20190324 based on 4.10.6
This build is maintained by netlabs
2019/09/04 21:31:20.24: 9 1: Working with 64 bit fileio NDFS
2019/09/04 21:31:20.38: 9 1: NdpIOCTL init thread
2019/09/04 21:32:00.74: 9 2: NdpCreateConnection in
2019/09/04 21:32:00.74: 9 2: NdpCreateConnection send CONNECT
2019/09/04 21:32:00.74: 1 2: Connecting to \\admin:*********@home:nas\vol1. Master HOME:1
2019/09/04 21:32:05.79: 4 2: Connection to nas failed (Error NT_STATUS_IO_TIMEOUT)
2019/09/04 21:32:05.79: 9 2: NdpCreateConnection [0] 87
2019/09/04 21:32:05.79: 9 2: NdpCreateConnection in
2019/09/04 21:34:37.75: 9 2: checkMountResource in tid#2
2019/09/04 21:34:37.75: 1 2: Connecting to \\admin:*********@home:nas\vol1. Master HOME:1
2019/09/04 21:34:42.77: 4 2: Connection to nas failed (Error NT_STATUS_IO_TIMEOUT)
2019/09/04 21:34:42.77: 9 2: NdpMountResource rc=58
2019/09/04 21:43:58.58: 9 2: NdpMountResource in
2019/09/04 21:43:58.58: 9 2: dircache_create: 10 seconds, 32 entries
2019/09/04 21:43:58.58: 9 2: dircache_create: 0x6d3f20, rc = 0
2019/09/04 21:43:58.58: 9 2: checkMountResource in tid#2
2019/09/04 21:43:58.58: 1 2: Connecting to \\admin:*********@HOME:192.168.1.4\vol1. Master HOME:1
2019/09/04 21:43:58.59: 4 2: Server supports NT1 protocol
2019/09/04 21:43:58.62: 4 2:  session setup ok. Sending tconx <vol1> <********>
2019/09/04 21:43:58.63: 4 2:  tconx ok.
2019/09/04 21:43:58.63: 9 2: NdpMountResource rc=0
2019/09/04 21:43:58.63: 9 2: NdpRsrcQueryInfo in
2019/09/04 21:43:58.63: 9 2: NdpRsrcQueryInfo 0
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo in
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo 0
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo in
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo 0
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo in
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo 0
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo in
2019/09/04 21:43:58.81: 9 1: NdpRsrcQueryInfo 0
2019/09/04 21:44:05.21: 9 2: NdpCreateConnection in
2019/09/04 21:44:05.21: 9 2: NdpCreateConnection send CONNECT
2019/09/04 21:44:05.21: 1 2: Connecting to \\admin:*********@HOME:192.168.1.4\vol1. Master HOME:1
2019/09/04 21:44:05.22: 4 2: Server supports NT1 protocol
2019/09/04 21:44:05.23: 4 2:  session setup ok. Sending tconx <vol1> <********>
2019/09/04 21:44:05.24: 4 2:  tconx ok.
« Last Edit: September 05, 2019, 04:10:57 am by Dariusz Piatkowski »

Paul Smedley

  • Sr. Member
  • ****
  • Thank You
  • -Given: 12
  • -Receive: 54
  • Posts: 474
    • View Profile
Re: Samba - cached server IP address?
« Reply #1 on: September 05, 2019, 05:02:40 am »
Hi Dariusz,

That leads me to believe that the Samba client is maintaining a mapping of the actual IP address the alias was previously pointing to and re-using it instead of querrying it up each time.

I haven't seen this before, but I'm not disputing your results :) There's nothing I've added to do this - my guess would be that in one of the files in %ETC%\samba\* where there are various tdb files that something may be cached there?

Assuming you don't run the Samba server on this machine, you should be pretty safe to remove files from this tree and let the client re-create what it needs to.

Cheers,

Paul.

Doug Bissett

  • Hero Member
  • *****
  • Thank You
  • -Given: 1
  • -Receive: 46
  • Posts: 1251
    • View Profile
Re: Samba - cached server IP address?
« Reply #2 on: September 05, 2019, 08:03:15 pm »
Quote
The question therefore is: does anyone know where that alias to IP address mapping is cached in the Samba configuration?

Depending on settings, C:\MPTN\ETC\samba\lmhosts will do that. It can also import the contents of C:\MPTN\ETC\hosts, sometimes, and that usually doesn't work very well, unless you only use the hosts file for private addresses. I use the hosts file from: https://github.com/StevenBlack/hosts, which blocks reams of advertising (among other things), but every once in a while, I find the contents in C:\MPTN\ETC\samba\lmhosts.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Thank You
  • -Given: 13
  • -Receive: 10
  • Posts: 601
    • View Profile
Re: Samba - cached server IP address?
« Reply #3 on: September 06, 2019, 02:07:20 pm »
Yup, lmhosts is the culprit, both of you were right on the money. Thank you for the great pointer!

Now, how did I get to that point?

Well, I have both NetDrive and EVFSGUI installed here. As it turns out the 'Global settings' tab of EVFSGUI shows 'name resolve order' and has 'Manage LMHosts' checked. Subsequently I find the following in the contents of that file:

Code: [Select]
[G:\mptn\etc\samba]type lmhosts
# Created by EVFSGUI Version 2.5.RC7-[2014-11-14] on 29 May 2019 at 21:33:45
# Syntax:
# IP-address             NetBIOS-name     [Role]
192.168.1.5              NAS
192.168.1.1              ROUTERDLNA
192.168.1.20             WINMAIN

So that explains the root cause. Quick fix here produced the result I was looking for.

Now that begs the question: should I, or shouldn't I be using the LMHosts approach? I suspect that given the description in EVFSGUI of how the lmhosts usually ends up producing a faster resolve time I may have actually chosen to use this approach - as opposed to this being the default setting (although I do not know this to be the case for sure).

Right now the 'name resolve order' is set to: lmhosts => wins => host => bcast

I suspect that given my LAN setups it would just as easily work if I had used: host => lmhosts => bcast => wins.

What the 'wins' option allows me to do is to use the WINS resolution instead, but is that of any use? DNS maps TCP/IP host names to IP addresses through the HOSTS file and WINS maps NetBIOS host names to IP addresses. So in a LAN where I have both Linux and Win servers, does WINS belong?

Dariusz Piatkowski

  • Hero Member
  • *****
  • Thank You
  • -Given: 13
  • -Receive: 10
  • Posts: 601
    • View Profile
Re: Samba - cached server IP address?
« Reply #4 on: September 08, 2019, 11:02:49 pm »