Local DNS!

Thanks very much everyone for the detailed technical discussion that helped me to understand the problem. My router recently updated the dnsmasq to version 2.88, that suddenly from v2.86 started returning NXDOMAIN for non existent IPv6 records for local domains instead of previous NODATA-IPv6. Or to be more precise, it forwards them upstream which is obviously nowhere in this case.

So to make it work - the less than ideal workaround is to add another entry into dnsmasq.conf file for the dummy (localhost - :: ) IPv6 address, so something is returned for the AAAA query, but IPv4 result of the A query is still used.

address=/router.home/192.168.1.1
address=/router.home/::

Ideally, there would be a dnsmasq option to change that behaviour and also Home Assistant should not be asking for IPv6 addresses, when IPv6 is disabled.

Just wanted to give you and my future self a nudge.
I resolved my issue using the unofficial Addon "Run On Startup.d", which i use to add a custom entry to the hosts file of the hassio_dns-container:

➜  ~ cat /config/startup/startup.d/hassio_dns.sh 
#! /bin/bash

echo "This script is executed in the hassio_dns container"; 
env;
echo "192.168.30.190 SECRETHOSTNAME.duckdns.org" >> /config/hosts;

This way, everytime homeassistant boots, the Hostname gets an entry with it’s local IP.

3 Likes

That’s an innovative use. I had never thought to modify DNS entries.

Maybe it helps someone with “.local” dns problem: HA OS does not resolve .local hostnames(Solved) - #7 by robot468

uhhh… You’re aware that you just necro’d a 3 year old thread, yes?

Yeah, it’s just the most informative thread on a problem I’ve encountered. Perhaps those who encounter it later will also find this thread.

it’s true it was “opened” 3 years ago, but if you bother to look through, or just alittle bit up in the posts, i.e Feb 20, that’s in 2023 :wink: etc. etc. so frankly a very “alive” topic still

Yeah, I realized that after he replied. I saw the post opened in '20, then saw “Feb 20” Missed the fact there was no ’ in front of the 20. The formatting of date/time posts and replies are written is not exactly clear in this forum… :wink:

2 Likes

agree on that :slight_smile:

Not sure if this is the correct place to post this, but you guys seems to be knowledgeable regarding the DNS setup in Home Assistant.
I’m having errors that I think might be related to DNS basically not working at all, no external resolving, so any pointers here would be great. Did a fresh install of HAOS on an Intel NUC, running 10.5, and Home Assistant Core 2023.9.2.

I have the following DNS config:
image

This is the result when trying to resolve from HA:
image

So basically ignoring the config.

This is the DNS log from the built in log viewer:

This is the output from ha resolution info:

This is the settings in /etc/resolv.conf
image

This is the output from nslookup from a computer on my local network:
image

Any clues on what is going on and how DNS can have ended up so complicated and in this state?

Br
/Micke

Solved the issue, the DNS container might have been broken for some reason, a supervisor repair solved the issue so that DNS resolution works again.

So to be clear, this problem still is not solvable if you are running a standard docker installation? (homeassistant/homeassitant)

I’m running HA along with AdguardHome, and using unbound to forward to cloudflared or dnscrypt proxy, in docker containers. Since firing up AdguardHome in docker, HA won’t initialize basically any of my integrations.

I’m digging into this now—I run a local DNS resolver, and the hassio Core DNS is breaking imtegrations with timeout errors, despite 0ms responses.

nmcli options don’t persist due to a reset of the image by the Supervisor (I think). Attempts to disable ipv6 from “local-link” reset on a reboot. Attempts to change the DNS server results in a “dns-data” error, which is not in the reported information for the connection, nor in any documentation.

Installation if DNSMasq to request from my upstream resolver returns a “junk in code” error upon attempts to start.

I’m going to fiddle and see what works — disabling IPv6, increasing the “connection.gateway-timeout” times, prioritizing IPv4, and de-prioritizing IPv6, plus about 50 others seemed to fix the errors but I gave it a hard reboot thinking I had fixed it… no dice. Ended up taking a break, but I’ll post back when I get to it with any solutions.

The HA team seems pretty opposed to discussing DNS issues, although I’m not sure why. I guess I can’t really complain — I’m running the supervised version.

Hopefully this gives me the tools I need to bootstrap it on my own (or at least with the help of the community).

1 Like

Suddenly had DNS issues as well. Local lookups didn’t function as expected anymore and to my surprise, there were lookups to Google DNS for a hostname that is strictly local. DNS did work correctly for months until a restart beginning of December. No mention of “8.8.8.8” in the network configuration settings, had to use tcpdump to find out. Then used “dns options --servers” to fix. Weird.

Did you get this error when the Startup.d ran?

exec: fatal: unable to exec /tmp/hassio_dns.startup.sh: No such file or directory

Ive read through this thread but a bit confused on how local dns is handled for local domain names that resolve totally locally.

Asking as one of the many reasons for using HA was the fact that everything is local. So I was a bit surprised earlier this week when I lost internet for an extended period of time and HA refused to solve some local domains to devices. Below Ive attached a picture with some debug info and some testing I did.

Not show, but from other testing I did using nslookup.I could tell it was able to properly resolve my domains but, it would then sit after resolving and give a SERVFAIL error as if it was trying to hit another DNS server or something.

I can see some IPv6 attempts in your screenshot. When your device receives an IPv6 address, it is typically made up with a prefix that has been provided by your ISP, and then a portion that the device gave itself. So when your internet connection goes down, the IPv6 address prefix is often removed by your router, because it could potentially be a different prefix when the internet connection is restored. It’s worth bearing that in mind.

Hmm interesting. To be totally honest, I am not sure if the device in the above picture actually even supports IPV6. My ISP doesnt support IPV6 so my router(unifi) doesnt even have it enabled.

I only have it enabled on HA for matter support.

The first time I ran into this behavior with local DNS servers I was also surprised at how convoluted such a basic setting is in HA (HAOS). Made me remember the same situation with NAT hairpinning on Cisco zone-based firewalls. A common setting with a standard, universally understood configuration is implemented in a unique and thus confusing way.

If I understand it correctly, in HAOS Home Assistant Core uses an internal DNS server that runs as a docker container: hassio_dns.

Network settings, including DNS server, can be changed on the web GUI > System > Network > Configure network interfaces. Or from the HA cli using ha network. DNS settings specifically (I think this is for hassio_dns) can be managed from the HA cli as well with ha dns.

On my setup a set the same local DNS server with both ha network and ha dns.

This is one of those pieces of the config that warrants a dedicated page in the docs, but I haven’t found it. Please point/correct me as needed.

Yeah totally agreed. It seems to defeat the point if we have all local services, if homeassistant cant actually resolve those services locally when/if the internet goes out