Gotta love it when you have dos/win line endings unintentionally

master
bbruns@gmail.com 2014-03-29 16:53:22 +00:00
parent c5a90a5522
commit b0ba377ca4
8 changed files with 327 additions and 327 deletions

View File

@ -1,71 +1,71 @@
#/bin/bash #/bin/bash
# By Brielle Bruns <bruns@2mbit.com> # By Brielle Bruns <bruns@2mbit.com>
# URL: http://www.sosdg.org/freestuff/firewall # URL: http://www.sosdg.org/freestuff/firewall
# License: GPLv3 # License: GPLv3
# #
# Copyright (C) 2009 - 2014 Brielle Bruns # Copyright (C) 2009 - 2014 Brielle Bruns
# Copyright (C) 2009 - 2014 The Summit Open Source Development Group # Copyright (C) 2009 - 2014 The Summit Open Source Development Group
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Static config options, normally do not need to change # Static config options, normally do not need to change
FW_VERSION="2.0" FW_VERSION="2.0"
# Important directory locations # Important directory locations
FWPREFIX="/usr/local" FWPREFIX="/usr/local"
FWCONFIGDIR="${FWPREFIX}/etc/srfirewall" FWCONFIGDIR="${FWPREFIX}/etc/srfirewall"
FWLIBDIR="${FWPREFIX}/lib/srfirewall" FWLIBDIR="${FWPREFIX}/lib/srfirewall"
FWBINDIR="${FWPREFIX}/bin" FWBINDIR="${FWPREFIX}/bin"
# Begin sourcing critical files, because we need things like path right away # Begin sourcing critical files, because we need things like path right away
source "${FWCONFIGDIR}/main.conf" source "${FWCONFIGDIR}/main.conf"
source "${FWLIBDIR}/binaries.inc" source "${FWLIBDIR}/binaries.inc"
source "${FWLIBDIR}/iptables.inc" source "${FWLIBDIR}/iptables.inc"
source "${FWLIBDIR}/display.inc" source "${FWLIBDIR}/display.inc"
source "${FWCONFIGDIR}/chains.conf" source "${FWCONFIGDIR}/chains.conf"
source "${FWCONFIGDIR}/ipv4.conf" source "${FWCONFIGDIR}/ipv4.conf"
source "${FWCONFIGDIR}/ipv6.conf" source "${FWCONFIGDIR}/ipv6.conf"
# We require at least bash v3 or later at this point given some of the more complex # We require at least bash v3 or later at this point given some of the more complex
# operations we do to make the firewall script work. # operations we do to make the firewall script work.
if (( ${BASH_VERSINFO[0]} <= "2" )); then if (( ${BASH_VERSINFO[0]} <= "2" )); then
echo "Error: We can only run with bash 3.0 or higher. Please upgrade your version" echo "Error: We can only run with bash 3.0 or higher. Please upgrade your version"
echo "of bash to something more recent, preferably the latest which is, as of this" echo "of bash to something more recent, preferably the latest which is, as of this"
echo "writing, 4.x" echo "writing, 4.x"
exit 1 exit 1
fi fi
# Swap out display_c command for dummy command if they don't want # Swap out display_c command for dummy command if they don't want
# output when command is run. # output when command is run.
if [[ "${DisplayDetailedOutput" == "yes" ]]; then if [[ "${DisplayDetailedOutput" == "yes" ]]; then
display="display_c" display="display_c"
else else
display="true" display="true"
fi fi
if [[ "${EnableIPv4}" == "yes" ]]; then if [[ "${EnableIPv4}" == "yes" ]]; then
# First flush all rules # First flush all rules
iptables_rules_flush ipv4 iptables_rules_flush ipv4
# Create the chain sets we'll need and the ones that can be # Create the chain sets we'll need and the ones that can be
# customized by users in their custom rules # customized by users in their custom rules
setup_iptables_chains ipv4 setup_iptables_chains ipv4
fi fi
if [[ "${EnableIPv6}" == "yes" ]]; then if [[ "${EnableIPv6}" == "yes" ]]; then
# First flush all rules # First flush all rules
iptables_rules_flush ipv6 iptables_rules_flush ipv6
fi fi

View File

