With bridged networking you can share actual network device with KVM machines. This is required for servers with multiple network cards and gives you good performance. You can choose to put multiple segments into one bridged network or to divide it into different networks interconnected by routers.
Our Sample Setup
The following describes the networking used by our setup:
+------+ +-----+
LAN --> | eth0 | <==> | br0 | -> KVM VMs connected to LAN for SAN/NFS
+------+ +-----+
10.10.x.y/24
+------+ +-----+
Internet --> | eth1 | <==> | br1 | -> KVM VMs connected to the Inernet
+------+ +-----+
123.1.2.0/28
Where,
- All other clients can reached to all VMs via br1 which is connected to public interface. br1 is our default gateway.
- br0 is connected to private LAN to access other servers, services and storage devices such as SAN/NAS or NFS servers. br0 route is configured via route-br0 static networking configuration file.
Turn Off NetworkManager
The NetworkManager (GUI) tool can create problems with bridged based networking so disable it as follows, enter:
# chkconfig NetworkManager off
# chkconfig network on
# service NetworkManager stop
Edit /etc/sysconfig/network, enter:
# vi /etc/sysconfig/network
Update file as follows:
NETWORKING=yes HOSTNAME=kvm42.nixcraft.net GATEWAY=br1
Save and close the file.
br0: Configure Bridging for eth0
Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Update it as follows:
DEVICE=eth0 ONBOOT=yes ETHTOOL_OPTS="autoneg off speed 100 duplex full" BRIDGE=br0 HWADDR=b8:ac:6f:65:31:e5
Save and close the file. Create /etc/sysconfig/network-scripts/ifcfg-br0, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-br0
Update it as follows (note options are case sensitive i.e. Bridge and bridge are two different options)
DEVICE=br0 TYPE=Bridge BOOTPROTO=static ONBOOT=yes IPADDR=10.10.21.70 NETMASK=255.255.255.192 DELAY=0
Save and close the file. Finally, create static routing file /etc/sysconfig/network-scripts/route-br0, enter :
# vi /etc/sysconfig/network-scripts/route-br0
Edit it as follows:
10.0.0.0/8 via 10.10.21.122 dev br0
Save and close the file. Delete old /etc/sysconfig/network-scripts/route-eth0 (if exists):
# rm /etc/sysconfig/network-scripts/route-eth0
br1: Configure Bridging for eth1
Edit /etc/sysconfig/network-scripts/ifcfg-eth1, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Update it as follows:
DEVICE=eth1 ONBOOT=yes ETHTOOL_OPTS="autoneg off speed 100 duplex full" BRIDGE=br1 HWADDR=00:30:49:8c:48:ad
Please note that test server is set to 100Mbps full duplex. Save and close the file. Edit /etc/sysconfig/network-scripts/ifcfg-br1, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-br1
Define public IP address including gateway as follows:
DEVICE=br1 BOOTPROTO=static ONBOOT=yes IPADDR=123.1.2.3 NETMASK=255.255.255.248 GATEWAY=123.1.2.200 TYPE=Bridge DELAY=0
Save and close the file.
Restart Network Service
Type the following command:
# service network restart
Make sure everything is working fine:
# brctl show
Sample outputs:
bridge name bridge id STP enabled interfaces br0 8000.0030488e31ac no eth0 br1 8000.0030488e31ad no eth1 virbr0 8000.000000000000 yes
Verify IPs and routing tables:
# ip addr show br0
# ip addr show br1
# ip route
# ping cyberciti.biz
# host google.com
- CentOS / Redhat: Install KVM Virtualization Software
- CentOS / Redhat: KVM Bridged Network Configuration
- KVM virt-manager: Install CentOS As Guest Operating System
- KVM virt-install: Install FreeBSD / CentOS As Guest Operating System
- KVM: Install CentOS / RHEL Using Kickstart File (Automated Installation)
- Troubleshooting KVM Virtualization Problem With Log Files
- KVM Virsh: Redirect FreeBSD Console To A Serial Port
- KVM: Starting / Stopping Guest Operating Systems With virsh Command
- Linux KVM: Disable virbr0 NAT Interface
- FreeBSD / OpeBSD Running in KVM Does Not Accept FTP Traffic
- KVM: Start a Virtual Machine / Guest At Boot Time
- KVM virt-install: Install OpenBSD As Guest Operating System
- Linux KVM: OpenBSD Guest Hangs At Starting tty Flags
- KVM Virtualization: Start VNC Remote Access For Guest Operating Systems













