Name resolution problem since 0.97.2

If you’re running hassio you have the command if you install the community ssh addon. I added my local router to dns and it resolves local network devices.

I’m running hassio in containers, I don’t have a hassio command… not in the host, not in the homeassistant container, not in the hassio-supervisor, not in hassio-dns…

g@h:/usr/share/hassio/homeassistant$ docker ps
CONTAINER ID        IMAGE                                           COMMAND                  CREATED             STATUS              PORTS               NAMES
f1cff7445a5f        homeassistant/qemux86-64-homeassistant:0.98.2   "/bin/entry.sh pytho…"   9 hours ago         Up 8 hours                              homeassistant
4374aa0705ef        homeassistant/amd64-addon-duckdns:1.10          "/run.sh"                10 hours ago        Up 10 hours                             addon_core_duckdns
057584be9b07        homeassistant/amd64-hassio-supervisor           "/bin/entry.sh pytho…"   43 hours ago        Up 8 hours                              hassio_supervisor
eecd515ed772        sketchup                                        "/usr/local/bin/run-…"   3 days ago          Up 3 days                               hardcore_napier
8c51feebc8aa        hassioaddons/log-viewer-amd64:0.6.3             "/init"                  5 days ago          Up 5 days                               addon_a0d7b954_logviewer
b1118968e9ad        hassioaddons/vscode-amd64:0.6.5                 "/init"                  5 days ago          Up 5 days                               addon_a0d7b954_vscode
195bdf99551e        homeassistant/amd64-hassio-dns:1                "coredns -conf /conf…"   5 days ago          Up 8 hours                              hassio_dns
g@h:/usr/share/hassio/homeassistant$ hassio
hassio: command not found
g@h:/usr/share/hassio/homeassistant$ docker exec -it homeassistant bash
bash-5.0# hassio
bash: hassio: command not found
bash-5.0# exit
g@h:/usr/share/hassio/homeassistant$ docker exec -it hassio_supervisor bash
bash-5.0# hassio
bash: hassio: command not found
bash-5.0# exit
...

Where does it reside?

Forget the hack I wrote above…

Making the following command (which must run each time the container starts) into a persistent change is the correct way to resolve this issue:

 docker exec -it homeassistant bash -c 'echo "options ndots:0" >> /etc/resolv.conf'

That tells dns to search names that are lacking “.” locally before forwarding to outside DNS.

I take it these errors are also related:

9-09-06 10:37:41 ERROR (MainThread) [hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].
19-09-06 10:37:41 INFO (MainThread) [hassio.api.proxy] Home Assistant WebSocket API request initialize
19-09-06 10:37:41 INFO (MainThread) [hassio.api.proxy] WebSocket access from a0d7b954_appdaemon3
19-09-06 10:37:41 ERROR (MainThread) [hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].
19-09-06 10:37:46 INFO (MainThread) [hassio.api.proxy] Home Assistant WebSocket API request initialize
19-09-06 10:37:46 INFO (MainThread) [hassio.api.proxy] WebSocket access from a0d7b954_nodered
19-09-06 10:37:46 ERROR (MainThread) [hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].
19-09-06 10:37:46 INFO (MainThread) [hassio.api.proxy] Home Assistant WebSocket API request initialize
19-09-06 10:37:46 INFO (MainThread) [hassio.api.proxy] WebSocket access from a0d7b954_appdaemon3
19-09-06 10:37:46 ERROR (MainThread) [hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].

all addons work for me, except mariadb.

I didn’t see any DNS errors there.

Thanks. Sorry if I was a bit harsh on my initial post, but to be fair [my opinion is] that it is a little crazy one has to

a) somehow learn that a third-party plugin is required to have the tools necessary to change DNS settings, considering it is not documented anywhere that I could find (sans a few obscure forum posts)

b) actually install and configure that plugin

c) finally get it working and have the ability to update DNS.

I’m not a dev, so all I can do is comment on what the end-user experience is like.

Please note: I am not trying to be negative; I want Home Assistant to be awesome (because it already is - I’m just getting started and WOW this is neat!)

