I have been using Linux network bridges for a while at work for various reasons, ranging from installing a new invisible firewall to measuring bandwidth in a client server setup. Until now, I always used a script called by rc.local to create the bridge and add interfaces to it, but today I found the proper Red-Hat way of using bridged interfaces:
If you have read until here, you are probably already aware that, in Red Hat or CentOS, interfaces are configured in /etc/sysconfig/network-scripts/ifcfg-[interface-name]
So the first step is to create a interface file for the future bridge: ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.10
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
USERCTL=no
IPV6INIT=no
PEERDNS=no
ONBOOT=yes
That file /etc/sysconfig/network-scripts/ifcfg-br0 will create the bridge itself but no interface will be member of that bridge.To add, say, 2 interfaces eth0 and eth1 to the bridge br0, edit or create
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BRIDGE=br0
ONBOOT=yes
and
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BRIDGE=br0
ONBOOT=yes
a reboot or "service network restart" will then create and activate your new Linux network bridge.
You can now easily filter traffic thanks to the physdev module of iptables or install an invisible proxy server.