@ -1,14 +1,14 @@
# Chain name mapping # Chain name mapping
# Don't change these unless you know what your doing # Don't change these unless you know what your doing
InPreRules="In-PreRules" InPreRules="In-PreRules"
OutPreRules="Out-PreRules" OutPreRules="Out-PreRules"
Trusted="In-Trusted" Trusted="In-Trusted"
InEasyBlock="In-EasyBlock" InEasyBlock="In-EasyBlock"
OutEasyBlock="Out-EasyBlock" OutEasyBlock="Out-EasyBlock"
InFilter="In-Filter" InFilter="In-Filter"
OutFilter="Out-Filter" OutFilter="Out-Filter"
NAT="NAT" NAT="NAT"
PortForward="PortForward" PortForward="PortForward"
InPostRules="In-PostRules" InPostRules="In-PostRules"
OutPostRules="Out-PostRules" OutPostRules="Out-PostRules"

View File

@ -1,14 +1,14 @@
# These are the custom files that can be used to inject rules during loading. Please don't change them # These are the custom files that can be used to inject rules during loading. Please don't change them
# unless you have a good reason. # unless you have a good reason.
# To allow variable propagation/change and some creative changes of rules that I haven't tought of, # To allow variable propagation/change and some creative changes of rules that I haven't tought of,
# these files are sourced into the main file during setup of the order of chains. # these files are sourced into the main file during setup of the order of chains.
$V4CUSTPREFIX="${FWPREFIX}/ipv4/" $V4CUSTPREFIX="${FWPREFIX}/ipv4/"
$v4_Custom_Pre="$V4CUSTPREFIX/prerun.sh" $v4_Custom_Pre="$V4CUSTPREFIX/prerun.sh"
$v4_Custom_Trust="$V4CUSTPREFIX/trusted.sh" $v4_Custom_Trust="$V4CUSTPREFIX/trusted.sh"
$v4_Custom_EasyBlock="$V4CUSTPREFIX/easyblock.sh" $v4_Custom_EasyBlock="$V4CUSTPREFIX/easyblock.sh"
$v4_Custom_Filter="$V4CUSTPREFIX/filter.sh" $v4_Custom_Filter="$V4CUSTPREFIX/filter.sh"
$v4_Custom_NAT="$V4CUSTPREFIX/nat.sh" $v4_Custom_NAT="$V4CUSTPREFIX/nat.sh"
$v4_Custom_PortFw="$V4CUSTPREFIX/portfw.sh" $v4_Custom_PortFw="$V4CUSTPREFIX/portfw.sh"
$v4_Custom_Post="$V4CUSTPREFIX/postrun.sh" $v4_Custom_Post="$V4CUSTPREFIX/postrun.sh"

View File

@ -1,14 +1,14 @@
# These are the custom files that can be used to inject rules during loading. Please don't change them # These are the custom files that can be used to inject rules during loading. Please don't change them
# unless you have a good reason. # unless you have a good reason.
# To allow variable propagation/change and some creative changes of rules that I haven't tought of, # To allow variable propagation/change and some creative changes of rules that I haven't tought of,
# these files are sourced into the main file during setup of the order of chains. # these files are sourced into the main file during setup of the order of chains.
$V6CUSTPREFIX="${FWPREFIX}/ipv6/" $V6CUSTPREFIX="${FWPREFIX}/ipv6/"
$v6_Custom_Pre="$V6CUSTPREFIX/prerun.sh" $v6_Custom_Pre="$V6CUSTPREFIX/prerun.sh"
$v6_Custom_Trust="$V6CUSTPREFIX/trusted.sh" $v6_Custom_Trust="$V6CUSTPREFIX/trusted.sh"
$v6_Custom_EasyBlock="$V6CUSTPREFIX/easyblock.sh" $v6_Custom_EasyBlock="$V6CUSTPREFIX/easyblock.sh"
$v6_Custom_Filter="$V6CUSTPREFIX/filter.sh" $v6_Custom_Filter="$V6CUSTPREFIX/filter.sh"
$v6_Custom_NAT="$V6CUSTPREFIX/nat.sh" $v6_Custom_NAT="$V6CUSTPREFIX/nat.sh"
$v6_Custom_PortFw="$V6CUSTPREFIX/portfw.sh" $v6_Custom_PortFw="$V6CUSTPREFIX/portfw.sh"
$v6_Custom_Post="$V6CUSTPREFIX/postrun.sh" $v6_Custom_Post="$V6CUSTPREFIX/postrun.sh"

