2010-04-20 12:58:29 +00:00
|
|
|
description "Setup Routing depending on several config files"
|
|
|
|
author "Harald Kueller <harald.kueller@compuextreme.de>"
|
|
|
|
version 1.0
|
|
|
|
emits none special
|
2008-05-03 17:03:02 +00:00
|
|
|
|
2010-04-20 12:58:29 +00:00
|
|
|
start on stopped ifup
|
2008-05-03 17:03:02 +00:00
|
|
|
|
2010-04-20 12:58:29 +00:00
|
|
|
console output
|
2008-05-03 17:03:02 +00:00
|
|
|
|
|
|
|
script
|
2010-04-20 12:58:29 +00:00
|
|
|
source /etc/init/functions
|
2008-05-03 17:03:02 +00:00
|
|
|
if [ ! -f /etc/sysconfig/net/notrouter ]; then
|
|
|
|
echo "Configuring System with routing allowed"
|
|
|
|
if [ -f /etc/sysconfig/net/gateways ]; then
|
|
|
|
sed -e "/^#/d" /etc/sysconfig/net/gateways | \
|
|
|
|
sed -e "/^ *$/d" >/tmp/gateways
|
|
|
|
exec 3</tmp/gateways
|
|
|
|
read <&3 TYPE NETWORK OPTION GW NETMASK
|
|
|
|
while [ $TYPE ]; do
|
|
|
|
if [ "$OPTION" == "dev" ]; then
|
|
|
|
route add -$TYPE $NETWORK netmask $NETMASK dev $GW
|
2010-01-28 13:58:15 +00:00
|
|
|
status_message "Device route to $NETWORK with $NETMASK on $GW"
|
2008-05-03 17:03:02 +00:00
|
|
|
fi
|
|
|
|
if [ "$OPTION" == "gw" ]; then
|
|
|
|
route add -$TYPE $NETWORK netmask $NETMASK gw $GW
|
2010-01-28 13:58:15 +00:00
|
|
|
status_message "Net Route to $NETWORK with $NETMASK and gw $GW"
|
2008-05-03 17:03:02 +00:00
|
|
|
fi
|
|
|
|
read <&3 TYPE NETWORK OPTION GW NETMASK
|
|
|
|
done
|
|
|
|
exec 3>&-
|
|
|
|
rm /tmp/gateways
|
|
|
|
fi
|
|
|
|
if [ -f /etc/sysconfig/net/defaultrouter ]; then
|
2010-01-28 13:58:15 +00:00
|
|
|
route add default gw `cat /etc/sysconfig/net/defaultrouter`
|
|
|
|
status_message "Default Router set to `cat /etc/sysconfig/net/defaultrouter`"
|
2008-05-03 17:03:02 +00:00
|
|
|
fi
|
2010-01-28 13:58:15 +00:00
|
|
|
NUMIF=`ip -f inet addr show|grep inet|grep -v "host lo"|wc -l`
|
2008-05-03 17:03:02 +00:00
|
|
|
if [ $NUMIF -gt 2 ]; then
|
|
|
|
echo "1" >/proc/sys/net/ipv4/ip_forward
|
2010-01-28 13:58:15 +00:00
|
|
|
status_message "Enable of ip_forwarding"
|
2008-05-03 17:03:02 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
end script
|