DNS configuration help

Hi,

I’ve been running Home Assistant for a few months now and i’ve found the AdGuard add-on to be really useful.

However, i’ve grown tired of constantly trying to remember the IP addresses of the many devices i’ve got so ideally i’d like to get a DNS server running internally.

I had originally thought about using DNSMasq, but of course the immediate problem i’ve hit is that it won’t run because it wants to also grab Port #53 (TCP and UDP) which is already being utilised by AdGuard.

So far as I can’t see there isn’t any way in AdGuard to add your own CNAME, A and PTR records so i’m a bit stuck as to how I could work around the issue. I also contemplated using alternate ports but all of the various locations I can see where you might specify a DNS server address don’t provide any means to specify an alternate port.

Has anyone got any good suggestions on how to work around this please?

I’m running HA using Hass.io which in turn is running as a VM in Proxmox, so another option might be to create a totally seperate VM and run another DNS Server in there, but if there’s a means to do the entire thing within HA then that’d be a big plus.

Thanks inadvance

Pete

You can simulate A records in AdGuard by using the rewrite rules. Might be possible for CNAMEs as well, but I haven’t tested that.

Thanks for the suggestion.

As I hadn’t had much in the way of feedback I actually downloaded a container template for Ubuntu and then stripped out the default DNS stub and replaced it with DNSMasq. I’m just doing the config of DNSMasq at the moment but it looks like it’ll do the job and as it’s running in a container it’s a pretty lightweight way to do it.

You’ll need to have your dnsmasq instance use adguard upstream in order to get the adblocking benefits, right?

Yes, that’s exactly what i’ve done. Upstream is pointing to AdGuard but DNSMasq instance is hit first to allow local resolution to take place.

Pete

Hi,

Having switch from Pi-hole (DEPRECATED!) to AdGuard Home Community Add-ons (on my HassOS), I wanted to do the same thing: have the resolution of a local area.

I did it the following way:

With the “AdGuard Home” and “Dnsmasq” Community Add-ons installed, I have setup “AdGuard Home” to listen on an alternate port (ie. 8053).

And I have setup Dnsmasq to listen on port 53, with AdGard Home as defaults upstream server (with the IP address of container), and with my records for local zone.

I had to search a little bit to find the IP address to use AdGuard Home as upstream server… I found it in the DHCP configuration settings of AdGuard Home (which I did not enable) under the hassio interface name.

It works, but maybe there’s a better way to find the container IP addr or a better way to use it. Any advice?

Thanks.

EDIT:

As suggested by a friend, I reversed the two add-ons, putting AdGuard Home in front with Dnsmasq as upstream. This allows to keep the statistics and functionality related to clients at AdGuard Home level.

So, AdGuard Home listen on port 53, Dnsmasq on port 8053.

In the DNS configuration of AdGuard Home, we have added this “Upstream DNS servers” entry for the local domain:

[/lan.example.com/]192.168.0.253:8053

(Here 192.168.0.253 is the IP addresse of Home Assistant on the LAN)
And the Dnsmasq configuration handle the local zone records:

    defaults: []
    forwards: []
    hosts:
      - host: gateway.lan.example.com
        ip: 192.168.0.254

can’t make it work with a unique address.
So I have AdGuard on port 53 as you said and added in the DNS configuration the following:

[/lan.example.com/]192.168.0.253:8053
the IP address is the IP from Home Assistant itself on the local network, and la.example.com is the duckdns address right?

On the other hand I have Dnsmaq with the same configuration, but I don’t undertsand the host. is it the same but with “gateway” at the beginning? why is the IP diferent for the Dnsmasq configuration?

Hi LTorrecilla,

[/lan.example.com/]192.168.0.253:8053
the IP address is the IP from Home Assistant itself on the local network

Yes, here the IP address is the Home Assistant IP address on the local network.

and lan.example.com is the duckdns address right?

No, this is the domain name for the internal/local zone.
All dns entries of internal devices in Dnsmasq have this .lan.example.com suffix, for example:
my-desktop.lan.example.com, my-laptop.lan.example.com, my-printer.lan.example.com, my-gateway.lan.example.com,…

On the other hand I have Dnsmaq with the same configuration, but I don’t undertsand the host. is it the same but with “gateway” at the beginning? why is the IP diferent for the Dnsmasq configuration?

Here, gateway.lan.example.com is a simple example, to resolve the address 192.168.0.254 which could be that of your Gateway/Internet box. As explained above, it is in the Dnsmasq configuration that we create the dns entries for the devices on the local network.

Here are some more recent screenshots:

AdGuard Add-on config:
Screenshot 2021-06-11 21.42.46

Dnsmasq Add-on config:

AdGuard config:
Screenshot 2021-06-11 21.51.49

I hope it will help you.

Nice solution!!

But i dont understand how to manage the duckdns domain ex myhome.duckdns.org

Since this thread was the most helpful for me to getting HA to resolve locally using Adguard addon that has it’s own DNS server (via the filtes list) I will necro this thread to share my solution that doesn’t require an additional DNS server (i.e. dnsmasq).

First look at the startup log for AdGuard for this section

2021/11/26 10:21:35.435690 [info] Entering the UDP listener loop on 192.168.8.3:53
2021/11/26 10:21:35.435866 [info] Entering the tcp listener loop on 172.30.32.1:53
2021/11/26 10:21:35.436017 [info] Entering the UDP listener loop on 172.30.32.1:53
2021/11/26 10:21:35.435727 [info] Entering the tcp listener loop on 192.168.8.3:53

there it will tell you the container IP address that Adguard is using for DNS in this case 172.30.32.1

Now via ssh shell use this command

ha dns options --servers dns://172.30.32.1

now the dns core container (in this case 172.30.32.3 will use adguard upstream and adguard can be configured to then look further upstream.

host: 172.30.32.3
locals:
- dns://192.168.8.3
- dns://192.168.8.1
- dns://8.8.8.8
- dns://8.8.4.4
servers:
- dns://172.30.32.1
update_available: false
version: 2021.06.0

tada now the “internal” dns of your hassio install will use this same DNS list as externally (from other machines on the network by setting router DNS to your hassio ip). That list being under “Filters/Custom filtering rules” in the Adguard UI

NOTE: I’m still scrathing my head what the locals: entries are for because you see it’s set to 192.168.8.3 so I thought that the HA dns container would attempt to use this (which is lan ip where Adguard is listenting) but HA dns internally doesn’t seem to forward requests there as without the servers: set to the docker adguard container ip it doesnt work.

FOLLOWUP:
Ironically I started having issues with adguard not listenting externally and I found this issue and a solution. Seem you need to “save” and restart to get adguard to listen on both the container and external ip.

1 Like