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?


What I get:

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

What I want

# Generated by NetworkManager
search acarime.org silatria.org relinq.org pripylen.org 

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

  • 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
    Commented Sep 27, 2018 at 23:13

2 Answers 2


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.

  • You're my hero of the day. 3 hours today and a multiple of that on others that ended in aahhh F....It... Commented May 7, 2023 at 23:18
  • I had to use: .. +ipv4.dns-priority 5 (with +, otherway it breaks my wireguard)
    – Gelldur
    Commented Oct 31, 2023 at 11:00

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>;
  • 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;

If not, default is

prepend domain-name-servers;

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




...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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .