Re: How to merge static and connection-specific dynamic configuration in resolv.conf



On Sat, 2018-01-13 at 08:37 +0300, Oleg Samarin wrote:
Hello!

Is there a proper way to include some static, connection-independent
part to autogenerated resolv.conf?

For example, I want to have /etc/resolv.conf like this:

-------------------------------------------------------------------
----
search mystaticdomain1.com, mystaticdomain2.com,
connection1domain.com,
connection2domain.com
nameserver 127.0.0.1 #static part
nameserver Cnn.001.Dns.Ip4 # from connection 1
nameserver Cnn.002.Dns.Ip4 # from connection 2
-------------------------------------------------------------------
----

Including 127.0.0.1 and "mystaticdomain1.com, mystaticdomain2.com" in
each connection configuration allows me to achieve this goal, but it
is
not comfortable. Moreover I want to have the static part in my
/etc/resolv.conf even there are no connections are opened.

Is there any way to specify static part somewere once?

Oleg Samarin

Hi,

Maybe.

1.) A non-solution is, that you configure global DNS in
NetworkManager.conf (see GLOBAL-DNS-DOMAIN in `man
NetworkManager.conf`). But specifying such global configuration
disables all per-connection settings, so this is not what you ask for.

2) What you can do, is to tell NetworkManager not to write
/etc/resolv.conf at all, and do it yourself. For example, using a
dispatcher script and possibly merge
/var/run/NetworkManager/resolv.conf with your own settings. You obtain
the DNS configuration from NetworkManager's D-Bus API (e.g. via nmcli)
and write the script to do whatever you want. But that is cumbersome...

3) If you configure NM's rc-manager with "resolvconf" (Debian) or
"netconfig" (SuSE), then these components merge the DNS information
(see `man NetworkManager.conf`). I never tried that, not sure how it
works.

4) if you use systemd-resolved, then you can configure resolved with
global configuration, and NM updates on top of that. I never tried
that, not sure how it works.

5) you could write a script that bulk-updates all NetworkManager
profiles to contain the setting you want.
  for uuid in $(nmcli -g UUID connection); do
     nmcli connection modify $uuid +ipv4.dns 127.0.0.1;
  done


best,
Thomas

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]