View File

@ -1,11 +1,11 @@
# Main Configuration File # Main Configuration File
# Define a prefix for important locations of binaries # Define a prefix for important locations of binaries
PREFIX="/bin:/sbin:/usr/bin:/usr/sbin:${PREFIX}" PREFIX="/bin:/sbin:/usr/bin:/usr/sbin:${PREFIX}"
# Enable / Disable IPv4 and IPv6 support (yes/no) # Enable / Disable IPv4 and IPv6 support (yes/no)
EnableIPv4=yes EnableIPv4=yes
EnableIPv6=yes EnableIPv6=yes
# Display detailed output while running script? # Display detailed output while running script?
EnableDetailedOutput=yes EnableDetailedOutput=yes

View File

@ -1,24 +1,24 @@
#!/bin/bash #!/bin/bash
# By Brielle Bruns <bruns@2mbit.com> # By Brielle Bruns <bruns@2mbit.com>
# URL: http://www.sosdg.org/freestuff/firewall # URL: http://www.sosdg.org/freestuff/firewall
# License: GPLv3 # License: GPLv3
# #
# Copyright (C) 2009 - 2014 Brielle Bruns # Copyright (C) 2009 - 2014 Brielle Bruns
# Copyright (C) 2009 - 2014 The Summit Open Source Development Group # Copyright (C) 2009 - 2014 The Summit Open Source Development Group
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Try and set some sane defaults for common binaries we need. Can always override them later. # Try and set some sane defaults for common binaries we need. Can always override them later.
MODPROBE=`which modprobe` MODPROBE=`which modprobe`
IPTABLES=`which iptables` IPTABLES=`which iptables`
IP6TABLES=`which ip6tables` IP6TABLES=`which ip6tables`

View File

