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 just installed my first Ubuntu Server (12.04) instance and immediately ran into the following problems:

  • Running apt-get install or update fails (see below)
  • Running ifconfig produces peculiar IP addresses starting with 10.x.x.x and my router does not see the server at all in its "Attached Devices" page (its a consumer grade Netgear)

When I run apt-get I get 50+ of the following errors:

Failed to fetch <some-http-url>. Temporary failure resolving <blah>.ubuntu.com

I read up on this error for 12.04, and found some similar posts on this forum and on server fault that recommended going into /etc/resolv.conf and adding an entry:

nameserver 8.8.8.8

To my surprise, I found that /etc/resolv.conf was a symlink pointing to somewhere else and I had to delete it first, then create a new one with the entry indicated above.

I restarted the server and tried running apt-get again, same results.

How do I start diagnosing the problem (I'm a relatively new Linux/Ubuntu user)?

Additional details that may help:

  • This is actually a virtual machine running as a VirtualBox guest OS
  • The physical host that is running this VM is my laptop which has a wireless connection; I'm wondering if (somehow) the laptop is getting the network wirelessly, but perhaps either the VBox VM and/or the Ubuntu server OS isn't configured for wireless and so nothing is "getting through"?

Thanks in advance for any pointers!

Edit:

Here is a snapshot of my VM's Network settings (only Adapter 1 has any information populating its fields, so I assume my VM has only 1 adapter):

enter image description here

Here is the output when I run ifconfig from the terminal:

enter image description here

And here is the output when I run route from the terminal:

enter image description here

Running ping google.com:

enter image description here

share|improve this question
    
Could you add the output of dig <blah>.archive.ubuntu.com, dig @8.8.8.8 <blah>.archive.ubuntu.com` and dig @8.8.8.8 archive.ubuntu.com. What is the contents of <blah> anyway? Can you ping <blah>.archive.ubuntu.com from the host of your virtual machine? –  John S Gruber Aug 25 '12 at 18:21
    
The HWAddr is probably OK to show, since each VM gets its own unique MAC address. –  Henrik Aug 29 '12 at 7:08
    
And the fe80::.. address is a link-local IPv6 which I can't contact you on. And the from in the ping is the server that you're pinging, not your gateway, so it doesn't give anything away. –  Henrik Aug 29 '12 at 7:10

8 Answers 8

up vote 14 down vote accepted
+50

To make it a short answer: It's a network issue.

The way I see the scenario is like this:

enter image description here

Now to correctly see where the problem is, in this case, we need to first check from the outer networks to the inner networks.

  1. Make sure the router has internet. You can use the same host or another device connected to it to check this.

  2. Make sure the Host has internet via the Router or any other source. To check simply send a ping to google.com for example like so: ping google.com.

If Point 1 and 2 are good (Your router is working great and has internet and your host has internet) then we proceed with the Guest and Virtualbox. It may be good to read how Wireless support is handled in VirtualBox by reading Wifi card on an virtualbox's ubuntu

We need to know the following information first:

  • There is no wireless connection inside the virtualbox environment. All "virtual" connections are in reference to cable/wired connected ones. So when you enable a Network card in your virtual guest, it is a virtual wired connection you are creating not a virtual wireless one.

  • The virtual connection from Host to Guest is independent of the type of connection your Host is connected to (Physically connected). If the host is connected via a wired or wireless connection, it does not matter or affect the virtual connection made from the Host to Guest because wired and wireless connections are used in the same way inside the Guest. Something similar to the following image:

    enter image description here

  • If your host does not have internet access, your guest will not have it. The same goes that if your host has internet access and your connection from Host to Guest permits sharing the internet, then the guest will most probably have internet also (Default behavior with Virtualbox).

  • I will be using Virtualbox 4.1.20 which looks different from the one you are using (Might be same, I do not know). I will add the network image just to help and show the differences:

    enter image description here

  • I will be using Ubuntu 12.04 as host and as Guest (This works the same in 12.10 or 13.04). In cases where Windows is the host you need to make sure the firewall is not blocking a particular port the guest will be using.

  • I assume that the Host is not using a proxy, just connected directly to the router via a wireless/wired connection.

  • The output from the Guest is the following with ifconfig and route:

    enter image description here

Now to the points you want to solve:

  1. Configure the network for the VM Ubuntu Server
  2. Get VM to connect to internet
  3. Get router to see the VM

Let me first mention that point 3 will be impossible unless the Virtualbox guess supports port forwarding. Your router will only see transfers made from your Guest as if they were transfers made from the actual Host. So without forwarding (Which is somewhat supported on the latest version) the router will never see the VM, only the Host.

There are of course ways to go around this like telling the host to forward stuff to the guest via the virtualbox engine. Or configuring (Easier I think) the guest for port forward. For example this:

enter image description here

So with this in mind we do the following in the Guest:

  1. Test if the guest has Internet access with the common ping google.com approach.

    If ping works then we know that an internet connection exists. The problem might be resolving the destination site.

  2. Try the following:

    /etc/init.d/network restart and/or dhclient

  3. Verify that /etc/network/interface is correct. My example would be:

    enter image description here

  4. Change the Adapter Type in the Network Options in the Virtualbox Configuration Window.

  5. Test out if the Ubuntu Desktop client or another OS works correctly. (Right now I only have the Desktop iso image of 12.10 and 12.04).

share|improve this answer
    
Wow, thanks @Luis Alvarado for such a thorough answer (+1). A few followups for each of your 5 suggestions: (1) ping google.com on the guest VM actually seems to be running normally, so what other tests could I perform to confirm I am actually getting internet? (2) I only have an /etc/init.d/networking (not network) service, and when I try to restart it I get a warning that its deprecated. (3) My etc/network/interface file looks exactly like yours. (4) What Adapter Type should I try, and what subsequent settings? (5) To be determined... –  zharvey Aug 25 '12 at 2:22
    
I think the first thing I need confirmation of is item #1: that fact that ping seemed to be kicking off and behaving like it is running fine. I will update my original question w/ a screenshot of the output, please let me know if this is "normal" ping output and indicative of a successful inet connection. –  zharvey Aug 25 '12 at 2:23
    
Sorry, it looks like offering the bounty dropped me below the minimum upvote threshold of 15, so it looks like I can't upvote your answer, otherwise I would :-/ –  zharvey Aug 25 '12 at 2:29
    
Hi. Let me make it short for the comment: 1. If your ping is working then VM has correct connection to Host. 2. Do not worry about the /etc/network stuff, if your interface is correctly configured as you mentioned and ping works then it does not matter. 3. Don't worry about the adapter since it was only if the other ones did not work. What I would include would be the OS that you are using as Host and if this Host has some kind of Firewall on it. Can you also virtualized an ISO image of Ubuntu desktop and see if the live cd has internet connection? –  Luis Aug 25 '12 at 16:28
    
Today at last I managed to download the Ubuntu Server 12.04.1 and did a test with it. It connected correctly. So I am more oriented into your host creating the problem or a misconfiguration when you install the server. I am leaning more towards the host denying something since for what I could read from you, you have some experience with computers and the Ubuntu Server is pretty easy to use. –  Luis Aug 27 '12 at 1:09

This is most definitely a network issue. To confirm that, try first pinging IPs inside your local network:

ping 10.1.1.1

(which is likely to be your router's IP)

and then pinging IPs in the "outside world"

Also, even if you're running your VM on a laptop which connects via wifi, you don't need to configure wifi on the guest machine - VirtualBox emulates a "wired" network adapter, so your guest OS thinks it runs on a machine which is connected to LAN with a cable.

Configuring networking in VirtualBox is a broad topic (although typical setups normally work out of the box), you need to make sure your VM has a network adapter configured in VM's properties etc.

See http://www.virtualbox.org/manual/ch06.html for more details.

The default VirtualBox setup (NAT) creates a "private" network between your host and guest machines, with the host machine forwarding all traffic coming from the guest machine outside and sending responses back to the guest (similarly to how your router connects your laptop to Internet). The guest does not have an individual IP address in your LAN and can not be accessed from outside your laptop, but you can access Internet from the guest because packets are translated into the LAN by the host machine and then into internet by the router. This explains why you don't see a separate device in your router's settings

share|improve this answer
    
Thanks for the awesome answer @Sergey (+1) - but I'm still a little confused! You say that the VM running on my laptop can access Internet because packets are translated into the LAN from the host machine. So if that's the case, why doesn't apt-get work? If a VM can receive an inbound network connection, apt-get shouldn't have a problem downloading content from remote URLs...yes? Thanks again! –  zharvey Aug 22 '12 at 16:40
    
Or is it that the VM can only receive packets from inside the private LAN (between the host OS and all of its guests)? –  zharvey Aug 22 '12 at 16:41
1  
@zharvey: I was referring to a host/guest with properly configured NAT networking (which is usually the case when you create a VM with the default settings) - I suspect that your VM may be mis-configured somehow. Please go into your VM's settings and check that you have a network adapter, that the virtual ethernet cable is "plugged in", that the networking type is set to NAT. Maybe add some screenshots to your question. Then start your VM and run ifconfig and route commands there and also post the results. –  Sergey Aug 22 '12 at 22:07
    
Thanks again @Sergey (+1 again) - please see attached screenshots and let me know if anything jumps out at you! Thanks again! –  zharvey Aug 23 '12 at 10:25

Here's what I notice from your question:

  1. The message is: "Failed to fetch . Temporary failure resolving <blah>.ubuntu.com"
  2. You can reach google.com just fine.

I'd say that there is a problem with the domain name service in resolving that address, not in your computer. There's nothing special about doing a domain lookup as opposed to doing a ping. Your network must be working, however it is configured.

I suggest that you change your software sources to use a different Ubuntu archive, perhaps just archive.ubuntu.com.

share|improve this answer
    
Actually I have to agree. If the OP can ping google and browse the internet (needs to be checked) then he has a working connection. The server selected in sources would appear to be the problem, not the internet connection. –  fabricator4 Aug 25 '12 at 20:37

/etc/resolv.conf is symlink and will be symlink after you remove it, because resolvconf always resets it.

If you want to use Google DNS, add these lines to your /etc/resolvconf/resolv.conf.d/head :

nameserver 8.8.8.8
nameserver 8.8.4.4

If you want to get your router to detect your virtual machine, you should use the "Bridged adapter". In Network adapters, change the box, which says "NAT" to "Bridged adapter". If you set it as bridged adapter, the virtual machine gets IP etc. from DHCP server. If your router doesn't have one or you don't have one in your network, then Virtualmachine cannot get the settings automatically and you must specify them by hand.

I'm not sure about that .ubuntu.com not resolving, but I would suggest you to try another mirror.

I use mirrors.ubuntu.com/mirrors.txt, which always contains the nearest possible mirrors. To use it, add these lines to your /etc/apt/sources.list:

deb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse
deb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse

If you want to have backports too, add also these lines:

deb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse
For me that file contains: ``` http://ubuntu.trumpetti.atm.tut.fi/ubuntu/

http://www.nic.funet.fi/pub/mirrors/archive.ubuntu.com/

http://mirrors.nic.funet.fi/ubuntu/

http://archive.ubuntu.com/ubuntu/ ```

because I am in Finland.

share|improve this answer
    
If everyone can edit and are better with markdown than me, please feel free to fix that mess, which I caused with markdown above. –  Mikaela Aug 29 '12 at 6:33
    
This is a flawed answer. (1) If /etc/resolv.conf was a symlink and you delete this symlink, resolvconf will not re-create the symlink. (2) The file /etc/resolvconf/resolv.conf.d/head is not the right place to put nameserver options. Nameserver addresses should go in /etc/network/interfaces if you are using ifup or should be entered into NetworkManager if you are using NetworkManager. If you really, really want to include nameserver address 8.8.8.8 statically in resolv.conf then put "nameserver 8.8.8.8" in /etc/resolvconf/resolv.conf.d/base. –  jdthood Oct 29 '12 at 10:37

This is what worked for me:

trying to set up wireless did not work
adding network property details on Ubuntu VM and changing on windows the same did no work

though host was wireless, guest (ubuntu VM) acts as if it is connected by virtual cable so following solved the problem:
Ubuntu VM window > Devices > Network > Network Settings ... > check the box for Cable Connected

share|improve this answer

This link has a tutorial on how to connect to wireless networks using command line: http://www.linuxjournal.com/content/wi-fi-command-line.

However, you might want to restore your resolv.conf file.

share|improve this answer
    
Is it really that simple? Ubuntu Server doesn't ship with wireless autodetect? So when it shows the IP address is that just a system default or something? Any idea how I could restore resolv.conf? Thanks (+1)! –  zharvey Aug 22 '12 at 3:26
    
@zharvey: this is unlikely to fix your problem as you DON NOT need to configure wi-fi on the guest machine. –  Sergey Aug 22 '12 at 3:32

Ok. A small question! Can you use the Internet on your browser? If yes, try this: Try to change the server selecting update manager, definitions, downloading from, then select a server more near you. and then try to check your updates again.

I think its a bug. Please try and tell me if it works.

share|improve this answer

I also run ubuntu desktop and server on VirtualBox. And i was having the same issue like you. My workaround was not to set up network card in VirtaulBox as NAT, but as Bridged Adapter.

I hope it help!;)

PS: from the link Serghey posted (VirtualBox manual):

"Bridged networking This is for more advanced networking needs such as network simulations and running servers in a guest. When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack."

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.