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



#
# The name of this chain
CHAIN=OUT_DNS


#
# 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!)

    #
    # dns querys from localhost (named forwarder requests)
    $fw -p udp -o $EX_INT ! --sport 53 --dport 53 -j ACCEPT

    #
    # dns answers to querys from LAN coming from localhost
    $fw -p udp -o $IN_INT ! -i $EX_INT --sport 53 -j ACCEPT
    
    #
    # localhost <=> localhost
    $fw -p udp -o $LO_INT -s $LO_NET --sport 53 -j ACCEPT
    $fw -p udp -o $LO_INT -s $LO_NET --dport 53 -j ACCEPT

    ;;
  "stop")
    echo "  Deleting $CHAIN"
    #
    # zero and delete this chain
    $iptables -F $CHAIN
    $iptables -X $CHAIN
    ;;
esac
