summarylogtreecommitdiffstats
path: root/ip64tables
diff options
context:
space:
mode:
authorThomas Heinemann2017-01-15 12:19:09 +0100
committerThomas Heinemann2017-01-15 12:19:09 +0100
commit49e2ffdd43ccbd51b301a3075792c42a08525cc7 (patch)
tree6f2c149da8ff0f98515e7a690428ef49a3cda807 /ip64tables
downloadaur-49e2ffdd43ccbd51b301a3075792c42a08525cc7.tar.gz
initial release
Diffstat (limited to 'ip64tables')
-rwxr-xr-xip64tables29
1 files changed, 29 insertions, 0 deletions
diff --git a/ip64tables b/ip64tables
new file mode 100755
index 00000000000..7b1639de533
--- /dev/null
+++ b/ip64tables
@@ -0,0 +1,29 @@
+#!/bin/bash
+# iptables/ip6tables switch
+LINE=$*
+
+RESULT=`echo $LINE | egrep " ([0-9]{1,3}\.){3}[0-9]{1,3}" | wc -l`
+RESULT6=`echo $LINE | egrep "(::[A-Fa-f0-9])|((:[A-Fa-f0-9]{1,4}){2,})" | wc -l `
+
+if [ $RESULT -eq "1" ]; then
+ # IPv4
+ iptables $LINE
+ ERRCODE=$?
+
+elif [ $RESULT6 -eq "1" ]; then
+ # IPv6
+ ip6tables $LINE
+ ERRCODE=$?
+
+else
+ # IPv4 + IPv6
+ iptables $LINE
+ ERRCODE=$?
+ ip6tables $LINE
+ if [ $? -ge "1" ]; then
+ ERRCODE=$?
+ fi
+
+fi
+
+exit $ERRCODE