Set DHCP to use custom DNS server on localhost

Hi, I recently installed OpenWrt on my FritzBox 4040 and it's amazing how much power there is in OpenWrt. However, I'm slightly confused as to instruct DHCP clients to use the Adguard Home Server (installed following this guide) which is installed on the same router but on a different port.
Currently, the router acts as the main DNS server and forwards DNS requests onto Adguard Home. I would like to instead have DHCP to instruct clients to use as DNS server, but when I type that into Network>Interfaces>LAN>DHCP Server>Advanced Settings>DHCP-Options it seems to not work and I get no DNS on my DHCP clients.
I see 2 options here:

  1. To get the DHCP server to recognise the port of the AdGuard DNS server (probably by using the CLI), or
  2. To disable OpenWrt's DNS server and change AdGuard's DNS Server to use the standard port 53 because then I won't need to define the port of the DNS server.

Any help would be greatly appreciated!

Under Network > DHCP and DNS you want to set your DNS forward to

Then for Network>Interfaces>LAN>DHCP Server>Advanced Settings>DHCP-Options

You need to enter 6,,

This is because that fild can be used for other things other than DNS and you have to specify the paramiter you want to change, in your case you want to change the DNS your devices use you set the DNS by 6,x.x.x.x,x.x.x.x

This will force all devices attached to the interface to use the specified DNS

Hi, thanks for replying,
I have the DNS forward set,
but under Network>Interfaces>LAN>DHCP Server>Advanced Settings>DHCP-Options will pointing to that make it use OpenWrt's DNS server since that is on the default port 53?

It will go to the openWRT DNS but because of the DNS forward, it will listen to all DNS requests from port 53 and then redirect them to port 5353

Yes, I'm aware of that, but I would prefer that all of my devices interfaced with Adguard independently so that I can set different rules for each device.

I probably have to disable the built-in DNS server and change Adguard to use port 53?

You can still achieve the same thing even with the DNS forward. You can specify Clients by ip in Adguard home.

But I would have thought if you wanted to do without the DNS forward and use Adguard home to use port 53. You would most likely have to disable DHCP on OpenWRT and configure, the one on Adguard Home to handle DHCP requests.

But unfortunutly I do not have any experiance of setting that up.

Ok, so I think I've figured it out.
I went to Network>DHCP and DNS>Advanced Settings>DNS Server Port and changed it to 5353 (so that devices don't automatically use it) and I edited the DNS server port in AdGuardHome.yaml to 53 so that it would be detected as DNS server and did a reboot of the router.
I know it's a bit of a hack but it works, OpenWrt is still the DHCP Server and, even thought its DNS Server is active, it uses AdGuard's DNS Server as the one to serve to DHCP clients.

Thanks @HexQauntum for your help!

1 Like

But now the router will not be able to get the ip-addresses of the domains

If the router uses port 53, we will not be able to see clients in adguardhome.

Well, as far as I understand, every other device apart from the router itself use adguard directly as the DNS server. The router instead uses its own DNS server and forwards the requests onto adguard.
That means that only the router's own requests are shown in adguard as the router's, all other deviices come up separately under the adguard dashboard.

1 Like

There are some occasions where the apps overrides the forwarded DNS address.

This can be prevented by using the following rule in custom rules under the firewall.

iptables -t nat -A PREROUTING -i br-lan -p udp --dport 53 -j DNAT --to x.x.x.x:PORT
iptables -t nat -A PREROUTING -i br-lan -p tcp --dport 53 -j DNAT --to x.x.x.x:PORT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.