When integrating Linux Samba servers with macOS environments, traditional network discovery methods often fall short of Apple's native user experience expectations. Bonjour (Apple's implementation of Zeroconf) provides automatic service discovery without manual configuration.
Before implementation, ensure your Debian system has:
- Samba 4.9+ (supports built-in mDNS publishing)
- Avahi-daemon (the Linux Zeroconf implementation)
- Properly configured firewall (UDP port 5353 open)
1. Install Required Packages
sudo apt update
sudo apt install samba avahi-daemon libnss-mdns
2. Configure Samba for mDNS Announcement
Edit your smb.conf (typically at /etc/samba/smb.conf) and add these parameters in the [global] section:
[global]
server min protocol = SMB2
server max protocol = SMB3
mDNS name = register
multicast dns register = yes
3. Avahi Service Configuration
Create a new service file at /etc/avahi/services/samba.service:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h SMB</name>
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>
Multiple Share Announcements
For announcing specific shares with friendly names:
<service-group>
<name>Marketing Files</name>
<service>
<type>_smb._tcp</type>
<port>445</port>
<txt-record>path=/shares/marketing</txt-record>
</service>
</service-group>
After restarting both services (sudo systemctl restart smbd nmbd avahi-daemon
), verify with:
avahi-browse -a -t
Common issues and fixes:
- If services don't appear, check firewall:
sudo ufw allow 5353/udp
- For name conflicts, set
netbios name
in smb.conf - Increase logging with
log level = 3 mdns:5
in smb.conf
For environments where Avahi isn't preferred, consider wsdd (Web Services Discovery Daemon):
sudo apt install wsdd
sudo systemctl enable --now wsdd
While Samba works perfectly for file sharing between Linux and macOS systems, native Bonjour (mDNS) discovery would significantly improve the user experience for Mac clients. Unlike Windows networks that use NetBIOS, macOS prefers zero-configuration networking through multicast DNS.
We'll need these packages on Debian:
sudo apt update
sudo apt install -y avahi-daemon libnss-mdns samba
Create a new service definition file:
sudo nano /etc/avahi/services/samba.service
Add this XML configuration (adjust for your setup):
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h SMB</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>
Ensure your smb.conf
has these parameters:
[global]
server string = %h server (Samba %v)
netbios name = FILESERVER
workgroup = WORKGROUP
wins support = yes
local master = yes
preferred master = yes
os level = 35
[shared]
path = /srv/samba/shared
browsable = yes
read only = no
guest ok = yes
force user = nobody
Restart services and check status:
sudo systemctl restart avahi-daemon smbd nmbd
sudo systemctl enable avahi-daemon
avahi-browse -a -t
On macOS terminal, verify discovery works:
dns-sd -B _smb._tcp
For better identification in Finder's Network view, add these TXT records:
<txt-record>sys=waMa=0,adVF=0x100</txt-record>
<txt-record>dk0=adVF=0x100,adVU=0xffff</txt-record>
<txt-record>machine=Macmini7,1</txt-record>
If services don't appear:
- Check firewall rules for mDNS (UDP 5353) and SMB ports
- Verify multicast is enabled on your network
- Inspect logs with
journalctl -u avahi-daemon -f
For persistent hostname issues, set in /etc/avahi/avahi-daemon.conf
:
[server]
host-name=fileserver
use-ipv4=yes
use-ipv6=yes
enable-dbus=yes