42 lines
1.4 KiB
Plaintext
42 lines
1.4 KiB
Plaintext
|
description "Setup Routing depending on several config files"
|
||
|
author "Harald Kueller <harald.kueller@compuextreme.de>"
|
||
|
version 1.0
|
||
|
emits none special
|
||
|
|
||
|
start on stopped ifup
|
||
|
|
||
|
console output
|
||
|
|
||
|
script
|
||
|
source /etc/init/functions
|
||
|
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
|
||
|
while read <&3 TYPE NETWORK OPTION GW NETMASK; do
|
||
|
if [ "$OPTION" == "dev" ]; then
|
||
|
/sbin/route add -$TYPE $NETWORK netmask $NETMASK dev $GW
|
||
|
status_message "Device route to $NETWORK with $NETMASK on $GW"
|
||
|
fi
|
||
|
if [ "$OPTION" == "gw" ]; then
|
||
|
/sbin/route add -$TYPE $NETWORK netmask $NETMASK gw $GW
|
||
|
status_message "Net Route to $NETWORK with $NETMASK and gw $GW"
|
||
|
fi
|
||
|
done
|
||
|
exec 3>&-
|
||
|
rm /tmp/gateways
|
||
|
fi
|
||
|
if [ -f /etc/sysconfig/net/defaultrouter ]; then
|
||
|
/sbin/route add default gw `cat /etc/sysconfig/net/defaultrouter`
|
||
|
status_message "Default Router set to `cat /etc/sysconfig/net/defaultrouter`"
|
||
|
fi
|
||
|
NUMIF=`/sbin/ip -f inet addr show|/bin/grep inet|/bin/grep -v "host lo"|wc -l`
|
||
|
if [ $NUMIF -gt 2 ]; then
|
||
|
echo "1" >/proc/sys/net/ipv4/ip_forward
|
||
|
status_message "Enable of ip_forwarding"
|
||
|
fi
|
||
|
fi
|
||
|
end script
|