I'm trying to setup a lab in KVM on my Ubuntu Linux machine. My goal is to create a test lab in which I can test the configuration of my physical router for my home network, before moving it into production. Of course the configuration on the physical network will differ a bit, but much of it can be tested in the lab environment first.
I watched a series of videos on creating a bridge in Debian for your KVM VMs. From these I was able to obtain an internet connection for my OpenWRT Barrier Breaker VM via it's WAN card.
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet manual
auto br0
iface br0 inet static
address 192.168.1.85
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.1.1
bridge_ports eth1
bridge_stp off
bridge_fd 0
bridge_maxwait 0
dns-nameservers 192.168.1.1
iface br0 inet6 static
address fe80:21f:5bff:fe3b:73b1
netmask64
pre-up echo 0 > /proc/sys/net/ipv6/conf/br0/autoconf
post-down echo 1 > /proc/sys/net/ipv6/conf/br0/autoconf
/etc/network - Host Interface Configuration
From this I ended up with the following configuration in Virtual Machine Manager:
Host Interface configuration in Virtual Machine Manager
I also configured the OpenWRT VM wan interface with the following configuration:
config `switch` `eth0`
option `enable` `1`
config `switch_vlan` `eth1`
option `vlan` `0`
option `device` `eth1`
option `ports` `4 5` #wan
config `switch_vlan` `eth0_1`
option `vlan` `1`
option `device` `eth0`
option `ports` `0` #lan 1
config `interface` `lan`
option `ifname` `eth0.1`
option `proto` `static`
option `ipaddr` `192.168.100.1`
option `netmask` `255.255.255.0`
option `defaultroute` `0`
option `peerdns` `0`
option `nat` `1`
config `interface` `loopback`
option ifname `log`
option proto `static`
option ipaddr `127.0.0.1`
option netmask `255.0.0.0`
config interface `wan`
option ifname `eth1`
option type `bridge`
option proto `static`
option ipaddr `192.168.1.85`
option gateway `192.168.1.1`
option netmask `255.255.255.0`
option dns `192.168.1.1`
/etc/config/network - OpenWRT VM network configuration
Thanks to this, I am now able to use opkg
to download any packages I might need for the OpenWRT VM.
However, I'm only half way there; I'd like to place some client VMs on series of private networks behind the OpenWRT VM. I did my best to setup the LAN ports, but I don't know how to connect the virtual interfaces of the OpenWRT VM and the client machines.
I also setup a virtual network using Virtual Machine Manager:
The Isolated Virtual Network, intnet, configuration in Virtual Machine Manager
I thought that on the OpenWRT VM if I connected an interface other than the WAN interface on to the inet network:
OpenWRT VM LAN interface configured to connect to the inet virtual network
....and that if I also connected the client's single network interface to the inet network, (and of course configured them both inside the VM) that would be able to simulate the conditions of my physical network.
Client machine interface configured to connect to the inet virtual network
I'm not really certain on how to proceed, the libvirt documentation confuses me because I don't quite understand the virtual switch; It seems to me that if the virtual switch on the isolated inet network has both the gateway and the client machine plugged into it, it should at the very least allow the OpenWRT VM and the client machine to ping each other, but this is not the case.
I'd like to verify that I have the libvert plumbing correct first, and the move on to fine tuning the configuration of the lan interfaces on the inet isolated virtual network on both vms.
You need two host bridges.
br0 connects to the internet, and
br1 is a dummy bridge where all of the openwrt clients connect.
The complete instructions for a dhcp wan interface are here: http://wiki.openwrt.org/toh/qemu/qemu
I've not yet figured out how to use one static address where the host connects to the br1 bridge and gives openwrt full control of br0...that's another question.
Just made the same setup myself and have been trying to solve the problem for four days. Finally I found a solution that worked. I have also posted the same here on
Turned out I overthinked the whole solution. Only one interface is needed. I assigned the physical interface of the host to the VM's as well. So instead of creating one bridge for the internal network of the VM's i just used the same interface for everything. All Virtual and physical machines now share the same LAN connected to the OpenWRT assigning IP's and serving as a DNS-forwarder.