ROOter/OpenWRT Samba Cross-Platform Setup with a WINS Server
Posted: Mon Apr 13, 2020 8:13 pm
I posted this on the ROOter forum too, but given the single thread nature there, tutorials tend to get lost in the clutter. So, starting with this post -- I'm going to post guides here too for some additional staying power.
If your network consists of a mix of different operating systems, and includes Windows, you've probably done battle with Samba at one time or another. Left to its own devices Samba is a discovery protocol, which in a mixed OS environment means frequent re-scanning of the LAN when using a file explorer to see your shares.
Making your ROOter, or other OpenWRT-based router, a WINS server significantly speeds up that process. It's easy to do with ROOter, and I'm happy with the results on my network, so thought I'd share the specifics here.
ROOter already comes with Samba installed (except on older memory-limited units), so that part is covered. My primary router is OpenMPTCProuter based, so I needed to install samba36-server and luci-app-samba:
Next order of business is to make your router a WINS server, so that it'll keep track of all available Samba shares — rather than relying on exclusively on discovery. You'll need to add the following to the [Global] section of the smb.conf file. This can be done through the LuCI GUI by navigating to Services – Network Shares – Samba – Edit Template, and adding the following lines to the end of the [global] section:
You'll also need to comment out the "local master = no" that you'll see earlier in the config by putting a "#" in front of it. The end result should look like this:
Save your changes and head on over to Network – Interfaces – LAN – Edit – DHCP Server – Advanced Settings – DHCP Options to setup advertising of your new WINS server to clients on the LAN.
If you'd like to off-load DNS duties from your router, this is also the place to advertise the DNS servers you'd like your LAN clients to use rather than having DNS queries sent to your primary router to be relayed elsewhere. I'm using an on-LAN Pi-hole server, so I've already been advertising its address to my LAN clients when they get their DHCP address. Now, they'll get the IP of the WINS server at that time too:
Under DHCP-Options, use this structure to advertise your WINS server:
and if you'd like to start advertising a Pi-hole server, or other DNS servers, add a line like this:
The end result looks like this in OMR, and very similar in ROOter:
The surest way of having these changes take effect immediately is to do a network-wide reboot, by first powering everything down. And then, by bringing your router back online first, followed by your DNS server (if you're using Pi-hole) and then everything else based on other dependencies that are specific to your setup.
Opening Windows Explorer, you should notice a significant speed increase, when clicking on the Network section, for Samba shares to appear:
If you have other problems with Samba, I'd recommend fixing them first before adding a WINS server. There's a Samba scanning tool available as part of the NetScanTools Demo package which will help you identify issues related to what versions of Samba are supported on each of your samba shares. As you can see in the attached, every system on my LAN supports Samba v2.02, giving me a common protocol:
https://www.netscantools.com/
If your network consists of a mix of different operating systems, and includes Windows, you've probably done battle with Samba at one time or another. Left to its own devices Samba is a discovery protocol, which in a mixed OS environment means frequent re-scanning of the LAN when using a file explorer to see your shares.
Making your ROOter, or other OpenWRT-based router, a WINS server significantly speeds up that process. It's easy to do with ROOter, and I'm happy with the results on my network, so thought I'd share the specifics here.
ROOter already comes with Samba installed (except on older memory-limited units), so that part is covered. My primary router is OpenMPTCProuter based, so I needed to install samba36-server and luci-app-samba:
Next order of business is to make your router a WINS server, so that it'll keep track of all available Samba shares — rather than relying on exclusively on discovery. You'll need to add the following to the [Global] section of the smb.conf file. This can be done through the LuCI GUI by navigating to Services – Network Shares – Samba – Edit Template, and adding the following lines to the end of the [global] section:
Code: Select all
domain master = yes
local master = yes
name resolve order = wins lmhosts hosts bcast
os level = 99
preferred master = yes
wins support = yes
Code: Select all
[global]
netbios name = |NAME|
display charset = |CHARSET|
interfaces = |INTERFACES|
server string = |DESCRIPTION|
unix charset = |CHARSET|
workgroup = |WORKGROUP|
bind interfaces only = yes
deadtime = 30
enable core files = no
invalid users = root
# local master = no
map to guest = Bad User
max protocol = SMB2
min receivefile size = 16384
null passwords = yes
passdb backend = smbpasswd
security = user
smb passwd file = /etc/samba/smbpasswd
use sendfile = yes
# OpenWRT Samba User Guide WINS Settings
domain master = yes
local master = yes
name resolve order = wins lmhosts hosts bcast
os level = 99
preferred master = yes
wins support = yes
If you'd like to off-load DNS duties from your router, this is also the place to advertise the DNS servers you'd like your LAN clients to use rather than having DNS queries sent to your primary router to be relayed elsewhere. I'm using an on-LAN Pi-hole server, so I've already been advertising its address to my LAN clients when they get their DHCP address. Now, they'll get the IP of the WINS server at that time too:
Under DHCP-Options, use this structure to advertise your WINS server:
Code: Select all
44,[IP of your WINS server here]
Code: Select all
6,[IP of your primary DNS server here],[IP of your secondary (backup) DNS server here]
The surest way of having these changes take effect immediately is to do a network-wide reboot, by first powering everything down. And then, by bringing your router back online first, followed by your DNS server (if you're using Pi-hole) and then everything else based on other dependencies that are specific to your setup.
Opening Windows Explorer, you should notice a significant speed increase, when clicking on the Network section, for Samba shares to appear:
If you have other problems with Samba, I'd recommend fixing them first before adding a WINS server. There's a Samba scanning tool available as part of the NetScanTools Demo package which will help you identify issues related to what versions of Samba are supported on each of your samba shares. As you can see in the attached, every system on my LAN supports Samba v2.02, giving me a common protocol:
https://www.netscantools.com/