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'm experiencing what appears to be a name resolution issue in Ubuntu 12.04 Server edition when configuring my computer to use static ip.

In /etc/network/interfaces:

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.28
netmask 255.255.255.0
gateway 192.168.1.1

Running $ sudo apt-get upgrade, results in a 'Failed to fetch...':

. . . W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/i18n/Translation-en_US Something wicked happened resolving 'us.archive.ubuntu.com:http' (-5 - No address associated with hostname)
[...]

When I change my /etc/network/interfaces to:

auto eth0
iface eth0 inet dhcp

Everything works fine.

Looking into /etc/resolv.conf provides some more hints.

In cases where I was getting the resolving issue, resolv.conf was empty; no nameservers were specified. Then I changed to DHCP from static and restarted networking; /etc/resolv.conf got changed to: 'nameserver 192.168.1.1'.

Switching back from DHCP to static and restarting doesn't remove the nameserver entry. But when I restarted the system with static set, resolv.conf was empty. When I restart the system with DHCP set, resolv.conf has nameserver 192.168.1.1. So, it appears that the issue is that resolve.conf is not getting written to correctly? Which package/code is responsible for writing to resolv.conf? Is there a particular package that I can take a look at open issues?

UPDATE: istream posted a good article discussing changes to resolve.conf in 12.04. http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/

share|improve this question
2  
If everything works fine when you use DHCP, then what "problem" is it that you want suggestions to "fix". What does you LAN look like? What type of router are you using? (What's at 192.168.1.1?) What DNS servers do you specify when you use a static IP? –  irrational John Apr 29 '12 at 4:56
1  
Updated title to more accurately reflect symptom and adding more findings –  kenneth koontz Apr 29 '12 at 5:20
    
+1 for editing question and title to improve them even though you already had your answer! –  irrational John Apr 30 '12 at 15:53
1  
Added istream's reference to changes in dns in ubuntu 12.04. –  kenneth koontz May 1 '12 at 15:43

4 Answers 4

up vote 15 down vote accepted

As per the resolvconf man page (example provided in man page), add the following to your /etc/network/interfaces under your static configuration:

dns-nameservers [IP address(es) of your DNS]     
dns-search      [your dns-search strings (optional)]
share|improve this answer
    
Thanks for the solution. I'll give it a try. –  kenneth koontz Apr 30 '12 at 1:00
    
Perfect. This works! –  kenneth koontz Apr 30 '12 at 1:12
    
What's odd though is in 11.10 I didn't have to specify dns-nameservers. –  kenneth koontz Apr 30 '12 at 1:12
    
That's right. In 12.04 Ubuntu started using resolvconf to handle resolv.conf. It's resolvconf that reads the dns-nameservers option in /e/n/i. –  jdthood Jul 3 '13 at 16:20

Are you sure that you provided 192.168.1.1 as the value for the DNS when you set up the static IP?

I don't know how to do this from the command line, but using the System Settings -> Network GUI should work too, no? All I'm thinking is that you want something like the screen capture below? Or am I not understanding what you are trying to do?

Network config with static IP, default route, DNS server

Note: Ignore the values in the left-hand window. Those are just my values from DHCP. I didn't bother to save the static config since I was just trying to illustrate what I was thinking.

By the way, I used 192.168.1.1 because that's what you were using. But you could also use the IPs for any valid DNS servers. For example, 8.8.8.8 and/or 208.67.222.222 should also work.

share|improve this answer
    
Thanks for the solution. However, I'm not using a desktop. –  kenneth koontz Apr 30 '12 at 1:00
    
@kennethkoontz I don't understand. Are you using Ubuntu server? If you are not using the typical desktop install of 12.04, please edit your question and add this information to it. –  irrational John Apr 30 '12 at 1:17
2  
Sorry for the confusion. I should have said, "I'm not using the desktop edition. I'm using the server edition." I'll update the question post to remove ambiguity. –  kenneth koontz Apr 30 '12 at 15:45

If you don't want to (or can't) use the Network Manager applet to setup your network settings, I find the proper way to setup a "static" IP configuration, for when you don't have a DHCP server available, is to have a static lease on the dhclient.conf. There you should specify the nameserver that will be written to the resolv.conf file when dhclient falls-back to static.

However, if you don't wan't to get your hands dirty, I still recommend to use the GUI to specify a DNS server address at your connection's IP settings, as in http://askubuntu.com/a/127537/33305.

share|improve this answer
    
Thanks for your solution. –  kenneth koontz Apr 30 '12 at 1:13

The OP is using the server ed. NetworkManager doesn't apply.. though who knows maybe it'll get added just to add complexity to the server.

For that matter why in the world did resolvconf get added to the server ed... WHY!!??!?

Anyway to answer your question add in:

/etc/network/interfaces

something like this:

auto eth0 inet static
     dns-nameservers ns1.mydnsservers.com ns2.mydnsservers.com

The important option is "dns-nameservers".

share|improve this answer

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.