Apr 172012
 

If using DHCP on Ubuntu to populate your network configuration, there can be times when customising the DNS information can seem a little difficult.

In my case, the DHCP server was supplying my desktop /etc/resolv.conf with the DNS information:

nameserver a.b.c.d
nameserver a.b.c.e
domain example.com
search example.com

This file gets auto-generated every time the NetworkManager restarts the interface, so there’s no point editing it by hand.

The problem was, I was mostly using servers in the subdomain “dev.example.com”, and wanted this added to the search list, so I didn’t have to type the “.dev” in every time. I’m lazy like that.

The fix is to edit /etc/dhcp/dhclient.conf, or /etc/dhcp3/dhclient.conf:

sudo vi /etc/dhcp/dhclient.conf

and add the following line:

append domain-search "dev.example.com";

Then, restart the dhclient process to update:

# pkill -HUP dhclient

The network interface will bounce, and when it comes back up, the extra domain-search “dev.example.com” will have been added to /etc/resolv.conf

To add extra domains to the search path, just add extra “append” lines.


Matt Parsons is a freelance Linux specialist who has designed, built and supported Unix and Linux systems in the finance, telecommunications and media industries.

He lives and works in London.