Introduction
You can be faced with DNS issues in Home Assistant. Especially, if Home assistant supervised version is installed onto Debian fork (you can find guidance for such installations in the following articles):
The issue is related to improper resolved and NetworkManager configurations.
In this article, you can find how to configure them for HA compatibility.
resolved configuration
Resolved daemon has its own configuration, but NetworkManager overrides this config and configures resolved with its own configuration.
By default, you can find resolved config in NetworkManager with the following path:
/etc/NetworkManager/conf.d/no-systemd-resolved.conf
BTW, you have to create the file if it is absent.
sudo touch /etc/NetworkManager/conf.d/no-systemd-resolved.conf
sudo vi /etc/NetworkManager/conf.d/no-systemd-resolved.conf
Add following configuration (of cause you can replace Google DNS with your own servers):
[main]
systemd-resolved=true
[global-dns-domain-*]
servers=8.8.8.8 8.8.4.4
[Resolve]
DNS=8.8.8.8,8.8.4.4
FallbackDNS=8.8.8.8
DNSStubListener=yes
This config sets up DNS resolving and allows DNS listener 127.0.0.53:53 needed for Home Assistant resolving.
NetworkManager configuration
NetworkManager should be configured to use resolved
sudo vi /etc/NetworkManager/NetworkManager.conf
Add following configuration:
[main]
dns=systemd-resolved
plugins=keyfile
autoconnect-retries-default=0
rc-manager=file
DNSStubListener=yes
[keyfile]
unmanaged-devices=type:bridge;type:tun;driver:veth
[logging]
backend=journal
[connection]
connection.mdns=2
connection.llmnr=2
[connectivity]
uri=http://checkonline.home-assistant.io/online.txt
[device]
wifi.scan-rand-mac-address=no
As can you see Home Assistant adds its own section in the configuration.
The key parameter is: dns=systemd-resolved
Now apply your configuration:
sudo service NetworkManager restart
Check your configuration:
sudo resolvectl status
resolvectl status
Global
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: foreign
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8 8.8.4.4
You will see configurations for all your interfaces, but the Global section is the most important.
Static IP configuration
Also you can configure static IP for your instance if needed:
sudo touch /etc/NetworkManager/system-connections/default
sudo vi /etc/NetworkManager/system-connections/default
Add following configuration:
[connection]
id=Supervisor eth0
uuid="HA adds this parameter by himself"
type=ethernet
interface-name=eth0
llmnr=2
mdns=2
permissions=
[ethernet]
cloned-mac-address=preserve
mac-address-blacklist=
[ipv4]
address1=Your_IP/24,Network Mask
dns=YourDNS;
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
address1=ipv6_address/64
address2=ipv6_address/64
dns-search=
method=manual
As can you see Home Assistant adds its own section in the configuration.
The key parameter is: dns=systemd-resolved
Now apply your configuration:
sudo service NetworkManager restart
Please fill free to ask any questions in comments.