DNS and /etc/resolv.conf

By default content of /etc/resolv.conf

search lan
nameserver 127.0.0.1

My wan config has this line option dns 8.8.8.8 8.8.4.4

This works most of the time, but today I noticed "ping google.com" was sometimes returning "bad address" and other times it was slow to resolve the IP, from within the router prompt.

When I put nameserver 8.8.8.8, in resolv.conf the issue went away and IP resolution was faster, [from within the router]

My queries:

  1. Would this also impact internet user connected to the router?
  2. When I restarted dnsmasq, the content of resolv.conf got reverted to default.
    Where can I change to make it permanent?

depends on which DNS they use

depends on who the DNS IPs should affect, the router, or the clients.

The users have default network setting, which has DNS setting as the "router".

if the users have the routers IP as DNS, then the change on the router will affect them.

changing upstream DNS settings is done in How to set dns in dhcp mode - #2 by frollic, but I'm pretty sure your option dns covers this.

do a nslookup from the router, see where the query goes.

note, there's an additional resolv.conf file in /tmp/...

If this will help users resolve DNS faster, then every OpenWRT router should have nameserver <your preferred dns provide> in resolv.conf file. The impact was that much drastic.

Most people know only the "option dns" setting in /etc/config/network.
Wonder why the setting "option dns" in network config isn't as effective.

The default mode of operation is:

  • DNSMASQ acts as a local caching nameserver.
  • DNSMASQ is instructed to use the nameservers configured at /etc/network, or received by the DHCP client; but DNSMASQ does not use /etc/resolv.conf.
  • /etc/resolv.conf points to the local DNSMASQ, so the software running on the router uses the local cache.
  • DNSMASQ also acts as a DHCP server.
  • DNSMASQ is configured to announce itself as a nameserver to the clients.
1 Like

no it shouldn't.
openwrt is no mind reader, and public servers are completely blocked in some countries.
using anything else than what the ISP provides you with (usually via DHCP), is a hit or miss.

bypassing the local dnsmasq will also make any local lan name query fail.

1 Like

But it could pick up the setting from /etc/config/network OR received by DHCP client and populate in /etc/resolv.conf.

So as per this, the change in /etc/resolv.conf will not impact the user connected to the router. Am i correct?

as already posted ...

Yes, /tmp/resolv.conf.auto has the DNS from network config.
But /tmp/resolv.conf does not. It has only nameserver 127.0.0.1
And from within the router DNS resolution was much faster only after I added nameserver 8.8.8.8 in resolv.conf

Thank you folks for all your comments so far.

What I am mainly interested to know is whether DNS resolution speed-up i noticed from within the router after the aforesaid change in resolv.conf, will users also benefit from the same or not.

wrong file - /tmp/resolv.conf.d/resolv.conf.auto

/etc/resolv.conf is a softlink to /tmp/resolv.conf

I tested it out.
I put a bogus IP in /etc/resolv.conf; from within the router DNS did NOT resolve.
But as a user connected to router, it had no impact, DNS continued to work.

Thank you @frollic and @eduperez for your insights.
This forum never disappoints :slight_smile:

1 Like

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