Is it possible, and how do I configure CentOS 6.6 so that /etc/resolv.conf will obtain its configuration via DHCP, but will also have additional domain names added to the search line?

Bonus points if I can also add a domain line to that file.

Oh, I don't use NetworkManager.

All searches so far have turned up instructions for disabling the modification of /etc/resolv.conf by DHCP, and manually setting it up, but I think this defeats the purpose of DHCP.

1 Answer 1


In your /etc/sysconfig/network file, add:



DOMAIN="example.com sub.example.com"

Settings in the file /etc/sysconfig/network apply to all network interfaces. Since all interfaces are usually part of the same domain, it is best to place the DOMAIN or SEARCH setting in this file. In the unusual case that the system has multiple interfaces, and the search domain is only valid for one of the interfaces, put the settings into the appropriate file for that interface, such as /etc/sysconfig/network-scripts/ifcfg-eth0.

The domain and search directives in resolv.conf are mutually exclusive. They've been going back and forth upstream on how exactly to handle it. If DOMAIN doesn't work, try SEARCH.

  • 1
    I added DOMAIN="foo bar baz" to the end of /etc/sysconfig/network-scripts/ifcfg-eth0 and then did sudo /etc/init.d/network restart and the DNS domains where not added to /etc/resolv.conf
    – Ishq
    Mar 31, 2015 at 18:53
  • Using SEARCH in ifcfg-eth0 worked. DOMAIN did nothing. Thanks!
    – Ishq
    Mar 31, 2015 at 19:05
  • 1
    It seems that even minor Linux variants behave differently, so one of the options over there might work for other folks. superuser.com/questions/110808/…
    – Ishq
    Mar 31, 2015 at 19:08
  • Thank you very much! "Settings in the file /etc/sysconfig/network apply to all network interfaces." This is exactly the information I was looking for!
    – FCTW
    Oct 24, 2016 at 14:16
  • Adding DOMAIN=... to /etc/sysconfig/network-scripts works for Fedora28 and generates an entry search ... in `/etc/resolv.conf.
    – nimrodm
    Oct 10, 2018 at 15:21

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