linux eth0 is not working with bridge

prathmesh.kallurkar picture prathmesh.kallurkar · Apr 16, 2012 · Viewed 9.1k times · Source

Friends, I am trying to bridge my qemu guest to the real network using linux bridge utility.
For this, I am using very simple method :

  1. Create a bridge on host using (sudo brctl addbr br0)
  2. Add eth0 to this bridge (sudo brctl addif br0 eth0)
  3. Changed /etc/qemu-ifup script (brctl addif br0 $1)
  4. Changed /etc/qemu-ifdown script (brctl delif br0 $1)

With above 4 steps, I was get the network of my guest working properly. But now the problem is that my host network is not working after i attach my eth0 to bridge br0.

I confirmed that after step1 and step2 my host network stops working. But the guest network continue to work and this is what baffles me.

Can somebody please point out what is the problem with this two lines ?

  1. Create a bridge on host using (sudo brctl addbr br0)
  2. Add eth0 to this bridge (sudo brctl addif br0 eth0)

PS : I have tried almost all methods given on the Internet and have not succeeded in any method. Besides my question is related to linux networking and not qemu in particular

Answer

prathmesh.kallurkar picture prathmesh.kallurkar · Apr 16, 2012

I realized my stupidity. but since the question was still intersting and useful at the same time, I am not closing it.

Here is the issue. I should have ip stack on the bridge and not the eth0.
Because an ip stack on eth0 breaks the bridge structure. I just added a couple of steps to my solution and it works like a charm. Better than most of the solutions on the web.

Steps :

  1. Create a bridge on host using (sudo brctl addbr br0)
  2. Release ip addr on eth0 (bring link down and up again)
  3. Add eth0 to this bridge (sudo brctl addif br0 eth0)
  4. start ip stack on bridge (sudo dhclient br0)
  5. Changed /etc/qemu-ifup script (brctl addif br0 $1)
  6. Changed /etc/qemu-ifdown script (brctl delif br0 $1)

The qemu command i used was :
sudo qemu-system-i386 -enable-kvm -net tap,vlan=0,ifname=tap0 -net nic,vlan=0 -hda ~/Data/OS_DiskImages/ubuntu11.10/disk.qcow2

Detailed steps with scripts given here : link