So in case someone comes looking via a search engine: If you have a Hass instance and need to set your own DNS resolver, first install the “SSH & Web Terminal” third-party add-on (this gives you the hassio command that is necessary in the next step), configure it and get it working, then run the command hassio dns options --servers dns://IP_ADDRESS

Cheers!

1 Like

You could also use the core ssh addon… so not 3rd party. You can’t even bring up a terminal unless you install ssh.

But that’s not so different to anything else in Home Assistant is it? Adding integrations, adding custom components adding addons - all provide different functionality.

I believe the dns container was introduced to fix a lot of DNS problems people seem to have previously. Yes it was a poor initial implementation - but they didn’t expect that to happen and when it did cause issues they moved pretty quickly to fix it.

On my system I have not needed to add my own DNS to the dns options since they fixed it and I suspect most people won’t. Perhaps even you don’t. I did find after changing the DNS that it takes time for everything to start working properly again.

Anyway glad you sorted it out!

JUst ran into same issue … dns issue aftter auto upgrade supervisor to 187 … downgrading fails the way that the supervisor will be updated automatically each time on reboot or in running instance
I run hassio on intel-nuc …Docker… any ideas how to solve this again ?? Took me hours to setup hass and then this… ugly … :confused:

Mine resolves fine locally but just went down externally. :frowning:

I am going through a proxy not sure what this dns container is trying to do.

I too am really confused how the SSH addon is any different then me going into the bash of the container and running the command manually. Does the addon actually apt-get and install the command package?

Hi, Y’all, I’ve been running into DNS floods/race conditions too, on 2 different installs of home assistant, in docker, on Raspberry Pi. (2 different locations too)

What I found out, is the following:

Race conditions:
Config on the the raspberry pi:
Running PiHole, or dnsmasq, or even unbound on the pi itself as resolver:

/etc/resolv.conf contains:

nameserver 127.0.0.1 
search local.domain local2.domain

Nothing in /etc/docker/daemon.json

This creates a “corefile” in hassio_dns docker, where the first dns server is 127.0.0.1. This ends up in DNS race conditions, with thousands of resolving requests to the second, and even third DNS servers in /config/corefile.

Stopping Race Conditions:
Change the resolv.conf on the raspberry pi where you change the nameserver address and remove the search line:

nameserver 192.168.1.10 # use your eth0 ip adres for this
nameserver 8.8.8.8 # use whatever you like? or remove this entirely if your local resolver takes care of it.

Optional* add the info needed into /etc/docker/daemon.json:

{
    "dns": ["192.168.1.10", "8.8.8.8", "8.8.4.4"]
}

Restart the whole shebang! Now the DNS race is over.

I guess that the following is happening:

  1. hassio_dns reads /etc/resolv.conf to use the nameservers included there and puts that info into the /config/corefile.
  2. hassio_dns then tries to resolve names by contacting 127.0.0.1, fails and starts to question dns server 2.
  3. the search line is probably also confusing to corefile, because resolved hosts, that are within this search domain, will only be presented with the hostname, and not the fqdn, and therefor confuse corefile, making another request. This all ending up in a race condition.

By removing the search domain(s), and pointing to the “external” ip of the Pi, I resolved this issue. Ergo, corefile inherited the 127.0.0.1 from the /etc/resolv.conf on the Pi, which by itself could already cause issues. And the search domain(s) also cause issues.

I hope that this 5 cents shines some light on issues that some people are having with DNS, Home Assistant in Docker on Raspberry Pi.

  • Optional: Not sure if this is really needed

I’ve added a new DNS server to my hassio which now points to my local dnsmasq server. The dnsmasq server is running on my router. I used the commands suggested via hassio dns options --servers dns://MY-ROUTER-IP and then hassio dns restart. However when I try and ping a local host such as hostname.lan or hostname.local I’m still getting Name or service not known. However when ping the IP address I get a response.

hassio dns info shows that my router / dnsmasq server is has been added to the section under server

