Operate OpenWRT as DNS Server

Hey Guys,

I want to use OpenWRT without DHCP, but it should offer a DNS Server to my LAN interface.

I've got a Fritzbox which is handling all the DHCP and Internet connectivity running on IP...9, also I've got an Router with OpenWRT running on IP...1 which is handling the WiFi Network (operating as an DHCP Client). Until now I had a different setup and my OpenWRT Router was operating behind a modem and doing DHCP, Internet Connectivity etc...
Unfortunately my Fritzbox doesn't allow me to edit /etc/hosts file, but I want to add some hosts which are beeing resolved by my local DNS which I was doing with OpenWRT before.

I can set up my FritzBox so that it uses a local DNS Server, but whenever I enter the IP of the openwrt Router it won't work (no DNS resolves). Can someone guide me how to set this up? In my Interface->LAN Settings (where the Fritz Box is connected to) I set "use custom DNS Server" and set the two cloudflare IPs.

I tried to find some help via google, however I didn't find my usecase so maybee I'm using the wrong search parameters.

[EDIT] I just tried "opkg update" and I get the error:

Failed to send request: Operation not permitted
*** Failed to download the package list from https://downloads.openwrt.org/releases/22.03.2/targets/ipq40xx/generic/packages/Packages.gz

Thank you in advance for your Help,

Then you need to work out how to get the Fritzbox to send your chosen DHCP Option 6 (DNS server) to the requesting devices.

If that facility isn't exposed, then you're unlikely to achieve your desired objective in the manner in which you've indicated, and you might have to consider an alternate approach.

1 Like

sorry, didn't make myself clear, there is an option with Fritzbox to set "local DNS Server" so, this is possible. However, if I do this, it won't resolve names, so I assume that this has something to do with OpenWRT, since the config in the FritzBox is actually pretty obvious and easy.

Is that the DNS server which Fritzbox uses itself, or the DNS server which Fritzbox issues to DHCP clients? If you configure that option on Fritzbox and then check the clients, what DNS server do they report being issued with?

(I don't have a Fritzbox at my disposal, so I don't know the device's behaviour.)

The OpenWrt should be configured with an IP, with gateway and upstream DNS servers you want it to use.

The dnsmasq instance should then be able to make DNS queries on the Internet.

1 Like

The OEM Fritz!OS does not expose any knobs to configure its dnsmasq instance, the only thing it does allow to configure would be the DNS server it uses itself (and indirectly whose DNS requests it passes through to its DHCP clients).

1 Like

Ok, thank you for the info! I set up the Fritz!Box to use my OpenWRT Router as a DNS Server and I setup up the DNS Server settings in there.

However, I've got some settings in /etc/hosts (some local services I want to be resolved locally, e.g. unraid points to the IP of my server). If I ping unraid it won't get resolved, so I don't get the IP of my server. When using the DHCP of OpenWRT (double NAT) this was working just fine.
I checked and my Windows is getting the correct DNS Server (so my OpenWRT router) and this seems correct.

Any Ideas what might go wrong here?

Try renaming the file from "host" to "hosts", with an "s" on the end.

moronic typo in the description here, it is /etc/hosts actually. I'll fix it in my original post.

[EDIT] I just switched the DHCP Server to openwrt again, somehow I can not access some websites now. Seems like it's exclusively IPv6, I'm at a complete loss. Any Ideas what might cause this?

My ISP is providing me DS-lite Internet, so I don't have "my own" public IPv4.

1 Like

Unfortunately not. I'm a total noob with regard to IPv6. Apologies. I need to set aside some time to work through Hurricane Electric's IPv6 training course!

So, after looking deeper into the system of the router, why it was working for IPv6, but not IPv4.
I only changed the DNS settings for IPv4, so as soon the website was anserwing on IPv4 it wasn't working, but IPv6 was fine, since this was still going directly throught the fritzbox.

Now, I'm actually seeing the issue within my OpenWRT Router, so somewhere I must have made a mistake.

Can someone see what might be going wrong?
This is my LAN Interface setup:

I'm a step further now, I'm not using OpenWRT as a DHCP Server now, but no PC it's not using my /etc/hosts entries except the router itself.

I don't know exactly why, but it's working now. I had to reset my OpenWRT router, restart the fritzbox and the OpenWRT router and switch to DHCP on the OpenWRT router, but not it's working as I want it to work.

My Assumption is, since I alredy tested this, but without resetting the router there was a leftover config which caused this issue.

1 Like

As long as it's working the way you want, that's the main thing.

1 Like

It stoped working, no major changes. I need to look into it again, this is absolutely mysterious to me, I changed some stuff in /etc/hosts (which was working) then changing the WiFi from WPA2 to WPA3 creating a backup.

Some advice, if I may:

Change one thing, then test.

Then change one more thing, then test. And so on.

If you cultivate the habit of changing and testing incrementally, it can help when trying to troubleshoot if something goes wrong; you're more likely to be able to identify the thing you just changed rather than the one of many things you changed several iterations ago.

Yeah, I'm aware and I tell all my engineers to do it like that, but I was sure my changes wouldn't affect this. Also I'm 90% confident, that it was working after the backup, but stoped after some time. Which also shouldn't happen, so I might restart and then do it step by step again.
Unfortunately I I deleted an intermediate backup which was working already.

Oh, the number of times I've been bitten by that very assumption. :rofl:

"It's okay, I know what I'm doing..."

We've all been there.


I just checked it with my phone which is connected via WiFi, working perfectly fine, but not on my PCs which are connected via LAN cable. They are in the same LAN config and the PCs are connected via a Switch to the openWRT router.

Any Ideas how it is possible? I don't have any ideas left, I could reset and redo, but this doesn't seem to make sense to me with an Issue that basically should not happen (in my opinion).

nslookup is giving me the FritzBox as a Name Server

Which, I suspect, possibly answers the question I posed here:

If the FRITZ!box DHCP server doesn't expose the DHCP Option 6 setting for you to configure, then you might need to consider an alternate approach.

How about this?

Consider disabling the DHCP service on the FRITZ!box, and enable it on OpenWRT instead.

OpenWRT definitely exposes both DHCP Option 3 (router) and DHCP Option 6 (DNS) for the administrator to configure, so you could tell clients to use OpenWRT for DNS and the FRITZ!box for the gateway out of the network.

And there'd still be only one DHCP server on the network, so no conflicts... fingers crossed.