-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HOAS resolv.conf has wrong search path in homeassistant container #118
Comments
As a workaround, you can automate the fixing of resolv.conf on startup. Replace There's probably a more elegant way to do this that dynamically fetches the correct search path when the container starts up, but I don't know what it is.
#!/usr/bin/env bash
# For some reason sed -i doesn't work inside the container, so we need
# this little dance
sed -E 's,^search .*,search example.net,' /etc/resolv.conf > /tmp/$$
cat /tmp/$$ > /etc/resolv.conf
rm /tmp/$$
shell_command:
fix_dns: 'bash /config/tools/fix-dns' And then in Automations, create one with the trigger "HomeAssistant starts" and the action "call service shell_command.fix_dns". |
Update: the above doesn't work as well as I might hope, because some integrations fire off before the fix script runs -- so e.g. if you have a cmus media sink, it'll try to connect to it before resolv.conf is repaired, and fail. Some of these, like MQTT, will retry and succeed, but cmus doesn't seem to. |
The container in Home Assistant use the DNS plug-in which in turn uses CoreDNS to resolve hostnames. I am transferring the issue to that plug-in. |
Hass.io is a closed system and container orchastrator. If you want to access an external system, use the full qualified name. That is per design and not a bug. |
It may not be a bug, but allowing this to work could be be a desirable feature, because it would remove a difference between core/docker installs and HAOS, it resolves what looks like inconsistent behavior in HAOS, and it looks to be really easy to do, and quite low risk. Currently using bare hostnames for external devices via DCHP provided DNS search paths works just fine with core and docker installs, but doesn't work with HAOS or Supervised installations. This adds undesirable friction for people who want to migrate to HAOS from core or container. Furthermore, using raw hostnames for devices with HAOS sometimes seems to work, and sometimes doesn't. The reason for this is because it works for devices that support LLMNR, but not for others. So how could this be enabled in a simple way with minimal risk? Well to find out, let's look at what happens if you try to resolve a single label name (
So if the mdns plugin had instead removed the "." suffix (with code like Why do I claim this is low risk? Well, first of all it cannot affect any single label names for containers, as those will get tried first. This change also cannot affect any queries that the mdns plugin declines to process, so is limited to just affecting mdns and single label names. systemd-resolved treats names ending with a dot and those without identically, except for dns search list processing, which only gets applied for single label names. |
is this abandoned? |
Still seeing this issue present in HAOS 12.4 (with Core 2024.7.0). Please advise. |
Same issue present in 2024.9.0 |
i've encountered this in one of the add-ons (so it happens inside the docker container).
^-- exactly this. I don't understand the stubbornness that is resulting in this and not allowing us to use our internal network's normal search-domain setting. please someone care to explain why this is being a requirement? well I have discovered another legitimate use-case to add to the list to justify changing this behaviour: My IP camera's RTSP does not work when using FQDN (seems it's too long an address to result in anything but a 401 unauthorized error, due to some unknown limit, change it to an IP and the login works fine). but i don't want to hard-code IPs (it's a well known anti-pattern). so i created a CNAME under my search domain, but of course that doesn't work due to this bug. And yes, i understand it's a deliberate choice, but i would still categorize it as a bug and the wrong decision to make on behalf of everyone, and we'll continue to consider this a bug unless someone can explain the rationale behind this choice |
I would submit that any device (closed system or not -- think any IOT device) in a network that ignores DHCP option 15 (domain to search when looking for unqualified names) is broken by design. The "closed system" nature of HAOS does not absolve it from operating properly in a properly configured network. There are tons of IOT devices for example that work properly with DHCP option 15. Why should HAOS not? |
Describe the issue you are experiencing
I've been having DNS problems with a newly set up HOAS install, where it couldn't resolve any local hostnames. Looking at the logs showed it trying to resolve names like
timelapse.local.hass.io
rather than justtimelapse
or using the DNS search path provided by DHCP.ha dns info
is fine andnslookup
works as expected on both the host and in thehassio_dns
container. However, looking inside the main homeassistant container we see:That is definitely not the correct DNS search path, and it doesn't match the one in the host system or the DNS container! This looks similar to home-assistant/operating-system#454, but that was fixed years ago.
Furthermore, I can't even fix this by editing /etc/resolv.conf in the container, because it gets overwritten every time HA restarts. As a result, HA is basically nonfunctional for me right now.
What operating system image do you use?
ova (for Virtual Machines)
What version of Home Assistant Operating System is installed?
10.5
Did you upgrade the Operating System.
No
Steps to reproduce the issue
Anything in the Supervisor logs that might be useful for us?
Anything in the Host logs that might be useful for us?
System information
System Information
Home Assistant Cloud
Home Assistant Supervisor
Dashboards
Recorder
Additional information
No response
The text was updated successfully, but these errors were encountered: