#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/ip-up.portfw - setup portfw # # Creation: 24.11.2002 fm # Last Update: 14.12.2003 fm # # Copyright (c) 2002-2003 Frank Meyer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- kernel_version=`uname -r` ip=$local . /etc/config.d/routing case "$kernel_version" in 2.2.*) if [ "$PORTFW_N" -gt 0 ] then idx=1 while [ "$idx" -le "$PORTFW_N" ] do eval portfw_rule='$PORTFW_'$idx set -- $portfw_rule ports=$1 hidden=$2 proto=$3 if echo "$ports" | grep "-" > /dev/null 2> /dev/null # is there a port-range? then low=`echo "$ports" | cut -d "-" -f 1` high=`echo "$ports" | cut -d "-" -f 2` /usr/sbin/ipmasqadm autofw -A -v -r $proto $low $high -h $hidden else rport=`echo "$hidden" | cut -d ":" -f 2` hidden=`echo "$hidden" | cut -d ":" -f 1` if [ "$rport" = "$hidden" ] # no port specifed after hiddenhost? then rport="$ports" fi /usr/sbin/ipmasqadm portfw -a -P $proto -L $ip $ports -R $hidden $rport fi idx=`/usr/bin/expr $idx + 1` done fi ;; *) is_default_route=yes if [ -f /etc/portfw.conf ] # is portfw configured? then echo "initializing port forwarding..." if [ "$is_default_route" = "yes" ] # is a default-route-interface going up then /usr/local/bin/setup-portfw.sh doit "default" "$local" fi /usr/local/bin/setup-portfw.sh doit "$interface" "$local" echo 'port forwarding: done' fi ;; esac