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 81.19.82.0
PING 81.19.82.0 (81.19.82.0): 56 data bytes
64 bytes from 81.19.82.0: seq=0 ttl=58 time=18.340 ms
64 bytes from 81.19.82.0: seq=1 ttl=58 time=18.289 ms
^C
--- 81.19.82.0 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?

https://openwrt.org/docs/guide-user/base-system/dhcp.dnsmasq

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;

nameserver 8.8.8.8

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 <==
   nameserver 127.0.0.1

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

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

https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#upstream_dns_provider

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

3 Likes

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.

3 Likes

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
    renew)
	# 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
	done
    ;;
    bound)
	# 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
	done
    ;;
    esac

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.