Home » Questions » Computers [ Ask a new question ]

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

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?

Asked by: Guest | Views: 381
Total answers/comments: 4
Guest [Entry]

"I managed to work this out in the end. I added a line like the following to /etc/dhclient-eth0.conf

append domain-name ""example.com"";"
Guest [Entry]

"The /etc/dhclient-eth0.conf answer didn't work for me. I don't have an /etc/dhcp3 directory so I didn't think that was likely to work either.

After examining the /sbin/dhclient-script file (which creates /etc/resolv.conf on my Centos 5.6 system), I added the SEARCH line below to /etc/sysconfig/networking/devices/ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=08:00:24:61:17:AC
ONBOOT=yes
TYPE=Ethernet
SEARCH=""example.com sub1.example.com sub2.example.com""

Then:

# ifdown eth0
# ifup eth0
# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search example.com sub1.example.com sub2.example.com
nameserver 10.1.0.11"
Guest [Entry]

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
Guest [Entry]

"In Fedora 19 add next lines to /etc/dhcp/dhclient.conf

# /etc/dhcp/dhclient.conf

interface ""p2p1""
{
supersede domain-name-servers 8.8.8.8, 8.8.4.4;
append domain-name "" mydomain.net example.com"";
}

Work fine with NetworkManager. Details see: # man dhclient.conf"