I am lost on this. Basically I am trying to set up a Ubuntu Server 10.10 as a virtual machine by using KVM. Everything went smoothly and I can even sudo-apt get packages from the guest OS.

Now, because of my limited networking & administrating experience, I cannot find out how I can connect to the VMed Ubuntu Server from the host OS. When I did ifconfig the only address that I saw started with 127.0.x.x which means there is no IP for outside communication.

How can I do so? I tried to ping/telnet but apparently, there is no proper IP for that.

The reason for me to do this, is to transfer some of the application into the VM server and run some tests on it.

I googled it out but apparently, I cannot find any useful guide.

Thanks in advance.

P/S: The host OS is ubuntu 10.10 desktop edition


Are you using bridged networking? This is usually the easiest way to set up networking in KVM under Linux. I would assume one reason you might be able to have network connectivity on the guest VM without having set up its IP explicitly is that it's getting a valid IP from a DHCP server, either through NAT from the host OS or from a DHCP server on your network. However, usually you choose network interfaces during install (using virt-install, KVM, etc) to make available to the guest. How did you install the guest OS?

To find its IP, you would need to run ifconfig on the guest, not the host. If you get an IP on the same subnet as your host OS's IP, you can connect to it using that IP -- in that case treat it like it's any other computer on the network.


Per my comment below, to set up bridged networking, on the host OS edit the /etc/network/interfaces file to look like the following:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address           #change these 5 lines
        network            #to match your IP/network info
        netmask          #
        broadcast        #
        gateway            #
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

if you use DHCP to get your IP, set the br0 section to look like this instead of the last part above:

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

You can set the network when you install the guest using libvirt:

sudo virt-install --vnc -n vm1 -r 1024 --vcpus=1 \
--os-type=linux --os-variant=ubuntulucid  --hvm --accelerate \
--network=bridge:br0 -c ~/isos/ubuntu_lucid_amd64.iso \
-f ~/vms/vm1ubuntu.vm -s 50

This would install an Ubuntu Lucid guest named 'vm1' from an iso file, giving it 1 vCPU, 1024MB of RAM, and a 50GB qcow2 disk image file.

If you've installed your guest with this or another method, you can run sudo virsh dumpxml vm1 > vm1.xml to dump information about that guest, edit the file to change a setting, and use sudo virsh create vm1.xml to recreate the guest with the new settings (you'll need to run sudo virsh destroy and sudo virsh undefine in between or use some other method to stop and remove the guest in its current format before re-creating).

  • no, I am using the "user mode network stack". I installed the guest OS by using AQEMU. I tried to use bridged networking but apparently since I m using Huawei wireless modem for internet access, it is not working, at least, the way I understand it. – Songbreaker Apr 17 '11 at 4:40
  • @nedm: I tried to unplug the wireless modem , but its not helping as I tried. The guest ifconfig yielded two connection, lo and eth0(with inet addr:, mask: while the host os ifconfig yielded br0 (with inet addr:, mask eth0(no ip), lo, ppp0(,mask all 255) and virbr0(, mask 255.255.255). I tried to ping/ssh on ip addresses on host os from guest os, but no luck. Same vice versa. Could you please elaborate more on how to set the IP explicitly? – Songbreaker Apr 17 '11 at 4:49
  • Now, my understanding on QEMU networking is getting better. I have established bridged networking. But now, how do I connect the host and guest OSes? Telnetting into the host from guest is fine; i can telnet using the bridged IP now. But the other way is not possible. It says something like out of reach. – Songbreaker Apr 19 '11 at 0:32
  • That looks like NAT mode to me given the 10.0.2.X IP in your second comment and that you can connect from the guest, but not to the guest. I've edited my answer with how to modify this to ensure you have bridged networking running. – nedm Apr 20 '11 at 3:04
  • Actually I installed the vm using AQEMU. Anyway I am reinstalling the vm using the guide you gave above and during the installation, it says something like "Network Configuration Failed- No DHCP configuration or the network is slow etc". So I skipped the network settings part. Is this ok? – Songbreaker Apr 22 '11 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.