-
- #Getting host IP/masklen
- address=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}')
- [ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; }
-
- broadcast=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}')
- [ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN"
-
- gateway=$(netstat -rn | grep '^0.0.0.0' | awk '{print $2;}')
- [ -z "$gateway" ] && echo "WARNING: Could not determine gateway IP"
-
- # creating the bridge
- echo "Creating bridge INTERFACE_BRIDGE=$INTERFACE_BRIDGE"
- brctl addbr $INTERFACE_BRIDGE
- #brctl stp $INTERFACE_BRIDGE yes
- brctl addif $INTERFACE_BRIDGE $INTERFACE_LAN
- echo "Activating promiscuous mode INTERFACE_LAN=$INTERFACE_LAN"
- /sbin/ifconfig $INTERFACE_LAN 0.0.0.0 promisc up
- sleep 2
- echo "Setting bridge address=$address broadcast=$broadcast"
- # static
- #/sbin/ifconfig $INTERFACE_BRIDGE $address broadcast $broadcast up
- dhclient $INTERFACE_BRIDGE
- sleep 1
-
- #Reconfigure the routing table
- echo "Configuring gateway=$gateway"
- route add default gw $gateway
-
- echo "========== $COMMAND: exiting start - beg"
- ifconfig
- netstat -rn
- echo "========== $COMMAND: exiting start - end"
-
-
-return 0