2

On Debian-based Linux, dnsmasq works by replacing the nameservers in /etc/resolv.conf with 127.0.0.1 (referring to "Linux for Wireless Engineers: How to Do DNS Caching with dnsmasq").

But I find that on Alpine (and Alpine based docker) it does not work that way. When dnsmasq starts, /etc/resolv.conf remains the same. So if I just start dnsmasq it makes no difference in term of dns resolving. I write a script to start dnsmasq and it feels awkward.

   cp /etc/resolv.conf /etc/resolv.dnsmasq
   sed -i 's/^nameserver.*/nameserver 127.0.0.1/' /etc/resolv.conf
   dnsmasq -r /etc/resolv.dnsmasq

So is there a better ("proper") way make dnsmasq work on Alpine ?

Qiulang 邱朗
  • 201
  • 2
  • 11

1 Answers1

1

It seems that in debian the initialisation script is responsible for updating resolv.conf https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=tree;f=debian;h=7539dd72f8ea2d8d4b60d926ffa163956e3624a5;hb=HEAD . Look at resolvconf, systemd.service, etc.

I don't know if alpine handles similarly. I think you should run dnsmasq on alpine using its initialisation script rc-service dnsmasq start. You can read the script here https://git.alpinelinux.org/aports/tree/main/dnsmasq/dnsmasq.initd (or locally). There are valuable information on https://wiki.alpinelinux.org/wiki/Main_Page .

The dns might be changed by the dhcp client.

I hope this helps.

yarl
  • 502
  • 3
  • 8