[Dnsmasq-discuss] Avoid conflicts between dnsmasq and systemd-resolved.

Hongyi Zhao hongyi.zhao at gmail.com
Mon Sep 14 09:43:52 BST 2020


On Mon, Sep 14, 2020 at 12:31 PM Dominick C. Pastore
<dominickpastore at dcpx.org> wrote:
>
> On Sun, Sep 13, 2020, at 10:44 PM, Hongyi Zhao wrote:
> > On Mon, Sep 14, 2020 at 9:02 AM Neal P. Murphy
> > <neal.p.murphy at alum.wpi.edu> wrote:
> > >
> > > On Mon, 14 Sep 2020 06:52:49 +0800
> > > Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
> > >
> > > > On Mon, Sep 14, 2020 at 4:26 AM Geert Stappers <stappers at stappers.nl> wrote:
> > > > >
> > > > > On Sun, Sep 13, 2020 at 03:36:42PM +0800, Hongyi Zhao wrote:
> > > > > > So I want to know how to solve the confliction problem between dnsmasq
> > > > > > and systemd-resolved.
> > > > >
> > > > > The trick is deciding which DNS is "upstream"
> > > >
> > > > Still, I'm no so clear on the solution. How to solve it? Any more
> > > > hints/instructions?
> > > >
> > > > Regards,
> > > > HY
> > >
> > > You should be able to disable that systemd stub resolver service so that it is not started.
> >
> > I really like to use the systemd-resolvd relevant command for check
> > the DNS status, say, the following:
> >
> > $ systemd-resolve --status
> > $ resolvectl status
> >
> > If I disabled the systemd-resolvd service, then the above commands
> > should be unavailable.
> >
> > > Or configure your resolvers so that the systemd stub is not referenced.
> >
> > Do you mean operations similar to the following:
> >
> > $ sudo rm /etc/resolv.conf
> > $ echo nameserver 127.0.0.1 | sudo tee /etc/resolv.conf
> >
> > But I also set the DNS sever as 127.0.0.1 with the following netplan
> > config file:
> >
> > $ cat /etc/netplan/99-networkd-local-dns.yaml
> > network:
> >  version: 2
> >  renderer: networkd
> >  ethernets:
> >    enp:
> >      match:
> >        name: enp*
> >      dhcp4: true
> >      dhcp4-overrides:
> >        use-dns: false
> >      nameservers:
> >       addresses:
> >        - 127.0.0.1
> >    docker:
> >      match:
> >        name: docker*
> >      dhcp4: true
> >      dhcp4-overrides:
> >        use-dns: false
> >      nameservers:
> >       addresses:
> >        - 127.0.0.1
> >
> >
> > So, I still can't figure out the differences between the DNS set by
> > netplan and /etc/resolv.conf. Any more hints on this question?
>
> Personally, I am not a fan of Netplan for reasons like this. It's supposed to abstract away the details of NetworkManager or systemd-networkd, but it doesn't do a great job of it. You end up having to refer to the NetworkManager or systemd-networkd documentation anyway, and having Netplan on top muddies the water.
>
> Anyway: Those address lines in the Netplan yaml are used to tell systemd-resolved which upstream DNS server to use, so it is using your Dnsmasq server. Then, /etc/resolv.conf specifies what DNS server other programs on the system will use (not all programs use that mechanism, but many do), and by default, it points to 127.0.0.53 so everything else will go through systemd-resolved. This includes Dnsmasq unless you configure it to do otherwise!
>
> The net result is most likely that Dnsmasq and systemd-resolved are each trying to use the other as their upstream server, so neither can resolve anything.
>
> If you really want to keep using both systemd-resolved and Dnsmasq, you need to pick one to be "upstream" from the other, as Geert and Neal said.
>
> If you want Dnsmasq to query the upstream servers, systemd-resolved to query Dnsmasq, and everything else on the host to query systemd-resolved:
> Then you need to edit the Dnsmasq configuration to quit using /etc/resolv.conf. This probably means you want to manually specify DNS servers in /etc/dnsmasq.conf with the "server=W.X.Y.Z" and "no-resolv" options. That does assume you know what DNS server you want to use.

Very strange, for my case, I've already set the following options in
my dnsmasq.conf:

no-resolv
no-poll

and keep /etc/resolv.conf as the symlink to
/run/systemd/resolve/stub-resolv.conf

>
> Alternatively, if you want systemd-resolved to query the upstream servers and Dnsmasq to query systemd-resolved:
> Then you need to remove the "use-dns: false" and "nameservers" directives from Netplan so systemd-resolved stops trying to query Dnsmasq and uses the proper upstream servers instead. Dnsmasq will continue to use systemd-resolved, since /etc/resolv.conf will point it there. Note that programs on the same host will still use systemd-resolved and not Dnsmasq at all.

Why?

> Only other hosts on the same network will be able to use Dnsmasq.

Seems this is not my purpose.

>
> Regards,
> Dominick
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss



-- 
Hongyi Zhao <hongyi.zhao at gmail.com>



More information about the Dnsmasq-discuss mailing list