Setup bridge device on CentOS

Howto setup a bridge device on CentOS or Fedora.

If you need to bring your KVM VM’s into the same local area network like your host is in you need to configure a bridge device.

1. Install all needed packages:

yum install bridge-utils

yum install tunctl

2. Disable NetworkManager and enable network at boot time:

chkconfig NetworkManager off

chkconfig –levels 35 network on

/etc/init.d/NetworkManager stop

/etc/init.d/network restart

3. Create br0 configuration

vi /etc/sysconfig/network-scripts/ifcfg-br0

Change following configuration to your needs.

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
DNS1=192.168.0.1
GATEWAY=192.168.0.1
IPADDR=192.168.0.100
NETMASK=255.255.255.0
ONBOOT=yes
SEARCH=”example.com”

4. Modify eth0 configuration:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=00:1e:90:f3:f0:02
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
BRIDGE=br0

5. Restart network or reboot machine

/etc/init.d/network restart

or

reboot

Here are some additional information on the libvirt page. If you have performance problems with your bridge device you maybe need to disable the netfilter on the bridge interface.

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

8 thoughts on “Setup bridge device on CentOS

  1. indrajith rajapakse

    WHEN ADDING MAC ADDRESSES TO eth0 and eth1 this error is comming

    [root@localhost rc.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    [root@localhost rc.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth1

    [root@localhost rc.d]# /etc/init.d/network restart
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    Shutting down interface eth0: ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    [ OK ]
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    Shutting down interface eth1: ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    [ OK ]
    Shutting down loopback interface: [ OK ]
    Disabling IPv4 packet forwarding: net.ipv4.ip_forward = 0
    [ OK ]
    Bringing up loopback interface: [ OK ]
    Bringing up interface eth0: ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    [ OK ]
    Bringing up interface eth1: ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    [ OK ]
    [root@localhost rc.d]# /etc/init.d/network restart
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    Shutting down interface eth0: ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    [ OK ]
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    Shutting down interface eth1: ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    [ OK ]
    Shutting down loopback interface: [ OK ]
    Bringing up loopback interface: [ OK ]
    Bringing up interface eth0: ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    ifcfg-eth0: line 13: syntax error near unexpected token `newline’
    ifcfg-eth0: line 13: `HWADDR= ‘
    [ OK ]
    Bringing up interface eth1: ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    ifcfg-eth1: line 13: syntax error near unexpected token `newline’
    ifcfg-eth1: line 13: `HWADDR= ‘
    [ OK ]
    [root@localhost rc.d]# cd /
    [root@localhost /]# ping 192.168.1.43

    Reply
    1. Banym Post author

      Hi,

      can you post your ifcfg-eth0 file? You have an syntax error on line 13 like the error message is telling you.

      Regards,

      Dominik

      Reply
  2. Pingback: CentOS – ethernet modo brigde

  3. DevoKun

    indrajith rajapakse, doublecheck your quotes and line-endings. Errors like the ones you’re experiencing are usually because you copied and pasted some curly-quotes or the line-endings are \r\n when they should be just \n.
    You can quickly change the line-endings with:
    dos2unix ifcfg-eth0
    dos2unix ifcfg-eth1

    Reply
  4. Sam Song

    I want to setup a bridge to a wireless NIC. The wireless NIC gets IP address throught DHCP.
    My confs is as following:
    [sam@localhost network-scripts]$ more ifcfg-wlan0
    TYPE=wireless
    DEVICE=wlan0
    MODE=Managed
    HWADDR=74:DE:2B:59:31:24
    ONBOOT=yes
    BOOTPROTO=dhcp
    ESSID=venucloud
    KEY=s:venusourcecld
    NM_CONTROLLED=no
    BRIDGE=br0
    [sam@localhost network-scripts]$ more ifcfg-br0
    DEVICE=br0
    TYPE=Bridge
    BOOTPROTO=dhcp
    ONBOOT=yes
    DELAY=0

    When I start the service, the bridge cannot get an IP address.

    Is there anything different between creating bridge to an ethernet and to an wireless?

    Reply
  5. Pingback: KVM on CentOS 6.4 (x86_64): problems configuring bridge

  6. Pingback: Cannot ping local systems - but local systems can access internet - Page 2

  7. Pingback: Building a WAN simulator | Spl0dge's Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>