What is a dns resolver for OpenWrt?

This question is similar/related to this one How to configure an OpenWrt's network without a luci? .

I'm composing a minimal OpenWrt image using ImageBuilder.
I use the next packages: base-files, busybox, netifd, dnsmasq, fstools, mtd_20, mtd-utils-flash-erase, mtd-utils-nandwrite, mtd-utils-mtdinfo .
I'm able to ping using an IP:

root@(none):/# ping
PING ( 56 data bytes
64 bytes from seq=0 ttl=58 time=18.340 ms
64 bytes from seq=1 ttl=58 time=18.289 ms
--- ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 18.289/18.314/18.340 ms

But fail using a name: (I tried the same on my PC and it works)

root@(none):/# ping rambler.ru
ping: bad address 'rambler.ru'

So a question: can a dnsmasq be used as a dns resolver? If this is true, what configs should I care about to make it work properly?


1 Like
head -n -0 /etc/resolv.* /tmp/resolv.*

from a host perspective a-la your question the resolver essentially converts internet addresses to names. on linux, one could characterise this to also include subsystem configurations involving the resolver. ( resolv.conf basically from a minimal view )

from a stack perspective its a little different, as the resolver is a point in the dns resolution hierarchy.

i.e. if you manually enter in /etc/resolv.conf;


and try your test again... WITHOUT DNSMASQ installed.... you will get a much more accurate picture of what a resolver is.

1 Like

Result of a command you've posted:

   root@(none):/# head -n -0 /etc/resolv.conf /tmp/resolv.conf*
   ==> /etc/resolv.conf <==

   ==> /tmp/resolv.conf <==

   ==> /tmp/resolv.conf.auto <==


From your answer I got that a dnsmasq is not a name resolver, but rather a dns server. Am I right?

I have no uci on my OpenWrt configuration :).
Where can I find those network settings as a config file?

Generally a device I have OpenWrt on isn't a router (OpenWrt has been chosen to boost up development), so it'd be better to not have neither dnsmasq nor odhcpd packages installed.

I use a udhcpc (part of busybox) utility to lease an IP and I thought that during dhcp DORA this utility sets up some network interface using settings obtained from a dhcp server (dhcp server IP, gateway,... list of DNS servers), but instead I got an interface up (with IP) without having an ability to resolve names using DNS servers provided by a dhcp server. (I thought that some updates to /etc/resolv.conf have to be, but that's not true).

It's a caching resolver.

DNS servers tend to do recursion when they don't possess the answer. Dnsmasq either consults a recursive server or consults its still-valid previously cached reply.

dnsmasq - /etc/config/dhcp
network - /etc/config/network


if you are bent on uber minimal you probably want to look here...

/usr/share/udhcpc/default.script > dhcp.user

In addition to @lleachii 's excellent answer...

Asking what a resolver is is like asking what a shopper is in a supermarket. Checkout staff are shoppers...

Point being is that a resolver is a concept. A point in a chain. So you can't really say what THE resolver is... unless your talking in the context of a single process or name resolution query.


Thanks, it works :slight_smile:

So here's a solution for a system without dnsmasq, odhcp packages:

udhcpc is a dhcp client which starts a dhcp DORA sequence, once it's finished (and lan settings obtained: leased IP, gateway IP, list of dns servers, etc...) a /usr/share/udhcpc/default.script script gets called which configures a network interface and passes a control to a /etc/udhcpc.user script to make some custom configuration.

In this /etc/udhcpc.user script a list of obtained dns servers is used the next way:

 # look at https://udhcp.busybox.net/README.udhcpc for details

 case "$1" in
	# IP wasn't changed but dns servers may be changed, so apply these changes

	echo "" > /etc/resolv.conf
	for dns_server in $dns; do
		echo "nameserver $dns_server" >> /etc/resolv.conf
	# DHCP DORA has finished, it's time to configure a network interface
	# (main configuration happens in a /usr/share/udhcpc/default.script file, here we just set up dns servers to use
	#  during names lookup)

	echo "" > /etc/resolv.conf
	for dns_server in $dns; do
		echo "nameserver $dns_server" >> /etc/resolv.conf

I'm not sure is it a proper way, as I thought this configuration is part of a base network configuration, not a custom one, so these steps had to be performed in a /usr/share/udhcpc/default.script script rather than a /etc/udhcpc.user one. Though it works...

1 Like

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