# -*-sh-*-
#
# INPUT_INTERN chain for scipfire
#
# $Id: INPUT_INTERN,v 1.3 2001/07/29 21:23:35 scip Exp $



#
# The name of this chain
CHAIN=INPUT_INTERN


#
# get the type of mode we are running under
# will be one of: start | startlog | print | stop
MODE=$1


#
# get the base path
PREFIX=$2


#
# source the config
. $PREFIX/conf/scipfire.cfg



#
# now $MODE is only start or stop!
case $MODE in
  "start")
    echo "  Initialize $CHAIN"
    #
    # initialize this chain
    $echo $iptables -N $CHAIN                # create the new chain
    $echo $iptables -F $CHAIN                # flush possibly existing rules(for restart|reload!)

    #
    # rfc sourced stuff will be denied
    $fw -j IN_RFC

    #
    # deny external network broadcasts
    $log -d $IN_BROADCAST
    $fw  -d $IN_BROADCAST -j $DENY

    #
    # deny stupid windows clients broadcast messages
    $log -d 255.255.255.255
    $fw  -d 255.255.255.255 -j $DENY
    
    #
    # dns may be allowed
    $fw -p udp --sport 53 -j DNS
    $fw -p udp --dport 53 -j DNS

    #
    # deny other udp
    $log -p udp
    $fw  -p udp -j $DENY

    #
    # related stuff, such as ftp active (NEEDS TO BE INVESTIGATED !)
    $fw -p tcp -m state --state RELATED -s $IN_NET ! -d $IN_ME -j ACCEPT

    #
    # jump to certain tcp services stuff
    $fw -p tcp --dport 22 -j SSH
    $fw -p tcp --dport 80 -j WWW
    $fw -p tcp --dport 20 -j FTP
    $fw -p tcp --dport 21 -j FTP
    $fw -p icmp           -j ICMP    
    
    ;;
  "stop")
    echo "  Deleting $CHAIN"
    #
    # zero and delete this chain
    $iptables -F $CHAIN
    $iptables -X $CHAIN
    ;;
esac
