Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I installed Windows 7 as a guest in KVM running on Ubuntu 12. Windows seems to be running fine with the exception that it can't access any external domains or IPs.

The guest can ping the host's IP and the host can ping the guest's IP, but that's it.

I used the default NAT setup, which others have reported should work. What can I do to fix this?

Edit: I also have VirtualBox running on the same host, also running a Windows VM, and it's internet works just fine.

Edit: The Ubuntu host's routing table:

user@localhost:~$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth2
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

The virbr0 is some old bridge leftover from when I tried setting up bridging in Virtualbox, but it's no longer used since Virtualbox works find with NAT. I did try using it with KVM, but had no success.

share|improve this question
    
Is IPv4 forwarding enabled on the Ubuntu box? ( cat /proc/sys/net/ipv4/ip_forward ) –  Niall Byrne Oct 6 '12 at 21:53
    
Check what dns server it is using. Try pinging the google opendns 8.8.8.8 from your windows 7 guest. –  lbanz Oct 7 '12 at 19:58
    
@NiallByrne, Yes. –  Cerin Oct 8 '12 at 15:09
    
The Windows guest is using 192.168.122.1 as its DNS server. The guest can't ping the Google opendns IP. –  Cerin Oct 8 '12 at 15:26
    
What does the routing table look like on the ubuntu box and what ip's are you using in your natted KVM and Virtualbox setups (is the virtualbox VM natted too ?) –  Niall Byrne Oct 9 '12 at 1:50

3 Answers 3

After some discussion on the oftc-channel #virt, @laine pointed me to the solution.

Apparently, the resolv.conf file is missing on ubuntu 12.04 (at least on my installation of linux mint 13). It is replaced by some resolvconf directory tree.

To enable internet on the guests: I had to

  1. sudo iptables --flush => on the host, might be obsolete, I don't know that. It cleared some rules.
  2. add "nameserver8.8.8.8" to /etc/resolv.conf
  3. reboot

After that, it worked

EDIT: note that step 2 was also performed on the host. I think it was linux mint (ubuntu 12.04), which was missing the /etc/resolv.conf file.

share|improve this answer
    
I tend to add one more step to this, which is chattr +i /etc/resolv.conf to stop pesky resolvconf scripts screwing with it. –  Tom O'Connor Nov 12 '12 at 0:07

Is there some reason you can't use bridged networking? I always run in bridged mode when the VMs need to have access to the Internet, and I generally recommend it (you haven't given any reason why bridged mode might not be a good idea). The VMs are then treated as first-class citizens as far as network connectivity is concerned.

share|improve this answer
    
I'm running this on a laptop with a wireless ethernet connection. Most documentation I've read about bridging mentions that most wifi Linux drivers don't support bridging (or not very well). I did try creating a bridge with my wifi ethernet interface, but it caused gnome-shell to crash and burn. –  Cerin Oct 9 '12 at 12:19

You're using the wrong NIC on the VM. I used to run xp/7/8 on ubuntu 12.04 on Oracle virtualbox without issue. don't use nat host only type NICs. use the option that gives you a physical address on the network, that way you have a single hop to the gateway.

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.