How to Fix Bridge problem in CentOS/RHEL 5.4 for KVM

Learn | Teach Open Source Technologies

How to Fix Bridge problem in CentOS/RHEL 5.4 for KVM

How to Fix Bridge problem in CentOS/RHEL 5.4 for KVM

.Dated: 05-Nov-2009

KVM in the CentOS 5.4 – How to fixing bridge Problem

When we use KVM in CentOS 5.4 we will notice that there is no bridge setup to allow your virtual guests to directly connect to the local network.

We need to do so simple steps to fix it.

As we are using libvirt,
We need to follwo steps below to fix it.

Step 1: Create the bridge script at /etc/sysconfig/network-scripts/ifcfg-br0

[root@babar /root]# vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
BOOTPROTO=static
TYPE=Bridge
IPADDR=192.168.0.100
NETMASK=255.255.255.0
ONBOOT=yes
NM_CONTROLLED=no

Save & exit

As you can see, I use static IP config.

Step 2: hook up eth0 to the bridge and remove it’s IP config in /etc/sysconfig/network-scripts/ifcfg-eth0

[root@babar /root]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no
TYPE=Ethernet

Please restart the network service or your system and your system will start working fine after reboot. Now create a new virtual machine with virt-manager,we can select to have it directly hooked up to the physical network.

[root@babar ~]# ifconfig
br0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:febd:c94d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:168 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:11475 (11.2 KiB) TX bytes:9580 (9.3 KiB)

eth0 Link encap:Ethernet HWaddr 00:xx:xx:xx:xx:xx
inet addr:192.168.1.253 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:febd:c94c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3240 errors:0 dropped:0 overruns:0 frame:0
TX packets:5286 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:417544 (407.7 KiB) TX bytes:5574477 (5.3 MiB)
Memory:b1a20000-b1a40000

eth1 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet6 addr: fe80::215:17ff:febd:c94d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9113 errors:0 dropped:0 overruns:0 frame:0
TX packets:122 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:755212 (737.5 KiB) TX bytes:27911 (27.2 KiB)
Memory:b1a00000-b1a20000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:969 errors:0 dropped:0 overruns:0 frame:0
TX packets:969 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2744681 (2.6 MiB) TX bytes:2744681 (2.6 MiB)

virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:9535 (9.3 KiB)

vnet0 Link encap:Ethernet HWaddr A2:F7:06:6D:C1:2F
inet6 addr: fe80::a0f7:6ff:fe6d:c12f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57 errors:0 dropped:0 overruns:0 frame:0
TX packets:1035 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:9782 (9.5 KiB) TX bytes:208709 (203.8 KiB)

Now it is working fine.