I’ve setup my new home assistant server, most things working but I’m getting fustrated with DNS.
At the moment I have the adguard DNS + DHCP server installed and running. Server IP is 192.168.175.10 and the DNS is working. From a server on the network -
You have specified two DNS servers, and which one gets used is unpredictable - it doesn’t use the second one if the first can’t be contacted. Therefore if it chooses to use Google (8.8.8.8), it will not be able to resolve “arm2”, so remove this one and try again.
Also, when you’re looking at core-ssh, that is a docker container, and 127.0.0.11 is docker’s internal DNS server that just forwards requests to the DNS server on the host.
If you have a display connected to the HA machine (or have enabled SSH over port 22222) you can use the following commands to see the DNS on the host:
nmcli device status
nmcli device show <insert-interface-from-above-command>
Thanks, I didn’t know that. I assumed home assistant used the default for resolv.conf If there are multiple servers, the resolver library queries them in the order listed ( https://linux.die.net/man/5/resolv.conf ).
However I tried remove 8.8.8.8 ( and rebooted ) but no change -
[core-ssh ~]$ host arm2
[core-ssh ~]$
I did noticed that core-ssh container can access the adguard dns server -
[core-ssh ~]$ host arm2 192.168.175.10
Using domain server:
Name: 192.168.175.10
Address: 192.168.175.10#53
Aliases:
arm2 has address 192.168.175.11
[core-ssh ~]$
I also noticed resolution via the default server, 127.0.0.11, is very slow ( 8 seconds ) -
[core-ssh ~]$ time host arm2 127.0.0.11
Using domain server:
Name: 127.0.0.11
Address: 127.0.0.11#53
Aliases:
real 0m8.043s
user 0m0.031s
sys 0m0.009s
But for public sites its fast -
[core-ssh ~]$ time host bbc.co.uk 127.0.0.11
Using domain server:
Name: 127.0.0.11
Address: 127.0.0.11#53
Aliases:
bbc.co.uk has address 151.101.64.81
bbc.co.uk has address 151.101.0.81
bbc.co.uk has address 151.101.128.81
bbc.co.uk has address 151.101.192.81
bbc.co.uk has IPv6 address 2a04:4e42:400::81
bbc.co.uk has IPv6 address 2a04:4e42:200::81
bbc.co.uk has IPv6 address 2a04:4e42::81
bbc.co.uk has IPv6 address 2a04:4e42:600::81
bbc.co.uk mail is handled by 20 cluster1a.eu.messagelabs.com.
bbc.co.uk mail is handled by 10 cluster1.eu.messagelabs.com.
real 0m0.144s
user 0m0.022s
sys 0m0.017s
I don’t have access right now, but I’ll try to get it.
When you just write arm2, then the DNS client will look for a domain just called arm2, not a host.
When that fails then it looks in its search domain list for domains to search and then pretend arm2 on these an goes through the list one by one until it gets a successful reply.
Th search domain list can be distributed rom the echo server but DHCP clients do not always use this information.
With static IPs you have to configure the DHCP service to get this I formation specifically or you will have to set the list directly and manually.
Internally Home Assistent uses a search domain of local.hass.io … maybe it could include lan as well.
I found Adguard Home supports Automatic hosts ( DHCP · AdguardTeam/AdGuardHome Wiki · GitHub ) - DHCP hosts are included in DNS but in the default .lan domain. I didn’t find this info in the Home Assistant docs.
But neither changing the domain nor the DHCP search domain ( option 119 ) is exposed via the Home Assistant Adguard plugin. So clients have to use .lan at the moment … still thats much better than IP addresses !
I think I had a workaround for that problems once, where I used the router DHCP and DNS, but made sure the router itself used the HA addons to look up things and then the HA addons access the internet for further lookups.
This opened up the routers possibilities, but made sure the HA addons’ features were still usable too.