summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/ubuntu/ip-redirect-all
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/ubuntu/ip-redirect-all')
-rwxr-xr-xsca-cpp/trunk/ubuntu/ip-redirect-all5
1 files changed, 5 insertions, 0 deletions
diff --git a/sca-cpp/trunk/ubuntu/ip-redirect-all b/sca-cpp/trunk/ubuntu/ip-redirect-all
index aba5bc15ae..f796b0589e 100755
--- a/sca-cpp/trunk/ubuntu/ip-redirect-all
+++ b/sca-cpp/trunk/ubuntu/ip-redirect-all
@@ -22,5 +22,10 @@ here=`readlink -f $0`; here=`dirname $here`
sport=$1
tport=$2
+# Cleanup existing rules
+sudo /sbin/iptables -t nat -S PREROUTING | grep "\-p tcp" | grep "\-\-dport $sport" | grep "\-j REDIRECT" | sed "s/^-A/-D/" | awk -F "\t" '{ printf "sudo /sbin/iptables -t nat %s\n", $1 }' | /bin/sh
+sudo /sbin/iptables -t nat -S OUTPUT | grep "\-p tcp" | grep "\-\-dport $sport" | grep "\-j REDIRECT" | sed "s/^-A/-D/" | awk -F "\t" '{ printf "sudo /sbin/iptables -t nat %s\n", $1 }' | /bin/sh
+
+# Redirect traffic
/sbin/ifconfig | grep "inet addr:" | awk -F ":" '{ print $2 }' | awk '{ print $1 }' | xargs -i $here/ip-redirect $sport $tport {}