Create bridge device on my KVM host

I installed KVM on my debian host. Since I have 8 cores and 32GB RAM I have room to play around 🙂 And since I have some experience with KVM it was the obvious choice.

Installing KVM : easy … apt is your friend
Creating an VM : easy … Maybe I’ll once write it up

I could connect to the VM, using the console. However from within the VM I could only ping itself. I forgot to create a (virtual) bridge device which connect the VMs to the host machine.

So what to do:
Create br0.xml

root@radijs:~# cat br0.xml 
<network>
  <name>br0</name>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='br0' stp='on' delay='0'/>
  <ip address='192.168.3.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.3.2' end='192.168.3.20'/>
    </dhcp>
  </ip>
</network>
root@radijs:~#

Make KVM aware of the bridge:

root@radijs:~# virsh net-define br0.xml 
Network br0 defined from br0.xml

root@radijs:~#

Start the just defined bridge:

root@radijs:~# virsh net-start br0
Network br0 started

root@radijs:~# 

Make sure it will autostart,

root@radijs:~# virsh net-autostart br0
Network br0 marked as autostarted

root@radijs:~#

Do I now actually have a bridge:

root@radijs:~# virsh net-list
 Name   State    Autostart   Persistent
-----------------------------------------
 br0    active   yes         yes

root@radijs:~#

Yes I have.

The proof of the pudding is in the eating:…Can I now reach the world from my VM’s?
I can not show you….but yes ….I can.

Success!!!

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *