# How to make mDNSResponder to resolve local domain names?



## eonil (Oct 14, 2013)

I installed mDNSResponder from port.


```
cd /usr/ports
portmaster net/mDNSResponder
echo 'mdnsd_enable="YES"' >> /etc/rc.conf
service mdnsd restart
```

After that, I modified /etc/nsswitch.conf to add mdns to host: entry.

It works well. My OSX box can find FreeBSD box via name. But, FreeBSD box cannot find OSX box with name. It also cannot find other FreeBSD box too. I think there's some problem on resolving name to IP address feature.



```
root@freebsd9:~ # mDNSIdentify freebsd9.local
freebsd9.local. Addr 192.168.0.105
freebsd9.local has no HINFO record
mDNS_PurgeCacheResourceRecord: Lock not held! mDNS_busy (0) mDNS_reentrancy (0)
mDNS_PurgeCacheResourceRecord: Lock not held! mDNS_busy (0) mDNS_reentrancy (0)

^Croot@freebsd9:~ # curl http://freebsd9.local
root@freebsd9:~ # curl http://freebsd9.local
curl: (6) Could not resolve host: freebsd9.local
root@freebsd9:~ # curl http://freebsd9.local
root@freebsd9:~ # curl http://freebsd9.local
root@freebsd9:~ # curl http://freebsd9.local
root@freebsd9:~ # curl http://localhost
curl: (7) Failed connect to localhost:80; Connection refused
root@freebsd9:~ #
```


So, name advertising is working well, but name resolution doesn't work. 
How can make it to work?


----------



## kpa (Oct 14, 2013)

Do you have dns/nss_mdns installed? Also is the line in your /etc/nsswitch.conf something like this:


```
hosts: files mdns_minimal [NOTFOUND=return] dns mdns
```


----------



## eonil (Oct 17, 2013)

That solved the issue. Thanks.

Anyway, nss_mdns has a hard dependency on Avahi, so it installs Avahi. I chose mDNSResponder to avoid the heavy dependencies of Avahi, so actually this avoids my intention 

So I decided just to go Avahi.


----------



## Mazhe (Nov 5, 2013)

I have written a port for the NSS module in mDNSResponder:
http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/178052

Feel free to test it and back up my request 

(PS. I can't make the 5xx net/mDNSResponder version work, I'll update the NSS module after resolving that problem, but it should be ok just to bump version in the Makefile)


----------



## eonil (Nov 6, 2013)

Oh looks nice.

Anyway, I am not currently on the mDNS stuff, so currently I can't test it.
But if I get another chance I will try it.

Thanks for information.


----------



## kpa (Nov 11, 2013)

@Mazhe, you have to support staging in your new port to have it accepted to the ports tree, the attached patch should do the job. It modifies the Makefile and the pkg-plist files.


----------



## Mazhe (Nov 14, 2013)

kpa said:
			
		

> @Mazhe, you have to support staging in your new port to have it accepted to the ports tree, the attached patch should do the job. It modifies the Makefile and the pkg-plist files.



Thanks, people wanting to try the last version can do so: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/178052&getpatch=4

But yet there's a problem inside of mDNSResponder which makes every query answer be 0.0.0.0 or ::0 (when network frames seems to be OK). It is even not FreeBSD-specific as it happens under also under GNU/Linux, so...


----------