{ 18 comments… read them below or add one }
A small typo needs to be corrected Under “br1: Configure Bridging for eth1″ heading, “vi /etc/sysconfig/network-scripts/ifcfg-eth0″ should be changed with “vi /etc/sysconfig/network-scripts/ifcfg-eth1″
Thanks for the heads up! The post has been updated.
regarding the Bridging…
watch the custom options ( ETHTOOL_OPTS ) you pass in eth0, eth1 etc !!
you may find network issues in guest machines. I have three guest ( Ubuntu,Centos, Openbsd ) in my Centos host and the 3 guest had problems.Probably has to do with the model of the network card..so leave the default!!!
something like this :
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0
HWADDR=XX:XX:XX:XX:XX:XX
How would a single eth0 nic grabbing its information from a DHCP server be handled?
I think your GATEWAY parameter in /etc/sysconfig/network is incorrect. That parameter should be the IP address. If you want to direct to a device, then you need to use GATEWAYDEV parameter.
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-sysconfig.html
Thanks for the good work on your site. I always learn something new.
Dear Vivek,
Can U please elaborate on this entry.
10.0.0.0/8 via 10.10.21.122 dev br0
I also do not know why you would need a static route. This route should be included by default.
The RHEL docs do not mention this.
How if eth1 have 2 class ip ?
I got up to the point where you have to edit
/etc/sysconfig/network-scripts/ifcfg-eth0
I dont have that file….
Its a clean install too….
Ok how do I remove the bridge?
Delete ifcfg-brX and restart the network, make sure you restore your route-eth0 file if you’re removing the private network bridge
Actually i am using wireless to connect to my modem (ifcfg-wlan0) from my host machine. if i create bridge as br0, in my host machine, will there be any change in ifcfg-br0 for wireless setup.
Also, whether i need to include type=bridge parameter in ifcfg-wlan0 file of my host machine?
Wheter i need to use eth0 or wlan0 in my kvm for connecting this bridge.
What if I have only one nic which is connected (wired) to a wireless router and internet gateway and I want my guest VMs accessible from the LAN and can access the internet as well?
Appreciating your support.
Don’t try this on a remote production machine with a public IP……you’ll lose connectivity. I haven’t found a guide for bridging anything yet that won’t cause a production machine to go down :(
My RHEL 5.8 box has one nic with two static IP’s (one VIP) – I have a DHCP server in my environment – do I need bridging?
How do you map your VM to use br0 ? When adding your VM using virt-manager, which network should my VM card be added to ?
If I add to virbr0, i get mapped to the 192.168.x.x/24 private network.
I can’t seem to create a new network with the same network as br0 cause it doesn’t allow it.
Any help appreciated.
This is so idiotic. Doing things round about way in redhat KVM virualization. Just use Oracle’s Virtual box. So much easier and not at all confusing.
@ CheapIndianITGuy: Why would anyone do this in Oracle virtualbox if their goal was to be an RHCSA or RHCE???? It defeats the purpose of developing a level of proficiency with RedHat KVM (a “known” RH Linux test objective) as well as gaining an overall familiarity of the OS’s functionality. Heck, even a linux enthusiast can gain from learning this method.
Personally, the guy who delves a bit deeper into the woodworks has more than a “job;” he has a “career…”