a cosmological pedestrian

Qemu (kvm) internal network setup

I got a new notebook, a nice Thinkpad T61 with virtualization technology. I need to run some Windows system for development so I’ve decided to use the Kernel based Virtual Machine (KVM). The VMs should communicate over an internal network but should have access to the internet and I want access via network to them. So I setup a bridge with TUN/TAP devices masqueraded to my normal interface.

On the guest you have to set the default gateway to 192.168.100.254 which is the bridge br0 and take a look in /etc/resolv.conf to get the name servers. I run a Windows 2003 Server as a guest which is the dhcp and name server for the other guests (Vista, several Linux installations).

Guest 2:

Note that the VMs have different MAC addresses. It took me a long time to find why I couldn't ping from one guest to another 😉 By the way, one of the guests is running Vista, which runs smoothly on my machine with KVM.

33 thoughts on Qemu (kvm) internal network setup

Thanks a LOT for KVM networking setup advice. Can you please tell me if this will work with Kernel 2.6.22, and not SuSE 2.6.18 ? Something has changed in the bridging stuff starting from 2.6.20 kernel.

I’ve spent some time looking for he reason why I could not ping between guests. When I check the bridge from the host brctl showmacs br0 it shows different addresses. Your wink prompted me to run ifconfig on each guest, sure enough, they are the same mac. Thank you!

Nice tutorial but i can’t make it work on Opensuse 11.
Everything seems fine except an “commit failed on table filter: No chain/target/match by that name” error with firewall (standard setup).
VM can ping the host but can’t go on the internet.
It seems my problem came from MASQUERADE (unable to activate it) but i haven’t found how to solve it.
Any help appreciated.

“Note that the VMs have different MAC addresses. It took me a long time to find why I couldn’t ping from one guest to another”

This did the trick for me as well. I was able to ping one or the other, but not both back to back. It was weird. In retrospect it must have been having a hard time figuring out which “NIC” to route to.

Now I can contact multiple KVM instances over the network without issue. Thanks for the tip!

The br/tap script is awesome, it brings the net devices right up. I can assign the correct IP/netmask/gateway to each VM via the mac address with dhpcd3. The VM’s can ping out to the internet just fine. However I can not ping to the VMs. If I try assigning an ip to qtap1 (ifconfig qtap1 192.168.100.1), then I can ping it, however the network on that VM stops. ifconfig qtap1 0.0.0.0 revives it again. It makes sense that it can’t be pinged because that IP does not show up under ifconfig. This is what a qtap interface looks like that works outbound only:

The only IP that can ping 192.168.100.1 is the XP VM itself. Adding eth0 to br0 changes the IP of br0 to what eth0 was; 192.168.192.125. I have dhcpcd giving the VM on qtap1 an IP of 192.168.192.75. Again, the only IP that can ping 192.168.192.75 is 192.168.192.75. If I could get the Host Linux machine to be able to ping the guests I could set up port forwarding on iptables to resolve the rest.

Can someone help me . I have a Fedora 10 guest running on a KVM with Fedora9 host .
I see vibr0 up and running with a valid ip already . But all my attempts to get the networking going on the guest fails .
what should be the right argument to the -net when i start the guest so that it works .

hi
how to connect OS “ubuntu 9:10” as the host, with Qemu as a guest.?
I can not connect from the host to geust, how to connect?
I use Samba to connect the host to the guest.
I was able to ping from guest to host, but from host to guest can not ping .. why?