3

Network Manager is posting the correct name servers and search domains into /etc/resolv.conf when I restart the network. However, it is not in an order I like. How can I tell Network Manager to prioritize the nameservers and search domain information of a certain interface over another?

Example:

What I get:

# cat /etc/resolv.conf 
# Generated by NetworkManager
search silatria.org relinq.org pripylen.org acarime.org
nameserver 120.052.0.2
nameserver 120.052.0.1
nameserver 10.66.66.1 

What I want

# Generated by NetworkManager
search acarime.org silatria.org relinq.org pripylen.org 
nameserver 10.66.66.1  
nameserver 120.052.0.2
nameserver 120.052.0.1

acarime.org & nameserver 10.66.66.1 belongs to my network interface enp3s0 120.052.0.2.1, 120.052.0.1 & silatria.org relinq.org pripylen.org belongs to my network interface enp4s0

1
  • It would be nice to have the version of rhel / rpm -q NetworkManager here, e.g. just in case there's a feature for it but it was added later.
    – sourcejedi
    Sep 27, 2018 at 23:13

2 Answers 2

11

Set ipv4.dns-priority of at least one of the profiles, to specify the relative order.

For example

nmcli connection modify "$PROFILE" ipv4.dns-priority 5

and reactivate the connection.

See the manual nm-settings(5) for details.

0
0

It doesn't work.
The nameserver used in the lab still have no priority over the ISP ones that are automatically added to /etc/resolv.conf first.

The only way to do this is to disable /etc/resolv.conf update by NetworkManager and switch either to Wicked and modify the interface file for each dns server in the wanted order; OR modify the /etc/sysconfig/network/config Directive NETCONFIG_DNS_POLICY= to "STATIC" AND furnish the static DNS list with the directive NETCONFIG_DNS_STATIC_SERVERS= with the DNS in your wanted order.

The issue is: with this kind of settings NetworkManager is no more usable as the different profile's DNS list are not added to /etc/resolv.conf.

I can't understand why NetworkManager can not be configured as Wicked interface.

DNS1= mydns
DNS2= ispdns1
DNS3= ispdns2 

I did not found any directive telling the ISP dns servers to be added at the end of the list instead of the top...

What I did after read again the documentation: for a laptop there is two files to be modified:

  • /etc/dhclient.conf
  • /etc/NetworkManager/NetworkManager.conf

First looking at dhclient.conf you have to be sure to uncomment those two lines:

  • prepend domain-name-servers <Your DNS here or 127.0.0.1>;
  • require subnet-mask, domain-name-servers;

If you are using a particular DNS (in my case I handle my own zone with a DNS) you have to write something like

prepend domain-name-servers 192.168.0.3;

If not, default is

prepend domain-name-servers 127.0.0.1;

Second, looking at NetworkManager.conf you have to write something like this:

[main]
plugins=keyfile
dns=default
rc-manager=file
dhcp=dhclient

[connectivity]
uri=http://conncheck.opensuse.org

[ifupdown]
managed=true

...and never forget to commit

systemctl restart NetworkManager

...and more /etc/resolv.conf to see if it has worked as expected ^^

rasalgethi:/etc/NetworkManager # more /etc/resolv.conf
# Generated by NetworkManager
search dezordi.world
nameserver 192.168.0.3
nameserver 62.197.111.140
nameserver 109.88.203.3

These settings could also be relevant for workstations, but they are less likely to be moved from physical networks to others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.