1#! /bin/sh 2# $Id: iptables_init.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $ 3IPTABLES="`which iptables`" || exit 1 4IP="`which ip`" || exit 1 5 6#change this parameters : 7#EXTIF=eth0 8EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1 9EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`" 10 11echo "External IP = $EXTIP" 12 13#adding the MINIUPNPD chain for nat 14$IPTABLES -t nat -N MINIUPNPD 15#adding the rule to MINIUPNPD 16#$IPTABLES -t nat -A PREROUTING -d $EXTIP -i $EXTIF -j MINIUPNPD 17$IPTABLES -t nat -A PREROUTING -i $EXTIF -j MINIUPNPD 18 19#adding the MINIUPNPD chain for mangle 20$IPTABLES -t mangle -N MINIUPNPD 21$IPTABLES -t mangle -A PREROUTING -i $EXTIF -j MINIUPNPD 22 23#adding the MINIUPNPD chain for filter 24$IPTABLES -t filter -N MINIUPNPD 25#adding the rule to MINIUPNPD 26$IPTABLES -t filter -A FORWARD -i $EXTIF ! -o $EXTIF -j MINIUPNPD 27 28#adding the MINIUPNPD chain for nat 29$IPTABLES -t nat -N MINIUPNPD-PCP-PEER 30$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MINIUPNPD-PCP-PEER 31