#! /bin/bash # # Author: Eicke Friedrich # # Bridge control script # # Interfaces eth0 and eth1 become br0 # # If you want to give the bridge interface # an IP adress put it here, else use 0.0.0.0 PUBLIC_IP=0.0.0.0 PUBLIC_NETMASK=255.255.255.0 PUBLIC_GATEWAY=0.0.0.0 PUBLIC_DEVICE=eth0 case "$1" in start) echo -n "Starting bridge ... " brctl addbr br0 brctl stp br0 off brctl addif br0 eth0 brctl addif br0 eth1 ifconfig eth0 down ifconfig eth1 down ifconfig eth0 0.0.0.0 up ifconfig eth1 0.0.0.0 up ifconfig br0 $PUBLIC_IP ifconfig br0 netmask $PUBLIC_NETMASK ifconfig br0 up route add default gw $PUBLIC_GATEWAY echo "done" ;; stop) echo -n "Stopping bridge ... " brctl delif br0 eth0 brctl delif br0 eth1 ifconfig br0 down brctl delbr br0 ifconfig $PUBLIC_DEVICE $PUBLIC_IP ifconfig $PUBLIC_DEVICE netmask $PUBLIC_NETMASK ifconfig $PUBLIC_DEVICE up route add default gw $PUBLIC_GATEWAY echo "done" ;; restart) echo -n "Restarting bridge ... " ifconfig br0 down ifconfig br0 up echo "done" ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac exit 0