diff --git a/miniupnpd/netfilter/iptables_init.sh b/miniupnpd/netfilter/iptables_init.sh index 0b064c9..bf64340 100755 --- a/miniupnpd/netfilter/iptables_init.sh +++ b/miniupnpd/netfilter/iptables_init.sh @@ -1,10 +1,13 @@ #! /bin/sh # $Id: iptables_init.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $ -IPTABLES=/sbin/iptables +IPTABLES="`which iptables`" || exit 1 +IP="`which ip`" || exit 1 #change this parameters : -EXTIF=eth0 -EXTIP="`LC_ALL=C /sbin/ifconfig $EXTIF | grep 'inet ' | awk '{print $2}' | sed -e 's/.*://'`" +#EXTIF=eth0 +EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1 +EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`" + echo "External IP = $EXTIP" #adding the MINIUPNPD chain for nat diff --git a/miniupnpd/netfilter/iptables_init_and_clean.sh b/miniupnpd/netfilter/iptables_init_and_clean.sh index 16f27d6..1783383 100755 --- a/miniupnpd/netfilter/iptables_init_and_clean.sh +++ b/miniupnpd/netfilter/iptables_init_and_clean.sh @@ -3,11 +3,15 @@ # Improved Miniupnpd iptables init script. # Checks for state of filter before doing anything.. -EXTIF=eth0 -IPTABLES=/sbin/iptables -EXTIP="`LC_ALL=C /sbin/ifconfig $EXTIF | grep 'inet ' | awk '{print $2}' | sed -e 's/.*://'`" -NDIRTY="`LC_ALL=C /sbin/iptables -t nat -L -n | grep 'MINIUPNPD' | awk '{printf $1}'`" -FDIRTY="`LC_ALL=C /sbin/iptables -t filter -L -n | grep 'MINIUPNPD' | awk '{printf $1}'`" +IPTABLES="`which iptables`" || exit 1 +IP="`which ip`" || exit 1 + +#EXTIF=eth0 +EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1 +EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`" + +NDIRTY="`LC_ALL=C $IPTABLES -t nat -L -n | awk '/MINIUPNPD/ {printf $1}'`" +FDIRTY="`LC_ALL=C $IPTABLES -t filter -L -n | awk '/MINIUPNPD/ {printf $1}'`" echo "External IP = $EXTIP" if [[ $NDIRTY = "MINIUPNPDChain" ]]; then diff --git a/miniupnpd/netfilter/iptables_removeall.sh b/miniupnpd/netfilter/iptables_removeall.sh index df8f282..5e10d0b 100755 --- a/miniupnpd/netfilter/iptables_removeall.sh +++ b/miniupnpd/netfilter/iptables_removeall.sh @@ -1,10 +1,12 @@ #! /bin/sh # $Id: iptables_removeall.sh,v 1.5 2011/05/16 12:11:37 nanard Exp $ -IPTABLES=/sbin/iptables +IPTABLES="`which iptables`" || exit 1 +IP="`which ip`" || exit 1 #change this parameters : -EXTIF=eth0 -EXTIP="`LC_ALL=C /sbin/ifconfig $EXTIF | grep 'inet ' | awk '{print $2}' | sed -e 's/.*://'`" +#EXTIF=eth0 +EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1 +EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`" #removing the MINIUPNPD chain for nat $IPTABLES -t nat -F MINIUPNPD