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 I modified the file and changed
to
and it all worked. |
|||||||||
|
|
Also you can add string to /etc/dhcp3/dhclient.conf like this
Note, that this method works with Debian Lenny and Squeeze, too. |
||||
|
|
|
I managed to work this out in the end. I added a line like the following to
|
|||
|
|
|
This is mostly a note for RHEL7 to reduce trial and error. Dean's answer of using DOMAIN="domain1.exmaple.com domain2.example.com" in /etc/sysconfig/network-scripts/ifcfg-device.conf works. An interesting note is the host's domain that the connection gets from DHCP is always prepended to the search path, even if you leave it out of DOMAIN= or put it later in a list for DOMAIN=. It looks like /sbin/dhclient-script has a bunch of logic in there related to this. In my testing, I found that Philip's suggestion of using /etc/dhcp/dhclient-device.conf also works, although there is some strange behavior with that, most likely due to that same logic in /sbin/dhclient-script that tries to move things around. For instance, neither supercede or prepend work as expected, the host's domain will be first. As a side note on this method, /var/lib/NetworkManager/dhclient-device.conf is the generated NetworkManager file and is used by the client. If you have a file in /etc/dhcp/ that gets read in, you'll see it pasted at the top of the file and a few extra options added below. |
|||
|
|
|
On CentOS 6, I'm using the following file to add my preferred DNS search domain:
This file is the first that's checked for in
See also https://serverfault.com/questions/231076/configuring-dhcp-on-rhel-6 |
|||||
|
|
The After examining the
Then:
|
||||
|
|
|
For anyone going through Fedora / Red Hat's rather opaque pile of scripts, the answer, at least on Amazon's latest AMI, it is /etc/dhclient-eth0.conf (and not the decoy empty folder at /etc/dhcp/ ). The file is not present and will need to be created |
|||||
|
|
In Fedora 19 add next lines to
Work fine with NetworkManager. Details see: |
|||
|
|
|
Add to the dchp server conf (isc dhcpd):
Where domain1.com,etc.. are the domain suffixes you want added to the resolv.conf file on each client. |
|||
|
|
|
Since I don't see this answer and it worked for me (while the others didn't), here it is: edit |
||||
|
|