[Samba] NetworkManager, DNS, and resolv.conf

Patrick Goetz pgoetz at math.utexas.edu
Sat Mar 5 14:42:58 UTC 2022


I think the following pertains to all desktop clients configured with 
NetworkManager, but this particular machine is configures with Ubuntu 
20.04 Mate edition.

I've been following the Samba Wiki instructions for setting up a domain 
member, in particular the /etc/resolv.conf configuration:

 
https://wiki.samba.org/index.php/Setting_up_Samba_as_a_Domain_Member#Configuring_the_.2Fetc.2Fresolv.conf

So, on a machine called erap-ubuntu I had configured /etc/resolv.conf 
like this:

    search ea.linuxcs.com
    nameserver 192.168.1.80


This morning I was testing something and noticed that /etc/resolv.conf 
had been rewritten by NetworkManager:

    search linuxcs.com
    nameserver 127.0.0.53

I don't typically use NetworkManager, so this was residual from the 
initial install.  Doing a little testing, when you edit /etc/resolv.conf 
by hand, NetworkManager doesn't know about this and instead defers to a 
NetworkManager-specific configuration file:

   /etc/NetworkManager/system-connections/Wired connection 1.nmconnection

My bind nameserver, 192.168.1.1 was set in this file, but NetworkManager 
still defers to the systemd-resolved nameserver stub, 127.0.0.53.

Any time NetworkManager is restarted, /etc/resolv.conf is reset to use 
127.0.0.53 even if I explicitly set the samba-dc nameserver in the 
NetworkManager configuration for that interface.  The search domain is 
preserved.

Given the prevalence of NetworkManager, this is one of those "if you 
can't beat them, join them" situations, so I experimented with just 
leaving /etc/resolv.conf set to:

    search ea.linuxcs.com
    nameserver 127.0.0.53

and everything seems to work fine:

   root at erap-ubuntu:~# wbinfo -i mduffy
   mduffy:*:11108:10513::/home/mduffy:/bin/bash

   root at erap-ubuntu:~# samba-tool dns query samba-dc 
1.168.192.in-addr.arpa 85 PTR -U Administrator
   Password for [EA\Administrator]:
     Name=, Records=1, Children=0
       PTR: erap-ubuntu.ea.linuxcs.com (flags=f0, serial=5, ttl=900)

   root at erap-ubuntu:~# host -t SRV _ldap._tcp.ea.linuxcs.com
_  ldap._tcp.ea.linuxcs.com has SRV record 0 100 389 
samba-dc.ea.linuxcs.com.
-------------------------------

So unless there's something I'm overlooking, I'm going to update the 
Wiki so that the vast majority of linux users (i.e. all those folks 
using NetworkManager) aren't confused by this.






More information about the samba mailing list