Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I add additional DNS search domains to a network connection which is configured using DHCP?

At work, we have several sub-domains (,, etc), and I've grown tired of perpending the sub-domain every time I need to access a server in one of the sub-domains.

share|improve this question

Here is a complete solution that works at least with 12.04:

sudo nano /etc/dhcp/dhclient.conf
# add next line (alternatively you can use append instead of prepend)
prepend domain-name "";
# before: request subnet-mask...

(you can also use sudo -e /etc/dhcp/dhclient.conf if you trust the default editor)

If you're on any sort of "professional" network that has its own DNS servers and/or if you've setup your own DNS service(s) on said network and also on your workstation, then, you might also want to comment-out this line:

# domain-name, domain-name-servers, domain-search, host-name,

--Doing so lets you use your own domain-name-servers, enabling your personalized domain-search to work much more smoothly, which is probably better than using whatever somebody else has setup for you. E.G.: I'm on the network; the company has name server and -- but, I run my own name server with a more extensive list of names on (which will forward to and .11 as needed). All my network configurations declare and and (the Google name servers), but, DHCP will tend to override that preference, feeding me as the default server. In the end... not requesting those aspects from DHCP makes for a much better network life.

Now restart the networking:

sudo service networking restart

(you can also use sudo /etc/init.d/networking restart with old rc scripts)

share|improve this answer
up vote 4 down vote accepted

Sorin's answer and Ib33X's answer are correct if you are not using the Network Manager. If you are using the Network Manager, then it appears that the Network Manager completely controls generation of the resolv.conf file (which is ultimately what the networking system uses for dns lookups). Changing the dhcpclient.conf is ineffective.

However, there is an (imperfect) solution if you are using the Network Manager:

  1. Make note of the DNS servers setup by DHCP by inspecting the resolve.conf file:

    cat /etc/resolv.conf

  2. Right-click on the Network Manager indicator and select Edit Connections...

  3. Select the connection you want to adjust, and click Edit. Depending on the type of the connection, you may have to switch tabs.
  4. In the Editing dialog, switch to the IPv4 Settings tab (or the IPv6 Settings tab if you're using IPv6).
  5. Change the Method from Automatic (DHCP) to Automatic (DHCP) addresses only.
  6. Copy the DNS servers you saved in step #1 into the DSN servers text box (sue commas to separate multiple entries).
  7. Enter each of the domain names to search by into the Search domains text box.
  8. Click Save...
  9. Disconnect and reconnect the connection.

The downsides of this approach is that you must specify both the DNS servers and the search domain names. It isn't possible to still pull the DNS server addresses from DHCP.

Additionally, the settings must be changed for each connection. I don't know of any way of changing the settings for all connections. However, this is often an advantage. For example, you might want different settings for your home wireless network and your work wireless network.

share|improve this answer

in ubuntu 11.10 edit file /etc/dhcp/dhclient.conf and add this line

append domain-name "";

Then restart your network.

/etc/init.d/networking restart
share|improve this answer

Try below in this case when users gets ip address from dhcp server it gets mulitple dns servers


ddns-update-style none;

ignore client-updates;


default-lease-time 1209600;

max-lease-time 1814400;

option local-wpad code 252 = text;

--- Domain name servers, tells the clients which DNS servers to use.

option domain-name-servers,,;

option time-offset 0

share|improve this answer
The question is geared toward how to configure a connection using DHCP, i.e. it's about a DHCP client, not server. – Josip Rodin Jan 18 at 18:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.