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?
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.
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).
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.
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.
So here's a solution for a system without dnsmasq, odhcp packages:
udhcpc is a dhcp client which starts a dhcpDORA 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...