OpenWRT WINS with Samba

Invaluable Information from here: https://www.samba.org/samba/docs/using_samba/ch07.html (NOTE: This entire page is marked as "this is old information and might be incorrect", however, WINS is old too, and as it turns out, all of the information in regards to WINS is still accurate)

Samba Related Information


Samba Information

OpenWRT Samba is configured to look for the lmhosts file (all lower case) here: /etc/samba/lmhosts (it was verified by looking in the log files for where it loads the file)

To configure logging, add the following directives (minus comments) to the /etc/samba/smb.conf file in the [glolbal] section;

# The below is the default location
log file = /tmp/log/samba/samba.log
log level = 3
# Per log file, the below has been deprecated
# syslog = 1

Information from above was referenced from here: https://wiki.samba.org/index.php/Configuring_Logging_on_a_Samba_Server

Top Tips

Do NOT set the log level higher than 3 or it will just fill up with gibberish

Do NOT attempt to read the log file via a text editor through a Samba shared directory, or the log file will fill with recursive gibberish (IE, use nano or vi)

Best to not use these directives; client min protocol = SMB2, client max protocol = SMB3 (If SMB1 or SMB2 are needed, switch to Samba 3)

When configuring the Hostname in the LuCI GUI, System, System, General Settings Tab, use ONLY the host name, not the "fully qualified host name" (IE use OpenWRT, do not use OpenWRT.WhatEverDomain.WhatEverComOrLocalOrLanEtc)

Commands Related to WINS for Samba

nmblookup is the command that can be used to check information within the Samba WINS database.

Examples;

  • nmblookup WhatEverNameOfHost will display the IP Address information for that host.
  • nmblookup -S WhatEverWorkGroupName will display all the records*

* This webpage notes that there are various ways to display all of the records: https://superuser.com/questions/1492010/finding-all-samba-shares-in-local-network

Static WINS Entries (not to be confused with LMHOSTS File)

First things first: The LMHOSTS file is used only the local computer / server (IE, the OpenWRT / LinkSys device that is acting as the WINS / NMBD (The component of Samba that equates to WINS) Server). The LMHOSTS File and its entries are not used in resolving names to IP Addresses for clients of the WINS Server. That duty is held by two files: wins.dat and browse.dat. And no one seems to want anyone to find those files (IE, I dare anyone to find documentation, besides here that notes the location of both of these files.

/tmp/lib/samba/wins.dat (AKA /var/lib/samba/wins.dat)

/tmp/cache/samba/browse.dat (AKA /var/cache/samba/browse.dat)

Here's an interesting statement about the wins.dat file from https://wiki.rockstable.it/Samba: "On Samba the dynamically maintained database is stored persistently across reboots in /var/lib/samba/wins.dat, which is written in regular intervals." Keep in mind this was not written about OpenWRT. Does that make a difference? Yes it does. Look at the path OpenWRT stores the wins.dat file (Hint: It begins with /tmp, which means it does not persist across reboots). Is this compensated for with something in the /etc/init.d/samba4 configuration file? Nope. In the /etc/config/samba4 settings? Nope. Solution? Make one up.

In OpenWRT, is it possible to put manual entries in the /var/lib/samba/wins.dat file? Yes. Will the entry exist for more than about 30 seconds? No. So putting static entries into the wins.dat file is pointless. That's for the NMBD Service which responds to broadcast requests for a NetBIOS name.

The format of entries in the /var/lib/samba/wins.dat file are from here: https://www.linuxtopia.org/online_books/network_administration_guides/samba_reference_guide/17_NetworkBrowsing_23.html

  • "NAME#TYPE" TTL ADDRESS+ FLAGS
    • NAME = NetBIOS name
    • TYPE = NetBIOS type
    • TTL = Time To Live (in seconds)
    • ADDRESS+ = One, possibly more addresses for the Computer / Entity
    • FLAGS = NetBIOS
Recommendation for Windows Hosts that are Multihomed (IE, have more than one network interface)

For some odd reason, if only one interface is configured with WINS server information, it reports the IP Address of all the network interfaces on the Windows machine to the WINS Server. IE, all the other network interfaces can have a blank / empty entry for WINS server, but that one network interface configured with a WINS server will report all of the IP Addresses associated with all of the other network interface. To prevent this, configure a different WINS server for each interface OR "Disable NetBIOS over TCP/IP" (oddly, this does not disable the ability of one to access shared folders, incoming or outgoing, on the network interface in question as it seems NetBEUI is the acronym that encompasses that functionality). This even includes PPTP VPN Connections and probably OpenVPN connections too.

Deprecated Configuration Directives from Samba3 to Samba4

There are several configuration directives that have been removed / deprecated from Samba 4. They include "announce as", "announce version", along with some others.

Other Information
  • If there is no Windows Domain Controller within a subnet, the following configuration is recommended for the /etc/dhcpd;
# This configures Samba to enable WINS support
wins support = yes
# The following settings will make the WINS functionality of Samba the main "Browser" for a subnet
# If using with a Windows Domain infrastructure, probably best to research a bit more before doing the following;
local master = yes
os level = 255
preferred master = yes
domain master = yes
  • The netbios name = |NAME| directive in Services, Network Share, Edit Template Tab in the OpenWRT GUI configures SAMBA with the name defined in the System, System, Hostname Field.

Remaining Items to Document