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.

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 10.4.180.250, and at home I need to use 192.168.1.1.

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

prepend domain-name-servers 192.168.1.1;

When I connect to the work network I need to manually change my resolv.conf and change the nameserver to 10.4.180.250. 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 10.4.180.250 again.

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

prepend domain-name-servers 192.168.1.1;
prepend domain-name-servers 10.4.180.250;

or:

prepend domain-name-servers 192.168.1.1 10.4.180.250;

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 192.168.1.1 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 '192.168.1.1' 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

1 Answer 1

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 192.168.1.1 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 "8.8.8.8, 8.8.4.4" in for the two DNS addresses. –  Marty Fried May 1 '12 at 4:39

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.