File server on Samba, visible from everywhere

In this short note, I will not touch on Samba configuration, since there is more than enough such materials on the network.



I would like to talk about how to make access to the file server more convenient.







TL; DR: Configuring Avahi and WSD to show the file server in Network Neighborhood on Windows, MacOS, and Ubuntu (and other distributions, of course, but I haven't tested them).



So let's start with Windows.



In time immemorial, when the list of computers in a networked environment was formed by broadcasts via NetBIOS, everything was simple.



We prescribed in smb.confsomething like local master = yesand were happy.



Those times are gone forever and today, in order for our file server to be displayed in the user's network environment, you need to either carry out manual therapy of the registry on each computer, connecting back the outdated and insecure SMBv1, or accept that the world has changed and start using the WS-Discovery recommended by Microsoft (WSD).



Why did Microsoft decide to use it, and not mDNS, which appeared earlier and is used in MacOS and Linux (aka Bonjour, aka Avahi)?



Well ... It's Microsoft.



So what do we need to get WSD to work?



Not so much - add a repository, install the WSD daemon, make settings in the configuration, restart the service and, in fact, that's it.



apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4BBAE4C69C568C54
echo "deb https://pkg.ltec.ch/public/ $(grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2) main" | tee /etc/apt/sources.list.d/wsdd.list
apt install wsdd


Now let's change it a little. /etc/wsdd.conf

My configuration line looks like this:



WSDD_PARAMS="--shortlog --interface enp3s0 --hostname server --workgroup HOME"


I guess the parameters speak for themselves, just note that if you are using Samba in domain controller mode, you --workgroupshould use --domain.



Well, I recommend that you look into man wsdd, as well as into the wsdd repository (there are also instructions for distributions other than Debian / Ubuntu)



Let's finish everything by restarting the service:



systemctl restart wsdd.service


and checking on some of the Windows computers from Vista and older that our server appeared in a networked environment.



Now it's time for Avahi. After configuring it, our file server will begin to display in Network Neighborhood in MacOS and Ubuntu.



First, make sure avahi is installed:



apt install avahi-daemon avahi-utils


Now we announce our server through it:



nano /etc/avahi/services/smb.service

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">%h</name>
 <service>
   <type>_smb._tcp</type>
   <port>445</port>
 </service>
 <service>
   <type>_device-info._tcp</type>
   <port>0</port>
   <txt-record>model=RackMac</txt-record>
 </service>
</service-group>


You can also look into /etc/avahi/avahi-daemon.confand, for example, limit the broadcast to one interface, but that's up to you.



Let's finish everything by restarting the service:



systemctl restart avahi-daemon.service


Separately, I will mention that in this way you can announce not only Samba, but also many other services (the list is here ).



I hope this post will save you time and add convenience to your users.



All Articles