Add support for IPv6.

This commit is contained in:
Christoph 2017-07-29 14:07:07 +02:00
parent a0290e96c9
commit c15b03264c
2 changed files with 31 additions and 1 deletions

29
ip64tables Executable file
View File

@ -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

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
ipt=`which /sbin/iptables`
working_dir="$(dirname $(realpath $0))"
ipt="${working_dir}/ip64tables"
default_iptables_chain=custom-`hostname -s`