KVM Network Bridge Setup

From SolusVM

Jump to: navigation, search

This guide explains how to setup a dedicated network bridge for Linux KVM virtualization. The guide also presumes the network interface is eth0 and the bridge will be called br0.

Bridging requires the bridge-utils package to be installed on the server. To check if it's installed, do the following:

rpm -q bridge-utils

If you get an output it's installed, if not, it needs installing:

yum install bridge-utils

Before setting up your bridge, the contents of /etc/sysconfig/network-scripts/ifcfg-eth0 will look like the following:

DEVICE=eth0
BOOTPROTO=static
BROADCAST=102.100.152.255
HWADDR=00:27:0E:09:0C:B2
IPADDR=102.100.152.2
IPV6INIT=yes
IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
NETWORK=102.100.152.0
ONBOOT=yes  

It's always good practice to backup your current ifcfg-eth0 before modification, To do this, just run the following command:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/backup-ifcfg-eth0

Next you need to create the bridge file:

nano -w /etc/sysconfig/network-scripts/ifcfg-br0

and copy parts of ifcfg-eth0 to it:

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
BROADCAST=102.100.152.255
IPADDR=102.100.152.2
NETMASK=255.255.255.0
NETWORK=102.100.152.0
ONBOOT=yes 

Save that file and edit ifcfg-eth0

nano -w /etc/sysconfig/network-scripts/ifcfg-eth0

Remove the networking parts and specify the bridge:

DEVICE=eth0
HWADDR=00:27:0E:09:0C:B2
IPV6INIT=yes
IPV6_AUTOCONF=yes
ONBOOT=yes
BRIDGE=br0  

Congratulations, your bridge is now setup, all thats left is to make sure the changes are correct and restart the networking.

/etc/init.d/network restart

Once it's restarted you should see the new bridge using the ifconfig command:

[root@dev1 ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 00:27:0E:09:0C:B2
          inet addr:102.100.152.2  Bcast:102.100.152.255  Mask:255.255.255.0
          inet6 addr: fe80::227:eff:fe09:cb2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:48 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2984 (2.9 KiB)  TX bytes:13154 (12.8 KiB)

eth0      Link encap:Ethernet  HWaddr 00:27:0E:09:0C:B2
          inet6 addr: fe80::227:eff:fe09:cb2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31613 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9564 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:2981335 (2.8 MiB)  TX bytes:2880868 (2.7 MiB)
          Memory:d0700000-d0720000                                                
Personal tools
Installation/Upgrading
Customization