@ -1,82 +1,82 @@
#!/bin/bash #!/bin/bash
# By Brielle Bruns <bruns@2mbit.com> # By Brielle Bruns <bruns@2mbit.com>
# URL: http://www.sosdg.org/freestuff/firewall # URL: http://www.sosdg.org/freestuff/firewall
# License: GPLv3 # License: GPLv3
# #
# Copyright (C) 2009 - 2014 Brielle Bruns # Copyright (C) 2009 - 2014 Brielle Bruns
# Copyright (C) 2009 - 2014 The Summit Open Source Development Group # Copyright (C) 2009 - 2014 The Summit Open Source Development Group
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# ANSI color sequences # ANSI color sequences
BLUE="\E[34m" BLUE="\E[34m"
GREEN="\E[32m" GREEN="\E[32m"
RED="\E[31m" RED="\E[31m"
YELLOW="\E[33m" YELLOW="\E[33m"
PURPLE="\E[35m" PURPLE="\E[35m"
AQUA="\E[36m" AQUA="\E[36m"
WHITE="\E[1m" WHITE="\E[1m"
GREY="\E[37m" GREY="\E[37m"
DEFAULT_COLOR="\E[39m" DEFAULT_COLOR="\E[39m"
# display_c $COLOR $TEXT BOOL(YN) # display_c $COLOR $TEXT BOOL(YN)
# $COLOR being bash colors # $COLOR being bash colors
# $TEXT being what to output (make sure to put " " around text) # $TEXT being what to output (make sure to put " " around text)
# BOOL being (Y or N) to do newline at end or not # BOOL being (Y or N) to do newline at end or not
function display_c { function display_c {
unset COLOR_CODE TEXT NEWLINE unset COLOR_CODE TEXT NEWLINE
DEFAULT_COLOR="\E[39m" DEFAULT_COLOR="\E[39m"
COLOR_CODE=`pick_color $1` COLOR_CODE=`pick_color $1`
TEXT="$2" TEXT="$2"
if [ "$3" == "N" ]; then if [ "$3" == "N" ]; then
NEWLINE="-n" NEWLINE="-n"
fi fi
echo -e ${NEWLINE} "${COLOR_CODE}${TEXT}${DEFAULT_COLOR}" echo -e ${NEWLINE} "${COLOR_CODE}${TEXT}${DEFAULT_COLOR}"
} }
# pick_color $COLOR # pick_color $COLOR
# returns appropriate color codes for use in display_c and such # returns appropriate color codes for use in display_c and such
function pick_color { function pick_color {
case $1 in case $1 in
BLUE) COLOR="\E[34m" ;; BLUE) COLOR="\E[34m" ;;
GREEN) COLOR="\E[32m" ;; GREEN) COLOR="\E[32m" ;;
RED) COLOR="\E[31m" ;; RED) COLOR="\E[31m" ;;
YELLOW) COLOR="\E[33m" ;; YELLOW) COLOR="\E[33m" ;;
PURPLE) COLOR="\E[35m" ;; PURPLE) COLOR="\E[35m" ;;
AQUA) COLOR="\E[36m" ;; AQUA) COLOR="\E[36m" ;;
WHITE) COLOR="\E[1m" ;; WHITE) COLOR="\E[1m" ;;
GREY) COLOR="\E[37m" ;; GREY) COLOR="\E[37m" ;;
*) COLOR="\E[37m" ;; *) COLOR="\E[37m" ;;
esac esac
echo "${COLOR}" echo "${COLOR}"
} }
# reset_color # reset_color
function reset_color { function reset_color {
unset NEWLINE unset NEWLINE
DEFAULT_COLOR="\E[39m" DEFAULT_COLOR="\E[39m"
if [ "$1" == "N" ]; then if [ "$1" == "N" ]; then
NEWLINE="-n" NEWLINE="-n"
fi fi
echo ${NEWLINE} -e "${DEFAULT_COLOR}" echo ${NEWLINE} -e "${DEFAULT_COLOR}"
} }
# show_help # show_help
# Show command line options help # Show command line options help
function show_help { function show_help {
echo "Firewall/SOSDG ${FW_VERSION} - Brielle Bruns <bruns@2mbit.com>" echo "Firewall/SOSDG ${FW_VERSION} - Brielle Bruns <bruns@2mbit.com>"
echo -e "\t--help\t\tShows this info" echo -e "\t--help\t\tShows this info"
echo -e "\t--flush\t\tFlushes all rules back to default ACCEPT" echo -e "\t--flush\t\tFlushes all rules back to default ACCEPT"
echo -e "\t--generate-cache\tGenerate cached rule file" echo -e "\t--generate-cache\tGenerate cached rule file"
} }

View File

