core: DNS resolution stopped working in 2021.7.0

The problem

My HA docker container updated to 2021.7.0 and HA could not connect anymore to the domain name of my MQTT broker.

When running a network command from within the docker (ping for instance), it fails to resolve the name as well:

bash-5.1# ping mqtt.my.real.domain
ping: bad address 'mqtt.my.real.domain'

At the same time running a dig @ip.of.my.dns.server mqtt.my.real.domain works fine.

A rollback to 2021.6.6 fixed the problem.

What is version of Home Assistant Core has the issue?

2021.7.0

What was the last working version of Home Assistant Core?

2021.6.6

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Many errors such as 


2021-07-07 22:24:13 ERROR (MainThread) [homeassistant.components.mqtt] Failed to connect to MQTT server due to exception: [Errno -2] Name does not resolve
2021-07-07 22:24:13 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall mqtt.publish (c:411cf4f6e58a19ec0c672240e025f72a): topic=/appliance/2007161799249290820048e1e92596e8/subscribe, qos=0, retain=False, payload={"header": {"messageId": "0b9130b4d7ec4370ae02055c5d2a5baf", "namespace": "Appliance.System.All", "method": "GET", "payloadVersion": 1, "from": "/appliance/2007161799249290820048e1e92596e8/publish", "timestamp": 1625689453, "timestampMs": 0, "sign": "2800989154fac2a788c41e22fcc0bc8b"}, "payload": {}}>


### Additional information

_No response_

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 28 (5 by maintainers)

Most upvoted comments

I also have the same issue, after upgrading to 2121.7.0 DNS is not working for local DNS entries. As in the original post MQTT failed to start, as well as the ESXi Stats and Certificate Expiry integrations. In all cases it failed to resolve the FQDN, but was working with the previous release 2021.6.6.

All of the FQDNs that failed are pointing to a local domain that I host on a DNS server on my LAN. I have done some packet captures with WireShark to see what is going on, and what appears to happen is that when HA does a DNS lookup it is requesting the A record (and this is returned correctly), but it then immediately does a second lookup for the AAAA which fails as I don’t have any local IPv6 address records in DNS, and a NXD is returned. HA then appears to ignore the valid A record and uses the NXD response from the AAAA lookup to say that the FQDN cannot be resolved and the integration fails to start.

I’m able to easily replicate this simply by using nslookup from the HA CLI and request an A record from my local subdomain.

~ $ nslookup opensprinkler.mydomain.uk Server: 127.0.0.11 Address: 127.0.0.11#53

Non-authoritative answer: Name: opensprinkler.mydomain.uk Address: 172.16.abc.xyz ** server can’t find opensprinkler.mydomain.uk: NXDOMAIN

I’ve obscured the actual FQDN and IP address, but you can see that although it returns the correct IP address (172.16.abc.xyz) from the A record, it marks it as a NXDOMAIN.

As a workaround for the MQTT and ESXi Stats integration I have recreated the integrations using the IP address instead of the FQDN.

I’m runnig HA OS as a local VM on an ESXi server. DNS resolution is working correctly for any externally hosted DNS servers. IPv6 is disabled on my HA OS network stack, so not sure why HA is even trying to do an IPv6 lookup.

Hope this gives you a clue as to where the problem lies.

@0n3-70uch That is not the same problem. Your issue is listed in the breaking changes section of the 2021.7 release notes.

Oh you a re right. Sorry I searched for “Bad request” but not for this. Thanks.

For anybody else with the same problem. Just add the following to your configuration.yaml:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24