nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format

http://www.cyberciti.biz/ ~ RSS Feed ~ Facebook ~ Twitter ~ Google+ ~
Youtube
Copyrighted material

Home > FAQ > Virtualization > Linux KVM > RedHat and Friends > CentOS

CentOS / Redhat: KVM Bridged Network Configuration
Posted By nixCraft <webmaster@cyberciti.biz> On January 12, 2010 @ 9:31 am [ 17 Comments ]

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:

[1]

+------+
+-----+
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
nixCraft is GIT UL++++ W+++ C++++ M+ e+++ d-

Page 1 of 3

enter : # vi /etc/sysconfig/network-scripts/route-br0 Edit it as follows: 10.1.255.HWADDR =b8:ac:6f:65:31:e5 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.21.248 GATEWAY=123. Edit /etc/sysconfig/network-scripts/ifcfgbr1.200 TYPE=Bridge DELAY=0 Save and close the file. 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. enter: # vi /etc/sysconfig/network-scripts/ifcfg-br0 Update it as follows (note options are case sensitive i. Create /etc/sysconfig/network-scripts/ifcfg-br0.10.e.2.122 dev br0 Save and close the file. Finally. Save and close the file. create static routing file /etc/sysconfig/network-scripts/route-br0.0/8 via 10.2.192 DELAY=0 Save and close the file.0. Bridge and bridge are two different options) DEVICE=br0 TYPE=Bridge BOOTPROTO=static ONBOOT=yes IPADDR =10.1.21.0. enter: # vi /etc/sysconfig/network-scripts/ifcfg-br1 Define public IP address including gateway as follows: DEVICE=br1 BOOTPROTO=static ONBOOT=yes IPADDR =123.3 NETMASK=255.70 NETMASK=255. 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.0030488e31ad no eth1 nixCraft is GIT UL++++ W+++ C++++ M+ e+++ d- Page 2 of 3 .10.255.0030488e31ac no eth0 br1 8000.255.255.

tips and tricks? We request you to sign up for the following to ensure that you make the most from our guides / howtos: 1.http://www.Get intimated about our new howtos / faqs as soon as it is released via email. More details .com Important Message from nixCraft: 4000+ howtos and counting! Want to read more Linux / UNIX howtos. All rights reserved. the documents and graphics stored on this Web server.biz/faq/category/linux-kvm/ Copyrighted material Copyright © 2006-2013 nixCraft. Daily email newsletter or weekly newsletter . are copyrighted.biz/faq/rhel-linux-kvm-virtualization-bridged-networking-with-libvirt/ URLs in this post: [1] Image: http://www.cyberciti.biz.cyberciti. No copies may be made without permission.biz/tips/copyright nixCraft is GIT UL++++ W+++ C++++ M+ e+++ d- Page 3 of 3 .000000000000 yes Verify IPs and routing tables: # ip addr show br0 # ip addr show br1 # ip route # ping cyberciti.virbr0 8000.cyberciti.Get intimated about our new howtos / faqs as soon as it is released. URL to article: http://www. This print / pdf version is for personal non-commercial use only. www.cyberciti. Unless otherwise indicated. 2. Links to these documents are permitted and encouraged.biz # host google. RSS feed for nixCraft .