Now while that works great! And it is probably what you wanted. Look at this as another solution
This is RedHat, other distros may have boot scripts in a different place. Adjust this as needed.
Backup files first..
Code:
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0
.bak
cp /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1
.bak
now we will create new files for the interfaces..
Code:
echo DEVICE=eth0 > /etc/sysconfig/network-scripts/ifcfg-eth0
echo ONBOOT=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo DEVICE=eth1 > /etc/sysconfig/network-scripts/ifcfg-eth1
echo ONBOOT=no >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo DEVICE=br0 > /etc/sysconfig/network-scripts/ifcfg-br0
echo ONBOOT=no >> /etc/sysconfig/network-scripts/ifcfg-br0
We are going to create a file that can be run to configure the interface..
I am calling it rc.br0
Code:
echo "#!/bin/sh" > /etc/rc.d/rc.br0
echo "brctl addbr br0" >> /etc/rc.d/rc.br0
echo "brctl addif br0 eth0" >> /etc/rc.d/rc.br0
echo "brctl addif br0 eth1" >> /etc/rc.d/rc.br0
echo "ip link set br0 up" >> /etc/rc.d/rc.br0
echo "ip link set eth0 up" >> /etc/rc.d/rc.br0
echo "ip link set eth1 up" >> /etc/rc.d/rc.br0
echo "Starting up Interface br0" >> /etc/rc.d/rc.br0
echo "This will take 60 seconds" >> /etc/rc.d/rc.br0
Now you have some options, only choose one of them
Option #1
If there is dhcp on the network you can add this
Code:
echo "dhcpcd br0" >> /etc/rc.d/rc.br0
Option #2
If there is no dhcp then manually assign an ip and routing.
Replace xxx.xxx.xxx.xxx with the ip of choice,
and yyy.yyy.yyy.yyy with the default gateway
Code:
echo "ifconfig br0 xxx.xxx.xxx.xxx" >> /etc/rc.d/rc.br0
echo "route add default gw yyy.yyy.yyy.yyy" >> /etc/rc.d/rc.br0
note: you will need nameservers in /etc/resolv.conf
for dns to work on this machine
Option #3
Don't set an ip, the computer will not have an ip and will be invisible
Ok, That's it for the script..
We need to set permissions on our new file
Code:
chmod 755 /etc/rc.d/rc.br0
Now we are ready to run the script to setup the bridge
if your interfaces are up you bring them down first
Code:
ifconfig eth0 down
ifconfig eth1 down
If you want it to come up at boot this will set it up
Code:
echo "/etc/rc.d/rc.br0" >> /etc/rc.d/rc.local
Now you have a bridge
One of the main advantages is that dhcp and other broadcast protocols will work through the bridge. They will not work through a proxy arp.