Package sysconfig problem (DNS settings in /etc/sysconfig/network/config )

I need to add my dns server IPs as static dns server for system.

People told me by editing /etc/sysconfig/network/config :

NETCONFIG_DNS_POLICY="STATIC NetworkManager"
NETCONFIG_DNS_STATIC_SERVERS="<dns-ips>"

However, /etc/sysconfig/network/config is owned by sysconfig package. Local changes can be overwritten or reverted during system package updates.

There does not seem to be a drop-in mechanism such as:

/etc/sysconfig/network/config.d/*.conf

So, dear openSUSE maintainers , please add support for an upgrade-safe way to override the NETCONFIG_DNS_* settings, without editing the package-owned /etc/sysconfig/network/config directly

(I’m on Leap 15.6)

Which tool do you use to manage your network

  • wicked?
  • NetworkManager?
  • systemd-network?
  • …?

But you tagged your topic as “Tumbleweed” (and “Leap”).
Please explain what you are using!

Which tool do you use to manage your network

I’m using NetworkManager, the default one.

I did some research before posting, and found out that with default setting, NETCONFIG_DNS_* in /etc/sysconfig/network/config will take effect.

But you tagged your topic as “Tumbleweed” (and “Leap”).
Please explain what you are using!

Sorry my bad at tagging. I’m using Leap 15.6

I’ll correct the tag to reflect this.

With NetworkManager, you can either use your desktop’s network configuration utility or nmcli to modify the connection and set the required static DNS servers for your connection definition.

For example:
nmcli connection modify "YourConnectionName" ipv4.dns "1.1.1.1 8.8.8.8"
nmcli connection modify "YourConnectionName" ipv4.ignore-auto-dns yes
then
nmcli connection down "YourConnectionName"
nmcli connection up "YourConnectionName"

More info:
man nmcli

Thank you for the tips but that won’t work for me.

At first I thought about NM way. But what I want is a “global” dns setting (no matter what network I connection to). NM’s config just effect one connection. I move my laptop a lot. I often connect to new Wifi. In new office I create new ethernet connection (with new static IP).

As far as I can find, sysconfig is the only way to config “globally static” dns server IPs for system.

Most probably again using NetworkManager. Simply because that is the way this is done (and it originally was designed for just that: moving systems from network to network).

I think I have such a contruction.

Please check. /etc/resolv.conf will be a symlink in your system.
When that is the case, then remove /etc/resolv.conf, create a new one with the resolv configuration you want. I have e.g.

boven:~ # ls -l /etc/resolv.conf 
-rw-r--r-- 1 root root 65 Jun 16  2023 /etc/resolv.conf
boven:~ # cat /etc/resolv.conf 
search xs4all.nl
nameserver 195.121.1.66
nameserver 195.121.1.34
boven:~ #

(The search definition is not needed and when used will of course differ from mine. As will the IP addresses to those you want them.)

As you are using NetworkManager you can create a file /etc/NetworkManager/conf.d/DNS.conf with content

[main]
dns=none

This will stop NetworkManager from setting a DNS-server.

Then you create a file /etc/resolv.conf with

nameserver IP_ADDRESS_OF_NAMESERVER_01
nameserver IP_ADDRESS_OF_NAMESERVER_02
...

Basically the same solution as mine.

It works for me without this, but it maybe better to add this to the solution.

Yes.

I guess so …

From the NetworkManager documentation:

dns Set the DNS processing mode.

If the key is unspecified, default is used, unless /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf, /run/systemd/resolve/resolv.conf, /lib/systemd/resolv.conf or /usr/lib/systemd/resolv.conf. In that case, systemd-resolved is chosen automatically.

default: NetworkManager will update /etc/resolv.conf to reflect the nameservers provided by currently active connections. The rc-manager setting (below) controls how this is done.

dnsmasq: NetworkManager will run dnsmasq as a local caching nameserver, using “Conditional Forwarding” if you are connected to a VPN, and then update resolv.conf to point to the local nameserver. It is possible to pass custom options to the dnsmasq instance by adding them to files in the “/etc/NetworkManager/dnsmasq.d/” directory. Note that when multiple upstream servers are available, dnsmasq will initially contact them in parallel and then use the fastest to respond, probing again other servers after some time. This behavior can be modified passing the ‘all-servers’ or ‘strict-order’ options to dnsmasq (see the manual page for more details).

systemd-resolved: NetworkManager will push the DNS configuration to systemd-resolved

dnsconfd: NetworkManager will push the DNS configuration to dnsconfd

and by default set ipvX.routed-dns to yes, so servers are contacted through right interfaces.

none: NetworkManager will not modify resolv.conf. This implies rc-manager unmanaged

Note that the plugins dnsmasq,systemd-resolved and dnsconfd are caching local nameservers. Hence, when NetworkManager writes /run/NetworkManager/resolv.conf and /etc/resolv.conf (according to rc-manager setting below), the name server there will be localhost only. NetworkManager also writes a file /run/NetworkManager/no-stub-resolv.conf that contains the original name servers pushed to the DNS plugin.

When using dnsmasq,systemd-resolved and dnsconfd per-connection added dns servers will always be queried using the device the connection has been activated on.

My resolv.conf is currently:

/etc/resolv.conf -> /var/run/netconfig/resolv.conf

Looks like a service named netconfig is managing it.

I have package sysconfig-netconfig installed. It has files:

/etc/netconfig
/etc/netconfig.d
/etc/netconfig.d/dns-bind
/etc/netconfig.d/dns-dnsmasq
/etc/netconfig.d/dns-resolver
/etc/netconfig.d/nis
/etc/netconfig.d/ntp-runtime
/etc/sysconfig/network/scripts/functions.netconfig
/sbin/netconfig
...

What’s this “netconfig” ? Is it safe to remove symlink resolv.conf ? Will it be recreated again?

As said, I have it done on a system using NM (and have it also on systems using systemd networking) and it functions as expected. You can read above that @susejunky has the same experience. What sort of reassurance do expect more from us.