Tuesday 22 May 2012

CentOS 6 Bridged Networking

If you are intending to run KVM under Centos, you will most likely want to use bridged networking.

I am starting with a standard CentOS 6 "minimal" install but the same process applies to RHEL and CentOS all versions.



First, install the bridge utils package;

yum install bridge-utils


Create/edit these two files, substituting the ipaddress and other details as applicable;

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="no"
ONBOOT=yes
HWADDR=FF:FF:FF:FF:FF:FF   # Use the actual hardware address for your NIC
TYPE=Ethernet
BRIDGE=br0

# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.0.1
PREFIX=24
GATEWAY=10.0.0.254     # You can put this in /etc/sysconfig/network if you prefer
DNS1=10.0.0.2
DOMAIN=example.net
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System br0"


Restart your server and you should now have a bridge adapter called "br0";

# ifconfig br0
br0    Link encap:Ethernet  HWaddr FF:FF:FF:FF:FF:FF 
          inet addr:10.0.0.1  Bcast:10.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:64ff:fe78:3f44/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9092 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4424 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9175506 (8.7 MiB)  TX bytes:369549 (360.8 KiB)


Confirm the bridge;

#brctl show
bridge name          bridge id           STP enabled    interfaces
br0                  8000.001a64783f44   no             eth0
virbr0               8000.525400badaa9   yes            virbr0-nic

No comments: