How can I add additional search domains to the resolv.conf created by dhclient in CentOS

When my CentOS virtual machine boots it uses DHCP to get an IP address. It also overwrites resolv.conf with the DNS settings provided by the DHCP server. The DHCP server doesn't supply any search domains so I would like to get dhclient to put in a list of search domains when it writes it. How can I configure dhclient to do this?


None of those worked, but the last one was the closest. For Red Hat 6, Use DOMAIN instead of SEARCH as in the example above and the file location is different.

I modified the file /etc/sysconfig/network-scripts/ifcfg-eth0

and changed

DOMAIN=domain.com

to

DOMAIN="domain.com sub.domain.com"

and it all worked.


Also you can add string to /etc/dhcp3/dhclient.conf like this

prepend domain-search "domain1.com", "domain2.com";

Note, that this method works with Debian Lenny and Squeeze, too.