Tuesday, June 26, 2007

How to add search domains in Ubuntu


I have lived with the following annoyance for the past year. At work I can't resolve various server names without editing the /etc/resolv.conf file and adding the following
search www.example.com
No big deal, except every time you connect to a new network this file is automatically overwritten with information received from DHCP. This is really annoying and after adding that line by hand for a year I finally got a solution!

It is really simple. Edit /etc/dhcp3/dhclient.conf and add the following line in there:
prepend domain-name "thoughtworks.com ";
duh! Many thanks to my friendly neighborhood sysadmin and this webpage

3 comments:

Unknown said...

you can also use the /etc/resolvconf/resolvconf.d head or tail file

Bill Zhao said...

Thanks alot, I solve my problem as well as per this post

Jure Merhar said...

Thanks for this post.

What I actually needed to add was this though:

supersede domain-name "mydomain.com";

Otherwise my domain would just get prepended to the original one like this: mydomain.comoriginaldomain.com