Have I set this up incorrectly?

Hello Everyone!

I have a simple problem since this morning when I restarted my server : the DNS service is taking 200% CPU constantly. I am running the latest hassio on RPI4. Everything was great so far and I can’t understand what I changed to make this wrong. I tried updating the DNS server to no avail… Logs are all OK. Where should I try to check for where my issue is?

Edit : I thought I found the issue to be the Spotify platform integration. I removed it and everything was back to normal… until it came back again. Now it seems intermittent. I don’t quite understand how to debug the source of the issue… I spent quite a bit of time trying to debug now, even restarting the whole config from scratch and it seems I can’t get anywhere. What I observe is that even with a clean config, latest image pulled from here (RPI4 32 bits) the coredns process is consuming a lot of CPU. When I let my config run for a while and observe it with top (on the command line host) the coredns process gets up to 2GB of RES memory! This looks to me like a bug there, and not something linked to my owm config. Is there anything I can do to search it further / solve it?

I am randomly loosing my internet connection on my hassio server. I am trying to figure out what is causing this, but I am starting to think it is actually the hassio-superviser. I am using traefik as a reverse proxy. It is not just hass that looses the connection, but all my other containers as well.

hassio dns info:

host: 172.30.32.3
latest_version: "1"
locals:
- dns://192.168.1.1
servers:
- dns://192.168.1.111
version: "1"

journalctl -b -1 -r:

Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.DBus.Properties.GetAll on /org/freedesktop/NetworkManager/DnsManager
Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.host.network] Update local network DNS information
Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.systemd1.Manager.ListUnits on /org/freedesktop/systemd1
Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.host.services] Update service information
Feb 11 01:46:31 USER systemd[1]: Started Hostname Service.
Feb 11 01:46:31 USER dbus-daemon[918]: [system] Successfully activated service 'org.freedesktop.hostname1'
Feb 11 01:46:31 USER systemd[1]: Starting Hostname Service...
Feb 11 01:46:31 USER dbus-daemon[918]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.1663' (uid=0 pid=31627 comm="gdbus call --system --dest org.freedesktop.hostnam")
Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.DBus.Properties.GetAll on /org/freedesktop/hostname1
Feb 11 01:46:31 USER hassio-supervisor[5485]: 20-02-11 07:46:31 INFO (MainThread) [hassio.host.info] Update local host information
Feb 11 01:18:17 USER nm-dispatcher[25744]: req:1 'connectivity-change': start running ordered scripts...
Feb 11 01:18:17 USER nm-dispatcher[25744]: req:1 'connectivity-change': new request (2 scripts)
Feb 11 01:18:17 USER systemd[1]: Started Network Manager Script Dispatcher Service.
Feb 11 01:18:17 USER dbus-daemon[918]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Feb 11 01:18:17 USER dnsmasq[1005]: using nameserver 127.0.0.53#53
Feb 11 01:18:17 USER dnsmasq[1005]: reading /etc/resolv.conf
Feb 11 01:18:17 USER systemd[1]: Starting Network Manager Script Dispatcher Service...
Feb 11 01:18:17 USER dnsmasq[1005]: using nameserver 127.0.0.53#53
Feb 11 01:18:17 USER dnsmasq[1005]: reading /etc/resolv.conf
Feb 11 01:18:17 USER dbus-daemon[918]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.7' (uid=0 pid=944 comm="/usr/sbin/NetworkManager --no-daemon ")
Feb 11 01:18:17 USER NetworkManager[944]: <info>  [1581405497.2437] manager: NetworkManager state is now CONNECTED_SITE
Feb 11 01:18:17 USER systemd-timesyncd[833]: Network configuration changed, trying to establish connection.

Shortly after hassio updates the local host information I start receiving seeing the error about not being able to resolve github on update checks:

