how to connect multiple kvm/qemu VM guests in to a subnet
Is the Debian6 VM configured to forward IP packets ?
Have you configured default routes on the other 2 VMs pointing to the VM Debian 6 ?
If yes, could you try changing the internal lan to another major subnet other than 10.x.x.x, i.e. 192.168.1.x/24 ?
After you use the new internal subnet, you will need to configure a route to the internal subnet 192.168.1.x on your internet router pointing to the Debian6 VM.
Related videos on Youtube
b1tH1de0
Updated on September 18, 2022Comments
-
b1tH1de0 over 1 year
I want to setup a simple subnetwork of KVM/QEMU guest VMs living on a single host (Fedora 19) for testing purposes. The subnet would contain 3 servers:
1 Debian 6.x
eth0 ip: 10.0.0.7 eth1 ip: 10.0.2.1
2 Debian 7.x
eth0 ip: 10.0.2.2
2 CentOS 6.x
eth0 ip: 10.0.2.3
and (possibly) multiple clients.
The idea is to simulate a subnet where only one VM (#1 from the above) is connected to WAN network and serves as a gateway/router for the rest.
I'm currently experimenting with a setup based on the one described here:
http://csortu.blogspot.com/2009/12/building-virtual-network-with-qemu.html
But, for the moment, can't seem to provide other VMs besides #1 with WAN connectivity.
I have two qestions: 1. Is there an easier solution? 2. (if not) how can I make other VMs connect with the outside world using VM #1 as gateway.
P.s. I should probably mention, that all VMs connect with each other, but WAN access is available only on #1.
EDIT: As requested, here is the complete network config.
HOST: Fedora 19 x86-64 directly connected to my home router (10.0.0.1) on 10.0.0/24 network (only print relevant interfaces)
3: wlp12s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 0c:60:76:64:c5:9d brd ff:ff:ff:ff:ff:ff inet 10.0.0.3/28 brd 10.0.0.15 scope global wlp12s0 valid_lft forever preferred_lft forever inet6 fe80::e60:76ff:fe64:c59d/64 scope link valid_lft forever preferred_lft forever 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN link/ether 2e:47:f7:fc:f2:fb brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever
VMs:
1 - Debian 6 amd64 with two NICs configured (one for access to my home network via the HOST, and the second for internal, VM-only 10.0.2/24 subnet)
Here is the startup command (I've changed the default QEMU user network config to reflect my home network and redirected HOST port 2222 to access port 22-ssh on the GUEST)
qemu-system-x86_64 -cpu host -enable-kvm --name Debian6-amd64 -hda VMs/Debian6/sda.img -hdb VMs/Debian6/sdb.img -net nic,vlan=1 -net user,vlan=1,hostfwd=tcp::2222-:22,net=10.0.0.0/24,dhcpstart=10.0.0.7 -net nic,vlan=2,macaddr=52:54:00:00:02:01 -net socket,vlan=2,listen=localhost:1234 -m 512 -boot c -nographic
and here are the interface configs:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff inet 10.0.0.7/24 brd 10.0.0.255 scope global eth0 inet6 fe80::5054:ff:fe12:3456/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:00:02:01 brd ff:ff:ff:ff:ff:ff inet 10.0.2.1/24 brd 10.0.2.255 scope global eth1 inet6 fe80::5054:ff:fe00:201/64 scope link valid_lft forever preferred_lft forever
2 - Debian 7 amd64 with one NIC configured (internal 10.0.2/24 subnet)
The startup command:
qemu-system-x86_64 -cpu host -enable-kvm --name Debian7-amd64 -hda VMs/Debian7/sda.img -hdb VMs/Debian7/sdb.img -net nic,vlan=2,macaddr=52:54:00:00:02:02 -net socket,vlan=2,connect=localhost:1234 -m 512 -boot c -nographic
and the interface config
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:00:02:02 brd ff:ff:ff:ff:ff:ff inet 10.0.2.2/24 brd 10.0.2.255 scope global eth0 inet6 fe80::5054:ff:fe00:202/64 scope link valid_lft forever preferred_lft forever
3 - CentOS 6 x86-64 with one NIC configured (internal 10.0.2/24 subnet)
The startup command:
qemu-system-x86_64 -cpu host -enable-kvm --name CentOS6-x86_64 -hda VMs/CentOS6/sda.img -hdb VMs/CentOS6/sdb.img -net nic,vlan=2,macaddr=52:54:00:00:02:03 -net socket,vlan=2,connect=localhost:1234 -m 512 -boot c -nographic
and the interface config
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:00:02:03 brd ff:ff:ff:ff:ff:ff inet 10.0.2.3/24 brd 10.0.2.255 scope global eth0 inet6 fe80::5054:ff:fe00:203/64 scope link valid_lft forever preferred_lft forever
-
Michael Hampton over 10 yearsAnd how did you set up the networking?
-
b1tH1de0 over 10 yearsSimilar to the setup described in the link I provided. Used 2x NICs with separate QEMU "VLANs" on VM #1 and 1x NIC with the second QEMU "VLAN" only on other VMs.
-
Michael Hampton over 10 yearsJust providing a link is not going to work. You need to describe it exactly as you have it.
-