Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

At work, we have several sub-domains (test.example.com, dev.example.com, 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
add comment

4 Answers

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

append domain-name "domain.com";

Then restart your network.

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

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 "example.com other.example.com";
# before: request subnet-mask...

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 192.168.10.0; the company has name server 192.168.10.10 and 192.168.10.11 -- but, I run my own name server with a more extensive list of names on 192.168.10.20 (which will forward to 192.168.10.10 and .11 as needed). All my network configurations declare 192.168.10.20 and 8.8.8.8 and 8.8.4.4 (the Google name servers), but, DHCP will tend to override that preference, feeding me 192.168.10.10 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 /etc/init.d/networking restart
share|improve this answer
add comment
up vote 2 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
add comment

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

/etc/dhcp3/dhcpd.conf:

ddns-update-style none;

ignore client-updates;

authoritative;

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 10.0.0.15, 8.8.8.8, 192.168.1.1;

option time-offset 0

share|improve this answer
add comment

Your Answer

 
discard

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.