Feb 11 02:13:16 USER hassio-supervisor[5485]:   stderr: 'fatal: unable to access 'https://github.com/home-assistant/hassio-addons/': Could not resolve host: github.com'.
Feb 11 02:13:16 USER hassio-supervisor[5485]:   cmdline: git fetch --depth=1 --update-shallow -v origin
Feb 11 02:13:16 USER hassio-supervisor[5485]: 20-02-11 08:13:16 ERROR (MainThread) [hassio.store.git] Can't update https://github.com/home-assistant/hassio-addons repo: Cmd('git') failed due to: exit code(128)
Feb 11 02:13:16 USER hassio-supervisor[5485]:   stderr: 'fatal: unable to access 'https://github.com/hassio-addons/repository/': Could not resolve host: github.com'.
Feb 11 02:13:16 USER hassio-supervisor[5485]:   cmdline: git fetch --depth=1 --update-shallow -v origin
Feb 11 02:13:16 USER hassio-supervisor[5485]: 20-02-11 08:13:16 WARNING (MainThread) [hassio.updater] Can't fetch versions from https://version.home-assistant.io/stable.json: Cannot connect to host version.home-assistant.io:443 ssl:None [Try again]
Feb 11 02:13:11 USER hassio-supervisor[5485]: 20-02-11 08:13:11 INFO (MainThread) [hassio.updater] Fetch update data from https://version.home-assistant.io/stable.json
Feb 11 02:13:11 USER hassio-supervisor[5485]: 20-02-11 08:13:11 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/home-assistant/hassio-addons repository

Any help would be appreciated.

EDIT:

/etc/resolv.conf

nameserver 127.0.0.53
options edns0

/etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

[keyfile]
unmanaged-devices=interface-name:veth*

I still had exactly the same issue.
RPi4, HassOS 3.13, hassio 108.6, Supervisor 217, so everything in its latest version as of now.
I configured the IP of my FritzBox router as a DNS server and restarted the DNS service via CLI:

ha dns options --servers dns://192.168.178.1
ha dns restart

Didn’t do the trick for me.


As I read most of this post, I stumpled upon the FQDN topic.
What worked for me in the end was to change the config entries to include the full domain name. For example a binary ping sensor:

platform: ping
host: %DNShostname%.fritz.box

As .box turned into a TLD in 2016 I read some other local network services apart from hassio could also experience trouble. The author of the article (in German) also gave the additional tip to add a dot at the end, like

platform: ping
host: %DNShostname%.fritz.box.

At least for me, it worked without.


After this being tested positively, I reseted my DNS entries.

ha dns reset
ha dns restart

Name resolution still works.


Hope that helps someone.
Cheers!

1 Like

I kept having similar problems, in which the DNS stopped working for external domains every now and then. I searched the home assistant forums and tried every given solution to no resolution…

Just found out that the problem was my EdgeRouter X router! It was set to use a static IP address outside of the range that my providers router could give. Seems that whenever my router gets a different WAN address the DNS resolution through the router breaks down…

Sadly my provider doesn’t allow static DHCP on the LAN side, so I will have to update the routing table inside the cable modem/router every time my WAN IP changes to keep things running on my double NAT system, but just thought this “discovery” might help some others with ubiquiti routers…

This worked for me. Adding a ‘.’ to the end of the local DNS name seems to be working.

Thank you.

1 Like

Hi, may i know is the DNS correctly setup below? I’m having problem to install any add on after the fresh install. So what i did is adding the dns server with my router gateway.

image

The 192.168.0.1 is my router gateway.

I have totally the same situation like you, same containers but I cannot run this command because homeassistant container cannot be started because of the Unkown domain error. any idea?

It was default settings for me, but get around 1000 requests each hour since 11 of April:

...
May  4 15:19:36 dnsmasq[2070008]: cached 251.7.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 252.7.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 252.7.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 253.7.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 253.7.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 254.7.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 254.7.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 255.7.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 255.7.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 0.8.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 0.8.18.172.in-addr.arpa is (null)
May  4 15:19:36 dnsmasq[2070008]: query[PTR] 1.8.18.172.in-addr.arpa from 127.0.0.1
May  4 15:19:36 dnsmasq[2070008]: cached 1.8.18.172.in-addr.arpa is (null)