How to allow guest OS to access Internet in qemu?

28,719

My second question is - is there an easier way to configure all of this to allow simple internet access to guest os?

You don't (or, at least, shouldn't) need to manually configure anything for simple internet access; QEMU automatically handles it. It has some limitations, such as not supporting the ICMP protocol (used by ping), not being visible to the external network, nor being able to talk to other virtual machines run the same way, but it works well for simple usage. See the Arch Wiki for more information.

Share:
28,719

Related videos on Youtube

yuusakuri
Author by

yuusakuri

My name is Boda Cydo. I am from Africa but now live in Washington DC.

Updated on September 18, 2022

Comments

  • yuusakuri
    yuusakuri over 1 year

    I've created a Windows XP image and I'm booting it with qemu. When using "user mode networking" via -net user, my guest os (windows xp) gets the 10.0.2.15 IP assigned and I can ping 10.0.2.2 so Windows drivers are installed correctly.

    Unfortunately I'm unable to access anything else. I read tutorials and I found that "user mode networking" doesn't forward connections to internet, and I've to use either TAP device, or Bridge device.

    I'm unfamiliar with these devices and the tutorials are very confusing and complicated.

    One of tutorials suggested that I use qemu-bridge-helper. I configured /etc/qemu/bridge.conf to allow br0 bridge device and created the br0 device via brctl addbr br0.

    I followed the tutorials and booted my winxp this way:

    qemu-system-x86_64 --enable-kvm -m 2048 \
      -drive file=winxp.img,if=virtio \
      -net nic,model=virtio \
      -net bridge,br=br0
    

    The image boots nicely but I don't get an IP address. The reason is that Windows is configured to use DHCP but "br0" is not providing a DHCP address as it's just a bridge interface (somehow tied with tap0 but I'm not sure what that means).

    My question is - how do I configure "br0" to give addresses to winxp over DHCP? Do I've to run a dhcp server on tap0 interface? How is br0, tap0 and eth0 related? (eth0 is my static IP interface, the only internet interface.)

    My second question is - is there an easier way to configure all of this to allow simple internet access to guest os?

  • Lukas Kalbertodt
    Lukas Kalbertodt almost 5 years
    "not supporting the ICMP protocol" -- thanks for mentioning that! I tested my internet connection via ping, assumed internet does not work and proceeded to try to "fix" it for hours. Thanks!