@ -1,104 +1,104 @@
#!/bin/bash #!/bin/bash
# By Brielle Bruns <bruns@2mbit.com> # By Brielle Bruns <bruns@2mbit.com>
# URL: http://www.sosdg.org/freestuff/firewall # URL: http://www.sosdg.org/freestuff/firewall
# License: GPLv3 # License: GPLv3
# #
# Copyright (C) 2009 - 2014 Brielle Bruns # Copyright (C) 2009 - 2014 Brielle Bruns
# Copyright (C) 2009 - 2014 The Summit Open Source Development Group # Copyright (C) 2009 - 2014 The Summit Open Source Development Group
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# iptables_rules_flush (ipv6|ipv4) # iptables_rules_flush (ipv6|ipv4)
# Clear all rules from iptables - be very careful in how this is called as it # Clear all rules from iptables - be very careful in how this is called as it
# could easily lock out the user from the network. Best way to be safe, is to # could easily lock out the user from the network. Best way to be safe, is to
# call iptables_policy_reset first then this function. # call iptables_policy_reset first then this function.
function iptables_rules_flush { function iptables_rules_flush {
IP_VERSION=$1 IP_VERSION=$1
case $IP_VERSION in case $IP_VERSION in
ipv6) VER_IPTABLES=${IP6TABLES} ; TABLE_NAMES=/proc/net/ip6_tables_names ;; ipv6) VER_IPTABLES=${IP6TABLES} ; TABLE_NAMES=/proc/net/ip6_tables_names ;;
ipv4|*) VER_IPTABLES=${IPTABLES} ; TABLE_NAMES=/proc/net/ip_tables_names ;; ipv4|*) VER_IPTABLES=${IPTABLES} ; TABLE_NAMES=/proc/net/ip_tables_names ;;
esac esac
${display_c} RED "Flushing ${IP_VERSION} rules..." ${display_c} RED "Flushing ${IP_VERSION} rules..."
${VER_IPTABLES} --flush &>/dev/null ${VER_IPTABLES} --flush &>/dev/null
${VER_IPTABLES} -F OUTPUT &>/dev/null ${VER_IPTABLES} -F OUTPUT &>/dev/null
${VER_IPTABLES} -F PREROUTING &>/dev/null ${VER_IPTABLES} -F PREROUTING &>/dev/null
${VER_IPTABLES} -F POSTROUTING &>/dev/null ${VER_IPTABLES} -F POSTROUTING &>/dev/null
for i in `cat $TABLE_NAMES`; do for i in `cat $TABLE_NAMES`; do
${VER_IPTABLES} -F -t $i &>/dev/null ${VER_IPTABLES} -F -t $i &>/dev/null
done done
${VER_IPTABLES} -X ${VER_IPTABLES} -X
} }
# iptables_policy_set (ipv6|ipv4) (ACCEPT|DROP) # iptables_policy_set (ipv6|ipv4) (ACCEPT|DROP)
# Sets all policy rules to either ACCEPT or DROP for ipv4 or ipv6 # Sets all policy rules to either ACCEPT or DROP for ipv4 or ipv6
# If no policy given, assume ACCEPT # If no policy given, assume ACCEPT
function iptables_policy_reset { function iptables_policy_reset {
IP_VERSION=$1 IP_VERSION=$1
SET_POLICY=${2=ACCEPT} SET_POLICY=${2=ACCEPT}
case $IP_VERSION in case $IP_VERSION in
ipv6) VER_IPTABLES=${IP6TABLES} ;; ipv6) VER_IPTABLES=${IP6TABLES} ;;
ipv4|*) VER_IPTABLES=${IPTABLES} ;; ipv4|*) VER_IPTABLES=${IPTABLES} ;;
esac esac
${display_c} RED "Setting ${IP_VERSION} policies to ${SET_POLICY}..." ${display_c} RED "Setting ${IP_VERSION} policies to ${SET_POLICY}..."
${VER_IPTABLES} --policy INPUT ${SET_POLICY} ${VER_IPTABLES} --policy INPUT ${SET_POLICY}
${VER_IPTABLES} --policy OUTPUT ${SET_POLICY} ${VER_IPTABLES} --policy OUTPUT ${SET_POLICY}
${VER_IPTABLES} --policy FORWARD ${SET_POLICY} ${VER_IPTABLES} --policy FORWARD ${SET_POLICY}
} }
# setup_iptables_chains (ipv4|ipv6) # setup_iptables_chains (ipv4|ipv6)
# Creates the default chains when called # Creates the default chains when called
function setup_iptables_chains { function setup_iptables_chains {
IP_VERSION=$1 IP_VERSION=$1
case $IP_VERSION in case $IP_VERSION in
ipv6) VER_IPTABLES=${IP6TABLES}; ipv6) VER_IPTABLES=${IP6TABLES};
IPVER="6" ;; IPVER="6" ;;
ipv4|*) VER_IPTABLES=${IPTABLES} ipv4|*) VER_IPTABLES=${IPTABLES}
IPVER="4" ;; IPVER="4" ;;
esac esac
# Create the actual chains # Create the actual chains
${display_c} GREEN "Setting up chains for ${IP_VERSION}..." ${display_c} GREEN "Setting up chains for ${IP_VERSION}..."
${VER_IPTABLES} -N ${InPreRules} ${VER_IPTABLES} -N ${InPreRules}
${VER_IPTABLES} -N ${OutPreRules} ${VER_IPTABLES} -N ${OutPreRules}
${VER_IPTABLES} -N ${Trusted} ${VER_IPTABLES} -N ${Trusted}
${VER_IPTABLES} -N ${InEasyBlock} ${VER_IPTABLES} -N ${InEasyBlock}
${VER_IPTABLES} -N ${OutEasyBlock} ${VER_IPTABLES} -N ${OutEasyBlock}
${VER_IPTABLES} -N ${InFilter} ${VER_IPTABLES} -N ${InFilter}
${VER_IPTABLES} -N ${OutFilter} ${VER_IPTABLES} -N ${OutFilter}
${VER_IPTABLES} -N ${FwdFilter} ${VER_IPTABLES} -N ${FwdFilter}
${VER_IPTABLES} -N ${NAT} ${VER_IPTABLES} -N ${NAT}
${VER_IPTABLES} -N ${PortForward} ${VER_IPTABLES} -N ${PortForward}
${VER_IPTABLES} -N ${InPostRules} ${VER_IPTABLES} -N ${InPostRules}
${VER_IPTABLES} -N ${OutPostRules} ${VER_IPTABLES} -N ${OutPostRules}
# Set up rules - the order matters - we do it separately here # Set up rules - the order matters - we do it separately here
# for easy viewing of order # for easy viewing of order
if [ -x ${v${IPVER}_Custom_Pre} ]; then . ${v${IPVER}_Custom_Pre}; fi if [ -x ${v${IPVER}_Custom_Pre} ]; then . ${v${IPVER}_Custom_Pre}; fi
${VER_IPTABLES} -A INPUT -j ${InPreRules} ${VER_IPTABLES} -A INPUT -j ${InPreRules}
${VER_IPTABLES} -A OUTPUT -j ${OutPreRules} ${VER_IPTABLES} -A OUTPUT -j ${OutPreRules}
if [ -x ${v${IPVER}_Custom_Trust} ]; then . ${v${IPVER}_Custom_Trust}; fi if [ -x ${v${IPVER}_Custom_Trust} ]; then . ${v${IPVER}_Custom_Trust}; fi
${VER_IPTABLES} -A INPUT -j ${Trusted} ${VER_IPTABLES} -A INPUT -j ${Trusted}
if [ -x ${v${IPVER}_Custom_EasyBlock} ]; then . ${v${IPVER}_Custom_EasyBlock}; fi if [ -x ${v${IPVER}_Custom_EasyBlock} ]; then . ${v${IPVER}_Custom_EasyBlock}; fi
${VER_IPTABLES} -A INPUT -j ${InEasyBlock} ${VER_IPTABLES} -A INPUT -j ${InEasyBlock}
${VER_IPTABLES} -A OUTPUT -j ${OutEasyBlock} ${VER_IPTABLES} -A OUTPUT -j ${OutEasyBlock}
if [ -x ${v${IPVER}_Custom_Filter} ]; then . ${v${IPVER}_Custom_Filter}; fi if [ -x ${v${IPVER}_Custom_Filter} ]; then . ${v${IPVER}_Custom_Filter}; fi
${VER_IPTABLES} -A INPUT -j ${InFilter} ${VER_IPTABLES} -A INPUT -j ${InFilter}
${VER_IPTABLES} -A OUTPUT -j ${OutFilter} ${VER_IPTABLES} -A OUTPUT -j ${OutFilter}
${VER_IPTABLES} -A FORWARD -j ${FwdFilter} ${VER_IPTABLES} -A FORWARD -j ${FwdFilter}
if [ -x ${v${IPVER}_Custom_NAT} ]; then . ${v${IPVER}_Custom_NAT}; fi if [ -x ${v${IPVER}_Custom_NAT} ]; then . ${v${IPVER}_Custom_NAT}; fi
${VER_IPTABLES} -A POSTROUTING -j ${NAT} ${VER_IPTABLES} -A POSTROUTING -j ${NAT}
if [ -x ${v${IPVER}_Custom_PortFw} ]; then . ${v${IPVER}_Custom_PortFw}; fi if [ -x ${v${IPVER}_Custom_PortFw} ]; then . ${v${IPVER}_Custom_PortFw}; fi
${VER_IPTABLES} -A PREROUTING -j ${PortForward} ${VER_IPTABLES} -A PREROUTING -j ${PortForward}
if [ -x ${v${IPVER}_Custom_Post} ]; then . ${v${IPVER}_Custom_Post}; fi if [ -x ${v${IPVER}_Custom_Post} ]; then . ${v${IPVER}_Custom_Post}; fi
${VER_IPTABLES} -A INPUT -j ${InPostRules} ${VER_IPTABLES} -A INPUT -j ${InPostRules}
${VER_IPTABLES} -A OUTPUT -j ${OutPostRules} ${VER_IPTABLES} -A OUTPUT -j ${OutPostRules}
} }