OpenWRT WINS with Samba: Difference between revisions
Line 35: | Line 35: | ||
======Static Mappings for WINS (Static Entries for Host Names and IP Addresses) - Not to be confused with LMHOSTS File====== | ======Static Mappings for WINS (Static Entries for Host Names and IP Addresses) - Not to be confused with LMHOSTS File====== | ||
As with everything in life (and OpenWRT), the solution isn't a simple 1, 2, 3 thing. The first item worth mentioning is that configuring an LMHOSTS file on an OpenWRT router will only work with name resolution queries run from the OpenWRT router. It will not be used when answering WINS queries from clients. | |||
Adding Static Mappings is easy using the below method (and also useless, because the settings will disappear when the router is restarted). It assumes Samba 4 is being used, but will also work with Samba 3 if minor changes are made to the commands; | |||
* Stop the Samba Service (this also stops the NMBD service): service samba4 stop | |||
*Add an entry to the /var/lib/samba/wins.dat file using the following format (see wins.dat format explanation further down) | |||
**"NAME#TYPE" TTL ADDRESS+ FLAGS | |||
*Start the NMBD Service: service samba4 start | |||
A better way to add Static Mappings that persist beyond router restarts is this; | |||
* Create and save a file with entries in the below format in /etc/samba/: nano /etc/samba/samba.static | |||
** "NAME#TYPE" TTL ADDRESS+ FLAGS (see wins.dat format explanation further down) | |||
*Add the below to the OpenWRT Startup Scripts (via LuCI GUI: System, Startup, Local Startup Tab; | |||
'''wins.dat Format Explanation''' | |||
*"NAME#TYPE" TTL ADDRESS+ FLAGS | |||
**NAME = NetBIOS name | |||
**TYPE = NetBIOS Type (00 = Workstation or Domain Name, 01 = Messenger (Workstation), 20 = File Server, etc.) | |||
**TTL = Time To Live in seconds, (Using a time of 0 (zero) ensures the entry will not be deleted by the Samba / NMBD service) | |||
**ADDRESS+ = One, possibly more addresses for the Computer / Entity | |||
**FLAGS = NetBIOS Flags (from The NetBIOS flags may be interpreted as additive hexadecimal values: 00 - Broadcast node registration, 20 - Peer node registration, 40 - Meta node registration, 60 - Hybrid node registration, 02 - Permanent name, 04 - Active name, 80 - Group name. The 'R' indicates this is a registration record. Thus 66R means: Hybrid node active and permanent NetBIOS name. These values may be found in the <code>nameserv.h</code> header file from the Samba source code repository. These are the values for the NB flags. | |||
***64R = Hybrid Node Registration AND Active Name AND registered | |||
*Example: "BUBBA#00" 0 192.168.1.88 64R | |||
The above information was sourced from these websites; | |||
* https://www.linuxtopia.org/online_books/network_administration_guides/samba_reference_guide/17_NetworkBrowsing_23.html | |||
* https://www.techrepublic.com/article/how-netbios-name-resolution-really-works/ | |||
* https://flylib.com/books/en/2.221.1/windows_internet_name_service_wins_.html | |||
* https://www.samba.org/~ab/output/htmldocs/Samba3-HOWTO/NetworkBrowsing.html | |||