Samba – SMB browsing elections wars

I while ago I posted a page about Kodi and SMB. Read about it here. My goal than was to disable SMBv1 and ban it from my network.

Today I did a new installation of my Chromebook (with Chromebook Unix on the side). I noticed I couldn’t browse with the file manager from my distro and after editing the samba configuration file to bumb the client max protocol to level 3 it still wouldn’t work.

Having multiple looks at my smb.conf file and restarting the service multiple times after uncommenting some settings I had no clou what was going on. Samba can be a handfull but has an overwhelming documentation library. Reading Chapter 7. Name Resolution and Browsing pointed my in the right direction to solve this.

Name Resolution

The first thing I saw was the section about name resolution. My freshly installed smb.conf did not have a name resolver order section defined so it should use the defaults defined in the software.

The default name resolve order is:

[global]
name resolve order = wins lmhosts hosts bcast

I can’t explain why wins is still being used (and preferred). I vaguely can remember working with WINS (Windows Internet Name Service) on NT 4.0 but I have no idea why this still exists today if we made the transition to DNS two decades ago. I’ve never used a lmhosts file and I don’t actively manage the host file 😉

This name resolve order is sufficient for my situation:

[global]
name resolve order = bcast hosts

After pushing the broadcast methode as the first option and restarting the smbd and nmbd I still couldn’t browse.

Browser elections

The following section in the Samba documentation was browser election. On Windows you can use nbtstat to show information about a network client that is possibly the master browser.

The bad news is you have to use two tools to find the master browser on Windows. As far as I know there is no all-in-one tool from Microsoft that works on recent operating systems. For the first part of the quest for the master browser you should use net view to populate all the network computers. The second part is to scan that all those remote computers with nbtstat -a %name% and look for a line with __MSBROWSE__ in the table returned within nbtstat.

You can imaging that nobody is happy doing this if your network consists of more than 2 computers. To automate this you can use the following command line:

FOR /F "tokens=* delims= " %I in ('NET VIEW ^| FIND "\\"') DO NBTSTAT -a %I | FIND "_MSBROWSE_"

And now the disappointing part… I bet your net view list returned empty or broken (possibly because that’s the whole reason you dived into this command) and is no good to locate your master browser…

Thankfully the samba counterpart for Linux is not the same. On Linux you can use nmblookup. To scan for your master browser on your workgroup use:

nmblookup -M YOURWORKGROUPNAME

On my Chromebook this resulted in:

$ nmblookup -M mshome
172.16.1.202 mshome<1d>

! that’s my Kodi MySQL machine and not supposed to be a some networking boss. This machine is based on a Ubuntu Server LTS network install looking at the smb.conf file there was a small difference with the one on my laptop. The smb.conf contained the following added lines:

;preferred master = no
;domain master = no

Maybe I made these while fiddling with Samba but this machine should not be a domain master so I removed the semicolons in front of these two lines, saved it and restarted smbd on that host.

note SMB v1 was already disabled on this machine by raising the min protocol for server and client.

Running the lookup command again after a few seconds have passed on my laptop the IP changed to a more familiar IP. After this the file manager on my laptop was able to list the workgroup name and computers with shares.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s