How to make .local domain work on local Ubuntu Server

The real issue is that Ubuntu 18.04 has its resolv.conf sym-linked to a stub file that points to the localhost for name resolution. Localhost DNS name resolution means that the system refuses to check the supplied DNS server for .local names, believing (incorrectly) that such names are invalid. This is the default setup of /etc/resolv.conf:

ls -la /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Jan 22 13:26 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

content of the stub file is (comments removed):

cat /run/systemd/resolve/stub-resolv.conf
 .. removed comments..  

the 'real' resolve conf has the 'correct' DNS setting (from DHCP):

cat /run/systemd/resolve/resolv.conf
..removed comments..
nameserver # This is my server that can resolve .local
nameserver # these are optional, fallback DNS servers
# Too many DNS servers configured, the following entries may be ignored.

In order to make the system use your preferred DNS resolver instead of localhost, you change the symlink to point to /run/systemd/resolve/resolv.conf instead of /run/systemd/resolve/stub-resolv.conf :

sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Immediately after this, resolution of .local started working. No need to reboot or restart any service.

Source: Ask Ubuntu forum

Last update: Fri, 18 Sep 2020 10:57:46