How to install and configure mDNSResponder

Wasn't able to find much info on configuring mDNSResponder. Most posts talk about using Avahi or Netatalk. I was using Avahi on FreeBSD 11 and recently clean installed FreeBSD 12-Release and read somewhere that mDNSResponder is more lightweight (but don't quote me on that :p).

Anyhow, I was able to get it working with the following steps so figured I'd share in case it helps anyone else, too (thanks to the info I found in https://forums.freebsd.org/threads/mdnsresponder-not-running.46659/).

1. Install net/mDNSResponder with pkg:
sudo pkg install mDNSResponder

2. Create an mdnsresponder.conf file:
sudo pico /usr/local/etc/mdnsresponder.conf
For example, to broadcast services for SSH (port 22) and Samba (port 445):
Code:
Server Name
_ssh._tcp. local.
22

Server Name
_smb._tcp. local.
445

3. Add the following to /etc/rc.conf:
sudo pico /etc/rc.conf
Code:
# mDNSResponder
mdnsresponderposix_enable="YES"
mdnsresponderposix_flags="-f /usr/local/etc/mdnsresponder.conf"

4. Start the service:
sudo service mdnsresponderposix start

From a Mac on the network you can then use ssh hostname.local to connect or look for the SMB server in the Finder's sidebar.

If you make any edits to the mdnsresponder.conf file you can restart it to apply the changes:
sudo service mdnsresponderposix restart
 
Last edited:
mdnsresponderposix_enable="YES" enables /usr/local/bin/mDNSResponderPosix. Enabling this as a service and a customized configuration file didn't work well. Starting it as a service claims it enables, but I can't find the process id with ps. (edit - the service command works more consistently, when the corresponding entry is put into rc.conf.local)

mdnsd_enable="YES" starts the service reliably. It starts /usr/local/sbin/mdnsd. The other thread mentions use of this service as well.

dns-sd(8) is an interesting testing utility that lets me load addresses.

dns-sd -R "mycustomname" _http._tcp mycustomdomain.local 80 & sets up a name address.
dns-sd -L "mycustomname" _http._tcp mycustomdomain.local & shows the status and what to type in the address bar.

I've done this, but couldn't get this to happen in my address bar. Maybe another service has to be started there. The next thing could be to adjust /etc/hosts to select an address for .local for IP addresses reserved for local use, from 169.254.1.0 to 169.254.254.255.

/usr/ports/net/mDNSResponder/pkg-plist list of files:
Code:
bin/dns-sd
bin/mDNSClientPosix
bin/mDNSNetMonitor
bin/mDNSProxyResponderPosix
bin/mDNSResponderPosix
include/dns_sd.h
lib/libdns_sd.so
lib/libdns_sd.so.1
sbin/dnsextd
sbin/mdnsd
share/man/man1/dns-sd.1.gz
share/man/man8/dnsextd.8.gz
share/man/man8/mDNSResponderPosix.8.gz
share/man/man8/mdnsd.8.gz
Not shown here, /usr/local/etc/rc.d/ has the services that come with this port: mdnsd and mdnsresponderposix. ( pkg which mdnsd)

I'm trying to set up a Zeroconf implementation, so I can understand enough about how it works.
 
sidetone, whether you use mdnsresponderposix or mdnsd depends on what you want/need.

For a server system we usually want our system advertise only services, which are personally hand selected and authorized by the server admin. This means we want to configure this manually by the way of a configuration file. For this use case, mdnsresponderposix is the ideal tool. We try hard to disable all automatic advertisements by for example net/avahi or dns/mdnsd. If we don’t take care, Avahi is dragged-in and activated by a number of ports, some (in)famous ones are net/netatalk3 and net/samba4xx. Note also that the other mdnsd-port is a separate animal, and has nothing to do with net/mDNSResponder.

For a server we usually also do not want, that it resolves .local addresses which are advertised by other services on other systems in our LAN. This might become a security nightmare. Therefore, on a server we do not want mdnsd, since this sets up an automatic responder and an automatic resolver as well. This is basically the use case for a client system.
 
In my experience
Code:
netatalk_enable="YES"
mdnsresponderposix_enable="YES"
mdnsresponderposix_flags="-n $hostname"
In /etc/rc.conf is all you need to run Netatalk. No need to write a Mdnsresponder config file. Unfortunately, that nice little program from Apple is documented very, very poorly in its man page. I was forced to inspect the source to figure out what command-line arguments it accepts:
 
Back
Top