beautypg.com

Moxa Technologies UC-7420/7410 User Manual

Page 72

background image

UC-7420/7410 User’s Manual

Managing Communication

4-20

# connect tap device to the bridge
brctl addif br0 tap${i}

# null ip address of tap device
ifconfig tap${i} 0.0.0.0 promisc up

i=`expr $i + 1`
if [ $i -ge $maxtap ]; then
break
fi
done

# null ip address of internal interface
ifconfig $iface 0.0.0.0 promisc up

# enable bridge ip
ifconfig br0 $IPADDR netmask $NETMASK broadcast $BROADCAST

ipf=/proc/sys/net/ipv4/ip_forward
# enable IP forwarding
echo 1 > $ipf
echo “ip forwarding enabled to”
cat $ipf
}

stop() {
echo “shutdown openvpn bridge.”
ifcfg_vpn
i=`expr 0`
while :
do
# disconnect tap device from the bridge
brctl delif br0 tap${i}
openvpn --rmtun --dev tap${i}

i=`expr $i + 1`
if [ $i -ge $maxtap ]; then
break
fi
done
brctl delif br0 $iface
brctl delbr br0
ifconfig br0 down
ifconfig $iface $IPADDR netmask $NETMASK broadcast $BROADCAST
killall -TERM openvpn
}

case “$1” in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage: $0 [start|stop|restart]”
exit 1
esac
exit 0
#---------------------------------- end -----------------------------

Create link symbols to enable this script at boot time:

# ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc3.d/S32vpn-br # for example
# ln -s /etc/openvpn/openvpn-bridge /etc/rc.d/rc6.d/K32vpn-br # for example