Resolving .local domains on Linux

I recently started working for a big firm, which (naturally) uses Active Directory. The domain is company.local , with useful servers all having the addresses server.local etc. To my surprise, Linux didn't ask for DNS resolution on these names, making it very hard to work. Thankfully, that's simple to resolve.

To culprit is in the order in which Linux checks how to resolve domain names. Specifically (after some digging about) it seems that .local is registered as an mDNS suffix ( Wiki ), which in Linux has greater precedence than querying DNS.

The way to change that order is to edit the /etc/nsswitch.conf file with your favourite editor. Eg, in Ubuntu:

user@dev:~$ sudo nano /etc/nsswitch.conf

In there, you need to locate the hosts entry, and make sure dns happens before mdns. In my case, the original line was

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

and was changed to

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

in order to make it work as expected. Just save and it should not be working!