roht.no: on.thor

Projects, articles, notes and other technical musings from a DevOps focused developer

Resolving issues with .local networks on CentOS 7 (or any system with Avahi)

Thor K. Høgås

⏱ 3 minutes read. 📅 Published . ✎ Last updated .

Local networks, be it private or small business networks, have for a long time adored the .local suffix. Partially, thanks to Microsoft and their former of this sort of usage.

Usually, this isn’t something that causes much issues, but besides being a bad idea in the first place, you might be so lucky as to incur issues if you mix and match this with most Linux distributions including Avahi.

The sort of issue I’ve most frequently come across–although never frequently enough to remember it when it happens again–is how nsswitch.conf is set to mDNS at a higher priority than resolv.conf. Inevitably this means that lookups on the local network in the shape of some-host or my-computer all work fine, but the moment you try to lookup some-host.my-domain.local things do not work anymore.

The Solution

You’ve got mainly three options. They’re ranged in the order of sensible solutions, not in the order of least effort.

  1. Use a different domain name.
  2. Change the multicast domain suffix for Avahi in avahi-daemon.conf.
  3. Remove mDNS from your nsswitch.conf.

Using a different domain name

You should not use .local. However, we live in the realm of reality, and whether or not alternative facts are a real thing (they’re not), you are going to have a hard time convincing your colleagues to change the domain network purely for this reason.

Ideally, you should do it for all the other reasons as well, but this is the solution you go to in the long run. You don’t change the domain just to fix host resolving on a subset of the machines, simply because you don’t want to edit avahi-daemon.conf.

Nevertheless, if the network’s all yours, it’s the ideal solution. Use something else. Preferably, use something which you actually control — don’t go with a domain name that isn’t yours. Whether your network is airgapped or not, you’re going to have a bad time either way when there are faulty DNS configurations, or if your network is breached.

Editing Avahi’s daemon to use a different multicast domain suffix

This is–what I believe–is the ideal workaround. I say workaround because the first suggestion is a true solution, whereas this incurs some configuration cost on all devices with Avahi. Either way, you won’t create any other particular disadvantages—in part because you doubtfully use much of Avahi anyway—if you make sure to set it to a consistent alternative.

Open up the file and make a modification in the server section, i.e. in [server]:

domain-name=.alocal

The value might already be #domain-name=local, which is a bit misleading seeing as the default value is actually .local, not local. You can change it to anything you’d like, besides .local.

Remove mDNS from nsswitch.conf

Don’t do this. Sure, you can, but there are applications depending on it, such as Google’s Chromecast, and surely you do not want to mess that up for no good reason.

Seeing as I don’t recommend doing this, although it’ll work around the issue, I’m not going to go into detail on how to do it. Needless to say, however, the cat’s already out of the bag, if you know how to edit files.