Simplified Peer DNS

Hello,
Needing to check understanding: the default script for udhcpc in OpenWrt handles peer DNS servers by updating the UCI configuration for dnsmasq and then reloading it?

I'm trying to work with a "secondary router" that has limited responsibilities, for now this means that dnsmasq is not installed.
Its WAN port is always set to use the DHCP client.
To get equivalent functionality, I have to create a udhcpc user script in /etc/udhcpc.user.d/ to process the server list and append them to /tmp/resolv.conf, like this:-

case "${1}" in
(bound|renew) ;;
(*) exit 0 ;;
esac
RESOLV_CONF="/tmp/resolv.conf"
echo -n > $RESOLV_CONF
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
for i in $dns ; do
    echo nameserver $i >> $RESOLV_CONF
done

Is this correct, or is there another way of achieving the same thing?

If you want to sysupgrade in future using standard images best is to bind dnsmasq dns to loopback and disable dhcp server on all interfaces.

I have a bunch of devices without dnsmasq and on interfaces configure as dhcp client the dhcp provided nameserver is installed and used without any manual steps... Why do you need your own script?

Why indeed. Turns out that the network service wasn't running on boot. :face_with_hand_over_mouth:
After I fixed that, /tmp/resolv.conf.d/resolv.conf.auto appears after DHCP address assignment and all is well.

1 Like