Must use a local DNS provided by DHCP

My devices are not visible from the outside world, and those that get locally addresses assigned by my Ubuiqit DHCP server acting as my local DNS. Why doesn’t HA honor the DNS server supplied by DHCP?

Home assistant itself is properly listed in my /etc/hosts file, so it is otherwise cooperating.

I did attempt to set up DNS IP, but it doesn’t let me specify the DNS server by IP address. And with over 300 devices I’m using static addresses is not an option.

Some background Living the Beta Life and other articles.

Set your DNS server(s) in Settings → System → Network → IPv4 (or v6 if you use it), for your listed network adaptor.

1 Like

Also try to run “ha resolution info” to do a little test of your DNS setup.

settings/system/network doesn’t seem to offer options for setting the address and “DNS IP” just says failed

Not sure how to do “ha resolution info” remotely but at the console it is just say “working” with no details.

And DNS IP failed and goes back to openDNS when I try to add it.

image

And to add injury to insult for some reason my mosquito machine’s IP address changed on a reboot (first in months) and the MQTT broker won’t accept the updated address.

Good news. HA accepted the new MQTT address this time. But it’s also a reminder of why I need to use names not static addresses.

You are typing in an IP address for the DNS and not a hostname or FQDN, right?

Yes, I’m typing the IP address because Ubiquiti isn’t giving me a DNS entry for it. If I find a name I’ll switch to using it. But I’m surprised it seems to be rejecting the IP address.

I just tried it, 192.168.20.1 works 192.168.20.01 is rejected. Note the leading zero. It is present in your screenie.

EDITED: I misinterpreted your second screenshot - where do you even find that dialog in HA?

oops.

I got to DNS IP using “add integration DNS IP”. Is there a better approach?

So I tried again and it still failed1 I wonder if it just doesn’t like 172.20? Unlikely to be the problem.

FYI
image

OK I understand that you are using the DNS IP integration now.

But that does not affect system dns resolution, it provides a sensor that looks up the IP address of a hostname and the state of that sensor is the IP address. The DNS IP integration can use whichever DNS resolver you choose.

However in the example you have given, you are not asking it to resolve a hostname (eg www.example.com), you have asked it to resolve an IP address (172.20.0.1), which doesn’t really make sense.

DNS servers can never be hostnames.
It will have to be IP addresses.
A DNS server translate hostnames into IP addresses and the IP addresses are then contacted.
Computers can not use hostnames to communicate, so a hostname in a DNS setup would require the computer to lookup the IP address that belongs to the hostname, which means contacting a DNS server. It’s a catch 22

In your query that you have posted a picture you have entered an IP address in the hostname field.
You need to enter a hostname there to make the query work.

Again oops. So it seems DNS IP is used to look up a name for testing and not for setting the DNS for HA. In fact, it says that I am using the correct resolver at 172.20.0.1 already.

Which brings me back to why can’t I use a local DNS name for my MQTT broker. DNS IP distracted me into assuming it was using an external DNS resolve. But given that it’s using the correct local address

Do you have an authoritative DNS server to serve azz.it?

Many DNS services are just resolvers and can not act authoritative.
Some can act authoritative, but only for non-existing TLDs.

If you ssh in to your hass machine, what does

nslookup pi4x.aaz.lt

return.

I’m using the Ubiquiti DHCP server as my DNS server. aaz.lt does have a public presence but my local machine is just in the local DHCP table. I’m not sure how authoritative figures in to simple asking for resolution. nslookup and ping work fine on my local machine.

I tried to figure out how to SSH and installed SSH/Telnet support but failed. I can, however, type on the console but it says no nslookup and I can’t find an equivalent.

BTW, I figured out why the IP address seemed to change – I had WI-FI enabled so there were two addresses. But now I can’t revert to the wired address even though I can ssh into the machine running mosquito. So if I turn off Wi-Fi it becomes in accessible. One big reason for using a name is that I can then use either Wi-FI or wired.

No you can’t.
A hostname can only point to one IP address and wired and WiFi will have different IP addresses, because the netcard will have different MAC addresses.

I know that each has a separate IP address. That’s why I saw the address change.

But if I use a name and only one interface is registered, it should switch to that name. Of course, I say should DHCP cannot be relied on to clear stale entries, but I can work around that. What is important is that by using names, I only have to address this issue in one place rather than the many places where there can be a reference.

You will have to update the DNS server with every change, since you should not be able to register the same name to two MAC addresses/IP addresses.
You will also have to fight with DNS clients that cache the lookups they have done earlier, which can be handled by lower the TTL of the zonefile and the host entry.

DHCP is updated automatically, though, as I noted, it means I only have to deal with one
place. I’m well aware of the limits of DHCP as DNS. I set my TTL to 900 seconds (15 minutes).

I don’t think of DHCP as a zone file as such – I do have my public zone files which are proper DNS zone files.

Some points

  1. DHCP servers are not DNS servers, but they can be linked. dnsmasq is a good and used often in home lans.

  2. A hostname can have more than one IP via DNS, that is how round-robbining works. It means the load for a hostname can be spread over more than one host. Try , eg, www.bbc.com. I set up the DNS IP integration for it yesterday and it changes often

www.bbc.com changed to 151.101.0.81

2:03:49 PM - 32 minutes ago

www.bbc.com changed to 151.101.192.81

2:01:49 PM - 34 minutes ago

www.bbc.com changed to 151.101.0.81

12:55:49 PM - 2 hours ago

www.bbc.com changed to 151.101.64.81

12:53:49 PM - 2 hours ago

www.bbc.com changed to 151.101.0.81

12:45:49 PM - 2 hours ago

www.bbc.com changed to 151.101.64.81

12:43:49 PM - 2 hours ago