Setting up a Network Bridge on Centos 6/RHEL with a Static IP is relatively straightforward
The bridge enables virtual machines to be accessed from other hosts as if they are physical systems in the network.
$ sudo yum -y install bridge-utils
Rename your existing file and get some information from it
(This assumes you have an existing connection 'eth0')
$ sudo su
# cd /etc/sysconfig/network-scripts/
# mv ifcfg-eth0 ifcfg-eth0.bak
# cat ifcfg-eth0.bak
Echo the HWADDR and UUID into your new ifcfg-eth0 file
# echo HWADDR="00:02:44:4B:52:D8" UUID="2609446d-e228-4600-ae9c-8230c1c3d7d3" > ifcfg-eth0
Add the lines below to complete the file
# vi ifcfg-eth0
DEVICE="eth0"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
BRIDGE="br0"
(Drop the UUID to the next line)
Save the file
Install iproute2 tools
$ sudo yum -y install iproute
$ route -n
$ netstat -nr
The above commands fetch needed information
Create a bridge file
# vi ifcfg-br0 add the following
DEVICE="br0"
BOOTPROTO="static"
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
PEERDNS="yes"
TYPE="Bridge"
Replace the 4 network values with your own, you can get all the information from the 2 commands above, this assumes you will know the static ip address range of your own router for the IPADDR.
(NETWORK will be under 'Destination', GATEWAY will be under 'Gateway' and NETMASK will be under 'Genmask' using either route -n or netstat -nr commands)
# service network restart
To relaunch the new configuration
$brctl show
Shows the bridge details
$ ifconfig -a
Shows the new setup
br0 Link encap:Ethernet HWaddr 00:02:44:4B:52:D8
inet addr:192.168.0.100 Bcast:192.168.0.255
Mask:255.255.255.0
inet6 addr: fe80::202:44ff:fe4b:52d8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:154 errors:0 dropped:0 overruns:0 frame:0
TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:32630 (31.8 KiB) TX bytes:88381 (86.3 KiB)
eth0 Link encap:Ethernet HWaddr 00:02:44:4B:52:D8
inet6 addr: fe80::202:44ff:fe4b:52d8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1048 errors:0 dropped:0 overruns:0 frame:0
TX packets:1129 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:383206 (374.2 KiB) TX bytes:240253 (234.6KiB)
Interrupt:18 Base address:0x8000
Some setups may require a reboot
See also a simple Static IP without a bridge.
Labels: Centos 6, Network Bridge, RHEL, Static IP