I need to prepend my /etc/resolv.conf with an entry. My interface is enp0s3. So I created /etc/dhcp/dhclient-enp0s3.conf and added the line:

prepend domain-name-servers

When I restart the CentOS VM, the NetworkManager automatically creates this file: /var/lib/NetworkManager/dhclient-enp0s3.conf

When I cat that I can see that my dhclient-enp0s3.conf file in /etc/dhcp IS being read properly:

[root@localhost network-scripts]# cat /var/lib/NetworkManager/dhclient-enp0s3.conf
# Created by NetworkManager
# Merged from /etc/dhcp/dhclient-enp0s3.conf

prepend domain-name-servers

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;

also request rfc3442-classless-static-routes;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;
also request ntp-servers;

However, when I cat /etc/resolv.conf, the prepended nameserver doesn't appear anywhere. I also ran dig just to test if my internal hostnames would resolve properly, but they don't.

Since the NetworkManager config appears to be generated, where do I go from here?

  • Thank you for the edits @cas. Thanks to your edit, I looked at the markup and learned how to do some of it properly! (Now if I knew how to reference your username properly. :) – alfreema Aug 14 '17 at 1:55
  • 1
    for code and command/file names etc use either backticks or the {} icon in the editor (the latter especially for multi-line blocks of code - or just indent each line by four spaces). @cas works. sorry i can't help with your actual question - my attitude to networkmanager, resolvconf and other things that mess with my hand-crafted configs is apt-get purge with the --nuke-from-orbit-its-the-only-way-to-be-sure option :). – cas Aug 14 '17 at 2:22
  • hahaha ... yeah for an old skool guy like me its painful to learn the new way – alfreema Aug 14 '17 at 3:31

Config statements in dhclient.conf (and other dhcp config files) must be terminated with a semicolon.

So prepend domain-name-servers; should do the trick.

  • Bingo! This indeed did the trick. – alfreema Aug 14 '17 at 18:03
  • Can you do the following? prepend domain-name-servers,;. A simple yes or no will do for me! :) – Fiddy Bux Jan 25 at 22:58

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.