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

I use Ubuntu 12.04 on my work laptop. Currently I live abroad and I only have this one computer, and I take it home after work to use as my personal computer. The problem is that the nameserver used on the office network differs from the nameserver on my own network at home.

At the office I need to use, and at home I need to use

My /etc/dhcp3/dhclient.conf has this line in it:

prepend domain-name-servers;

When I connect to the work network I need to manually change my resolv.conf and change the nameserver to Then I connect to another office in another country with a VPN, and the resolv.conf gets reset and I need to change the nameserver back to again.

Is it possible to always have both nameservers in my resolv.conf by using multiple prepends?

prepend domain-name-servers;
prepend domain-name-servers;


prepend domain-name-servers;

Are there disadvantages to having a nameserver that is "invalid" for the current network? It there a better way to do it?

share|improve this question
If it's invalid , it won't get used. As long as you can't access at work , what you are doing is right – warl0ck Apr 25 '12 at 2:22
Have you tried having two 'named' connections, with differnet details for you two sites? Is the '' your own (wireless) router? – david6 Apr 25 '12 at 5:49
@david6: What are named connections? Yes, that's my own wireless router. – Oscar Apr 25 '12 at 6:01
see my answer .. – david6 Apr 25 '12 at 6:45

Add two connection profiles: (eg. repeat twice.)

Setup a new interface with the settings you need:

  • (right-click) on Network icon (up/down arrows)

  • select Edit Connections

  • first select tab for 'Wired' or 'Wireless', then click on 'Add'

  • enter the name for this new connection (eg. 'home' / 'office')

  • select 'IPv4 settings'

  • method: 'Manual'

  • DNS Servers: (add for 'home')

  • click 'Save'

Note: You may need to manually assign a IP address, mask, etc..

share|improve this answer
I do it this way. But rather than selecting "Manual", I choose "Automatic (DHCP) addresses only", and fill in only the DNS servers, but not the IP addreses; those are set by DHCP. I have one set to use Google's DNS server, so I put "," in for the two DNS addresses. – Marty Fried May 1 '12 at 4:39

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.