Compare commits

...

42 Commits

Author SHA1 Message Date
Brie Bruns 423f6caff4 Add information for release 2021-09-02 15:41:37 -06:00
Brie Bruns f82d1fa2cd Add information for release 2021-09-02 15:37:32 -06:00
Brie Bruns 182651e108 Update information for release 2021-09-02 15:33:38 -06:00
Brie Bruns 3e54d20c78 Merge branch 'master' of https://git.sosdg.org/brielle/SRFirewall 2021-04-17 16:50:16 -06:00
Brie Bruns dab267b561 Release 2.2.1 2021-04-17 16:49:43 -06:00
Brie Bruns 582335b190 Release 2.2.1 2021-04-17 16:33:54 -06:00
Brie Bruns a0d5687567 Add IPTABLESOPT 2021-04-17 16:30:22 -06:00
Brie Bruns 33261c140e no message 2020-04-09 10:46:13 -06:00
Brie Bruns 3e7c254037 Hopefully fix for error 2020-04-09 10:43:38 -06:00
Brie Bruns 6a2589b8f2 Multiport support for v2.2 2020-04-09 10:15:22 -06:00
Brie Bruns 1ea92aa558 Add multiport functionality test 2020-04-09 09:50:52 -06:00
Brie Bruns cba6893c41 Bug fix NAT rule variable not being reset 2020-02-27 18:26:30 -07:00
Brie Bruns 11003d6b04 no message 2020-01-01 13:52:48 -07:00
Brie Bruns 710a25efbd no message 2020-01-01 13:48:03 -07:00
Brie Bruns 5167ee91fe no message 2020-01-01 13:46:15 -07:00
Brie Bruns e46fdf98a1 no message 2020-01-01 13:44:57 -07:00
Brie Bruns 61d32e9da0 no message 2020-01-01 13:40:32 -07:00
Brie Bruns d0208b0006 Make sure src interface is added 2020-01-01 13:38:04 -07:00
Brie Bruns 01fe8d5ec6 More fixes with NETMAP. This time, lets put rules with -src interface in them in the PREROUTING chain. 2020-01-01 13:35:11 -07:00
Brie Bruns 5eb6c581e6 no message 2020-01-01 13:02:46 -07:00
Brie Bruns ae9a725e8c Refactor NETMAP a bit so it allows more flexibility with src and dst. Requires that the custom field starts with the --to address. 2020-01-01 12:53:42 -07:00
Brie Bruns ca06b76fc2 2.1p1 to fix NETMAP issue 2020-01-01 11:57:04 -07:00
Brie Bruns f8cb8b11e2 Release tag for 2.1 final 2019-07-12 13:19:03 -06:00
Brie Bruns 1bfe6ded80 Add purge/delete rules for raw on flush 2019-07-12 13:14:51 -06:00
Brie Bruns be7e18539f Fix +x bit 2018-11-19 10:52:22 -07:00
Brie Bruns b19d4156d2 Add before/after run commands 2018-11-19 10:50:00 -07:00
Brie Bruns fa09ce18f9 Fix for mss clamping 2016-04-25 17:07:08 -06:00
Brie Bruns c2fe6eb39c Fix for mss clamping 2016-04-25 17:06:52 -06:00
Brie Bruns 965308dea4 2.1a3 2016-04-25 11:02:34 -06:00
Brie Bruns d50d918921 Fix issue with erasing variables in postfw 2016-04-25 10:40:45 -06:00
Brie Bruns ddffbcd998 Fix issue with erasing variables in service setup 2016-04-25 10:37:23 -06:00
Brie Bruns f13c0fc66c Oops, mss clamp not allowed on input chain 2015-05-29 11:47:15 -06:00
Brie Bruns 7e4cac96fa Some fixes for mss clamping 2015-05-29 11:45:05 -06:00
Brie Bruns 9359020bac Some fixes for mss clamping 2015-05-29 11:37:20 -06:00
Brie Bruns c01a1b62e3 Fix 'all' option for mss clamp 2015-04-09 15:37:55 -06:00
Brie Bruns 52e74f4b3f Fix 'all' option for mss clamp 2015-04-09 15:35:54 -06:00
Brie Bruns dcb0e19acc Fix 'all' option for mss clamp 2015-04-09 15:32:21 -06:00
Brie Bruns 78772c0cdf Add 'all' option for mss clamp 2015-04-09 15:27:01 -06:00
Brie Bruns d731b0ce61 2.1a2 release 2015-03-15 15:26:46 -06:00
Brie Bruns ab3b2f052f Unset variables to prevent variable leakage 2015-03-15 15:21:58 -06:00
Brie Bruns fe1d436c1f Unset variables to prevent variable leakage 2015-03-15 15:10:54 -06:00
Brie Bruns 6d0b13c194 Adding release.json for use with sites that support it 2014-11-29 13:21:27 -07:00
11 changed files with 166 additions and 36 deletions

View File

@ -1,3 +1,34 @@
2.2.1 - 04/17/2021
- Add support for iptables options via IPTABLESOPT and IP6TABLESOPT. These options are
applied at the beginning of the command line options to EVERY instance of $IPTABLES.
Useful for '-w' to deal with xtables lock issues.
2.2 - 04/09/2020
- Add multiport support to acl/forward
2.1p2 - 02/27/2020
- Fix issue with NAT variable not being reset after being changed
2.1p1 - 01/01/2020
- Refactor NETMAP NAT target so its more flexible. See new example nat.conf file for details
2.1 Final - 07/12/2019
- Fix flush tables rule for raw
- Final 2.1 release since we've had 2.1 for 5 years now without being 'released'
2.1 Beta 1 - 11/19/2018
- Add run-after and run-before rules (custom/runafter.sh and custom/runbefore.sh)
2.1 Alpha 3 - 04/25/2016
- Fix issue with erasing variables in two different setups
- mss clamp fix for fwd target
2.1 Alpha 2 - 03/15/2015
- Unset variables in loops to make sure theres no leakage of
variables into the next run of the loop
04/09/2015
- Allow use of 'all' in MSS rules to match all forwarding/out traffic
2.1 Alpha 1 - 11/29/2014
- Added support for custom fields in NAT and ACL rules, as this allows
definition of Policy rules in the ACL files (mostly useful for IPSec)

12
INSTALL
View File

@ -1,4 +1,4 @@
SRFirewall v2.0 http://www.sosdg.org/freestuff/firewall
SRFirewall v2.2.1 http://www.sosdg.org/freestuff/firewall
Written by: Brielle Bruns <bruns@2mbit.com>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@ -21,14 +21,14 @@ it:
=== Begin commands ===
cd /usr/src
svn checkout http://firewall-sosdg.googlecode.com/svn/srfirewall srfirewall-trunk
ln -s /usr/src/srfirewall-trunk/lib /usr/local/lib/srfirewall
ln -s /usr/src/srfirewall-trunk/bin/srfirewall /usr/local/bin/srfirewall
cp -R /usr/src/srfirewall-trunk/etc /usr/local/etc/srfirewall
git clone https://git.sosdg.org/brielle/SRFirewall.git
ln -s /usr/src/srfirewall/lib /usr/local/lib/srfirewall
ln -s /usr/src/srfirewall/bin/srfirewall /usr/local/bin/srfirewall
cp -R /usr/src/srfirewall/etc /usr/local/etc/srfirewall
=== End commands ===
Then when you want to update to bleeding edge, all you have to run is
'svn update'.
'git pull'.
You _will_ need to look for newly changed/added files and update
appropriately.

2
README
View File

@ -1,4 +1,4 @@
SRFirewall v2.1
SRFirewall v2.2.1
http://www.sosdg.org/freestuff/firewall
Written by: Brielle Bruns <bruns@2mbit.com>

View File

@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Static config options, normally do not need to change
FW_VERSION="2.1a1"
FW_VERSION="2.2.1"
# Important directory locations
FWPREFIX="/usr/local"
@ -155,6 +155,16 @@ if [ ! -e "/proc/net/ip6_tables_names" ] && [ "${EnableIPv6}" == "yes" ] && [ "$
fi
fi
# Splice in iptables options via IPTABLESOPT and IP6TABLESOPT
if [ -x "${IPTABLES}" ] && [ -x "${IPTABLESOPT}" ]; then
IPTABLES="${IPTABLES} ${IPTABLESOPT}"
fi
if [ -x "${IP6TABLES}" ] && [ -x "${IP6TABLESOPT}" ]; then
IPTABLES="${IP6TABLES} ${IP6TABLESOPT}"
fi
# Set up proper state matching variables, since there is old and new style.
if [ "$StateMatching" ]; then
case $StateMatching in
@ -174,6 +184,10 @@ fi
# Do IPv4 IPTables Rules
if [ "${EnableIPv4}" == "yes" ]; then
# Commands to run before everything else
if [ -x ${FWCONFIGDIR}/ipv4/custom/runbefore.sh ]; then . ${FWCONFIGDIR}/ipv4/custom/runbefore.sh; fi
# First flush all rules
iptables_rules_flush ipv4
@ -203,10 +217,16 @@ if [ "${EnableIPv4}" == "yes" ]; then
[[ ${Enablev4NAT} == "yes" ]] && enable_nat ipv4
[[ ${Enablev4PortForwarding} == "yes" ]] && enable_portfw ipv4
# Commands to run after everything else
if [ -x ${FWCONFIGDIR}/ipv4/custom/runafter.sh ]; then . ${FWCONFIGDIR}/ipv4/custom/runafter.sh; fi
fi
# Do IPv6 IPTables Rules
if [ "${EnableIPv6}" == "yes" ]; then
# Commands to run before everything else
if [ -x ${FWCONFIGDIR}/ipv6/custom/runbefore.sh ]; then . ${FWCONFIGDIR}/ipv6/custom/runbefore.sh; fi
# First flush all rules
iptables_rules_flush ipv6
@ -237,5 +257,7 @@ if [ "${EnableIPv6}" == "yes" ]; then
[[ ${Enablev6NAT} == "yes" ]] && enable_nat ipv6
[[ ${Enablev6PortForwarding} == "yes" ]] && enable_portfw ipv6
[[ ${EnableSysctlTweaks} == "yes" ]] && sysctl_tweaks
# Commands to run after everything else
if [ -x ${FWCONFIGDIR}/ipv6/custom/runafter.sh ]; then . ${FWCONFIGDIR}/ipv6/custom/runafter.sh; fi
fi

6
etc/ipv4/custom/runafter.sh Executable file
View File

@ -0,0 +1,6 @@
# This file is sourced by the main srfirewall program to inject
# custom commands/rules during specific moments of the firewall
# setup.
#
# In particular this file injects/commands rules:
# After all other things are done when the script loads

6
etc/ipv4/custom/runbefore.sh Executable file
View File

@ -0,0 +1,6 @@
# This file is sourced by the main srfirewall program to inject
# custom commands/rules during specific moments of the firewall
# setup.
#
# In particular this file injects/commands rules:
# Before all other things are done when the script loads

View File

@ -5,15 +5,17 @@
# <type> <src-interface> <src-address> <dst-interface> <dst-address> <custom>
#
# Type: Required ( SNAT | MASQ | NETMAP | ACCEPT)
# Source Interface: Optional ( interface name, aka eth0 )
# Source Interface: Optional, ignored by NETMAP ( interface name, aka eth0 )
# Source Address: Optional ( IP address with optional netmask )
# Destination Interface: Optional for all but MASQ ( interface name, aka eth0 )
# Destination Address: Required for all but MASQ ( IP address with optional netmask )
# Custom: Optional, set custom section after the source/dest and before ACCEPT/DROP
# Destination Address: Required for all but MASQ and NETMAP ( IP address with optional netmask )
# Custom: Optional for all except NETMAP, set custom section after the source/dest and before ACCEPT/DROP
# Custom: Required for NETMAP, address to map TO, then all other custom options (see example)
# You can use '-' for optional fields
#============================================================
#<type> <src-interface> <src-address> <dst-interface> <dst-address> <custom>
#SNAT eth1 10.0.0.0/24 eth0 172.16.1.1
#MASQ - - eth0 -
#NETMAP eth1 192.168.0.0/24 vpn0 172.16.10.0/24
#NETMAP - 192.168.0.0/24 vpn0 - 172.16.0.0/24
#^ ex: map src of 192.168.0.0/24 to 172.16.0.0/24 when it leaves via vpn0

6
etc/ipv6/custom/runafter.sh Executable file
View File

@ -0,0 +1,6 @@
# This file is sourced by the main srfirewall program to inject
# custom commands/rules during specific moments of the firewall
# setup.
#
# In particular this file injects/commands rules:
# After all other things are done when the script loads

6
etc/ipv6/custom/runbefore.sh Executable file
View File

@ -0,0 +1,6 @@
# This file is sourced by the main srfirewall program to inject
# custom commands/rules during specific moments of the firewall
# setup.
#
# In particular this file injects/commands rules:
# Before all other things are done when the script loads

View File

@ -42,6 +42,8 @@ function iptables_rules_flush {
${VER_IPTABLES} -t nat -X &>/dev/null
${VER_IPTABLES} -t mangle -F &>/dev/null
${VER_IPTABLES} -t mangle -X &>/dev/null
${VER_IPTABLES} -t raw -F &>/dev/null
${VER_IPTABLES} -t raw -X &>/dev/null
for i in `cat $TABLE_NAMES`; do
${VER_IPTABLES} -F -t $i &>/dev/null
done
@ -175,19 +177,25 @@ function enable_mss_clamp {
while read -r interface mss type msssize; do
[[ ${interface} = \#* ]] && continue
[[ ${interface} = "" ]] && continue
[[ -z ${mss} ]] && mss="-"
[[ ${mss} == "-" ]] && mss="1400:1536"
[[ ${interface} == "all" ]] && isallinterfaces="yes"
#[[ -z ${mss} ]] && mss="-"
[[ ${mss} != "-" ]] && mss="-m tcpmss --mss ${mss}"
[[ ${mss} == "-" ]] && mss=""
[[ -z ${type} ]] && type="-"
[[ ${type} == "-" ]] && type="${OutFilter}"
[[ ${type} == "-" ]] && type="out"
[[ ${type} == "out" ]] && type="${OutFilter}"
[[ ${type} == "fwd" ]] && type="${FwdFilter}"
[[ -z ${msssize} ]] && msssize="-"
[[ ${msssize} != "-" ]] && msssize="--set-mss ${msssize}"
[[ ${msssize} == "-" ]] && msssize="--clamp-mss-to-pmtu"
#[[ ${interface} != "all" ]] && interface="-o ${interface}"
[[ ${type} == "${OutFilter}" ]] && interface="-o ${interface}"
[[ ${type} == "${FwdFilter}" ]] && interface="-o ${interface}"
[[ ${isallinterfaces} == "yes" ]] && interface=""
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} Read: ${interface} ${mss} ${type} ${msssize}"
${VER_IPTABLES} -A ${type} -p tcp --tcp-flags SYN,RST SYN -j TCPMSS \
-o ${interface} -m tcpmss --mss ${mss} ${msssize}
unset interface mss type msssize
${interface} ${mss} ${msssize}
unset interface mss type msssize isallinterfaces
done < "${FWCONFIGDIR}/ipv${IPVER}/mss-clamp.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
@ -330,8 +338,8 @@ function enable_filtering {
[[ -z ${state} ]] && state="-"
([[ ${IP_VERSION} == "ipv4" ]] && [[ ${Enablev4ConnectionTracking} == "yes" ]] && [[ ! ${state} == "-" ]]) && conntrack_state="${M_STATE} ${C_STATE} ${state}"
([[ ${IP_VERSION} == "ipv6" ]] && [[ ${Enablev6ConnectionTracking} == "yes" ]] && [[ ! ${state} == "-" ]]) && conntrack_state="${M_STATE} ${C_STATE} ${state}"
[[ ${dstport} != "-" ]] && dstport="--dport ${dstport}"
[[ ${srcport} != "-" ]] && srcport="--sport ${srcport}"
#[[ ${dstport} != "-" ]] && dstport="--dport ${dstport}"
#[[ ${srcport} != "-" ]] && srcport="--sport ${srcport}"
[[ ${srcaddress} != "-" ]] && srcaddress="-s ${srcaddress}"
[[ ${dstaddress} != "-" ]] && dstaddress="-d ${dstaddress}"
([[ ${interface} != "-" ]] && [[ ${direction} == "IN" ]]) && interface="-i ${interface}"
@ -345,6 +353,15 @@ function enable_filtering {
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR}${direction} ${action} ${interface} ${srcaddress} ${srcport} ${dstaddress} ${dstport} ${protocol} ${syn} ${custom}"
dstmultiport="no"
srcmultiport="no"
([[ ${dstport} != "-" ]] && [[ ${dstport} =~ (-|:|,) ]]) && dstmultiport="yes"
([[ ${srcport} != "-" ]] && [[ ${srcport} =~ (-|:|,) ]]) && srcmultiport="yes"
([[ ${dstport} != "-" ]] && [[ ${dstmultiport} != "yes" ]]) && dstport="--dport ${dstport}"
([[ ${srcport} != "-" ]] && [[ ${srcmultiport} != "yes" ]]) && srcport="--dport ${srcport}"
([[ ${dstport} != "-" ]] && [[ ${dstmultiport} == "yes" ]]) && dstport="-m multiport --dports ${dstport}"
([[ ${srcport} != "-" ]] && [[ ${srcmultiport} == "yes" ]]) && srcport="-m multiport --sports ${srcport}"
# Blank variables that we're not going to use.
[[ ${interface} == "-" ]] && interface=""
[[ ${dstport} == "-" ]] && dstport=""
@ -356,6 +373,7 @@ function enable_filtering {
[[ ${custom} == "-" ]] && custom=""
${VER_IPTABLES} -A ${chain} ${interface} ${protocol} ${srcaddress} ${srcport} ${syn} ${dstaddress} ${dstport} ${conntrack_state} ${custom} -j ${action}
unset direction action interface srcaddress srcport dstaddress dstport protocol syn state custom conntrack_state
done < "${FWCONFIGDIR}/ipv${IPVER}/acl.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
fi
@ -407,10 +425,20 @@ function enable_forwarding {
([[ ${syn} == "syn" ]] && [[ ${protocol} == "udp" ]]) && syn="-"
[[ ${syn} == "syn" ]] && syn="--syn"
[[ ${syn} == "notsyn" ]] && syn="! --syn"
[[ ${dstport} != "-" ]] && dstport="--dport ${dstport}"
[[ ${srcport} != "-" ]] && srcport="--sport ${srcport}"
([[ ${bidirectional} == "yes" ]] && [[ ${srcport} != "-" ]]) && revsrcport="--dport ${srcport}"
([[ ${bidirectional} == "yes" ]] && [[ ${dstport} != "-" ]]) && revdstport="--sport ${dstport}"
dstmultiport="no"
srcmultiport="no"
([[ ${dstport} != "-" ]] && [[ ${dstport} =~ (-|:|,) ]]) && dstmultiport="yes"
([[ ${srcport} != "-" ]] && [[ ${srcport} =~ (-|:|,) ]]) && srcmultiport="yes"
([[ ${dstport} != "-" ]] && [[ ${dstmultiport} != "yes" ]]) && dstport="--dport ${dstport}"
([[ ${srcport} != "-" ]] && [[ ${srcmultiport} != "yes" ]]) && srcport="--sport ${srcport}"
([[ ${dstport} != "-" ]] && [[ ${dstmultiport} == "yes" ]]) && dstport="-m multiport --dports ${dstport}"
([[ ${srcport} != "-" ]] && [[ ${srcmultiport} == "yes" ]]) && srcport="-m multiport --sports ${srcport}"
([[ ${bidirectional} == "yes" ]] && [[ ${srcport} != "-" ]]) && revsrcport=${srcport/sport/dport}
([[ ${bidirectional} == "yes" ]] && [[ ${dstport} != "-" ]]) && revdstport=${dstport/dport/sport}
#[[ ${dstport} != "-" ]] && dstport="--dport ${dstport}"
#[[ ${srcport} != "-" ]] && srcport="--sport ${srcport}"
#([[ ${bidirectional} == "yes" ]] && [[ ${srcport} != "-" ]]) && revsrcport="--dport ${srcport}"
#([[ ${bidirectional} == "yes" ]] && [[ ${dstport} != "-" ]]) && revdstport="--sport ${dstport}"
[[ ${protocol} != "-" ]] && protocol="-p ${protocol}"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR}${action} ${srcinterface} ${srcaddress} ${dstinterface} ${dstaddress} ${bidirectional} ${srcport} ${dstport} ${protocol} ${syn} ${state}"
@ -430,6 +458,7 @@ function enable_forwarding {
${VER_IPTABLES} -A ${FwdFilter} ${protocol} ${srcinterface} ${srcaddress} ${srcport} ${syn} ${dstinterface} ${dstaddress} ${dstport} ${conntrack_state} ${custom} -j ${action}
[[ ${bidirectional} == "yes" ]] && ${VER_IPTABLES} -A ${FwdFilter} ${protocol} ${revsrcinterface} ${revsrcaddress} ${revsrcport} ${syn} ${revdstinterface} ${revdstaddress} ${revdstport} ${conntrack_state} ${custom} -j ${action}
unset action srcinterface srcaddress dstinterface dstaddress bidirectional srcport dstport protocol syn state custom conntrack_state
done < "${FWCONFIGDIR}/ipv${IPVER}/forward.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
fi
@ -449,7 +478,9 @@ function enable_nat {
if [ -e "${FWCONFIGDIR}/ipv${IPVER}/nat.conf" ]; then
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} read ${FWCONFIGDIR}/ipv${IPVER}/nat.conf successful"
ORIG_NAT=${NAT}
while read -r type srcinterface srcaddress dstinterface dstaddress custom; do
NAT=${ORIG_NAT}
[[ ${type} = \#* ]] && continue
[[ ${type} = "" ]] && continue
([[ ${type} != "SNAT" ]] && [[ ${type} != "MASQ" ]] && [[ ${type} != "NETMAP" ]] && [[ ${type} != "ACCEPT" ]]) \
@ -459,9 +490,10 @@ function enable_nat {
#[[ ${srcaddress} != "-" ]] && revsrcaddress="-d ${srcaddress}"
#[[ ${dstinterface} != "-" ]] && revdstinterface="-i ${dstinterface}"
#[[ ${srcinterface} != "-" ]] && revsrcinterface="-o ${srcinterface}"
[[ ${srcinterface} != "-" ]] && srcinterface="-i ${srcinterface}"
#[[ ${srcinterface} != "-" ]] && srcinterface="-i ${srcinterface}"
[[ ${dstinterface} != "-" ]] && dstinterface="-o ${dstinterface}"
([[ ${srcaddress} != "-" ]] && [[ ${type} != "NETMAP" ]]) && srcaddress="-s ${srcaddress}"
[[ ${srcaddress} != "-" ]] && srcaddress="-s ${srcaddress}"
([[ ${srcinterface} != "-" ]] && [[ ${type} == "SNAT" ]]) && srcinterface="-"
([[ ${dstinterface} != "-" ]] && [[ ${type} == "MASQ" ]]) && action="-j MASQUERADE"
([[ ${dstinterface} == "-" ]] && [[ ${type} == "MASQ" ]]) && \
@ -474,7 +506,17 @@ function enable_nat {
${display} RED "nat.conf: Error - SNAT rule can not have empty destination address: ${DEFAULT_COLOR}${type} ${srcinterface} ${srcaddress} ${dstinterface} ${dstaddress}" \
&& continue
([[ ${srcaddress} != "-" ]] && [[ ${dstaddress} != "-" ]] && [[ ${type} == "NETMAP" ]]) && action="-j NETMAP" && srcaddress="-d ${srcaddress}" && dstaddress="--to ${dstaddress}"
[[ ${type} == "NETMAP" ]] && action="-j NETMAP"
([[ ${custom} == "" ]] && [[ ${type} == "NETMAP" ]]) && \
${display} RED "nat.conf: Error - NETMAP rule can not have empty custom address: ${DEFAULT_COLOR}${type} ${srcinterface} ${srcaddress} ${dstinterface} ${dstaddress} ${custom}" \
&& continue
([[ ${custom} != "" ]] && [[ ${type} == "NETMAP" ]]) && custom="--to ${custom}"
([[ ${dstaddress} != "-" ]] && [[ ${type} == "NETMAP" ]]) && dstaddress="-d ${dstaddress}"
# If we use a source interface, the rule can't go in a POSTROUTING table like what NAT is, so we punt it to PREROUTING
# or it won't work. Plus we remove the destination interface too.
([[ ${srcinterface} != "-" ]] && [[ ${type} != "SNAT" ]]) && NAT="PREROUTING" && dstinterface="-" && srcinterface="-i ${srcinterface}"
#[[ ${srcinterface} != "-" ]] && NAT="PREROUTING" && dstinterface="-" && srcinterface="-i ${srcinterface}"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR}${direction} ${action} ${srcinterface} ${srcaddress} ${srcport} ${dstinterface} ${dstaddress} ${dstport} ${protocol} ${custom}"
@ -486,9 +528,10 @@ function enable_nat {
[[ ${srcaddress} == "-" ]] && srcaddress=""
[[ ${custom} == "-" ]] && custom=""
${VER_IPTABLES} -A ${NAT} -t nat ${srcaddress} ${action} ${dstinterface} ${dstaddress} ${custom}
${VER_IPTABLES} -A ${NAT} -t nat ${srcinterface} ${srcaddress} ${action} ${dstinterface} ${dstaddress} ${custom}
#${VER_IPTABLES} -A ${FwdFilter} ${M_STATE} ${C_STATE} RELATED,ESTABLISHED,NEW ${srcinterface} ${srcaddress} ${dstinterface} -j ACCEPT
#${VER_IPTABLES} -A ${FwdFilter} ${M_STATE} ${C_STATE} RELATED,ESTABLISHED ${revsrcinterface} ${revsrcaddress} ${revdstinterface} -j ACCEPT
unset type srcinterface srcaddress dstinterface dstaddress custom
done < "${FWCONFIGDIR}/ipv${IPVER}/nat.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
fi
@ -506,10 +549,10 @@ function enable_services {
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} loading"
if [ -e "${FWCONFIGDIR}/ipv${IPVER}/services.conf" ]; then
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} read ${FWCONFIGDIR}/ipv${IPVER}/services.conf successful"
use_conntrack="no"
([[ ${IP_VERSION} == "ipv4" ]] && [[ ${Enablev4ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
([[ ${IP_VERSION} == "ipv6" ]] && [[ ${Enablev6ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
while read -r service protocol interface address srcaddress; do
use_conntrack="no"
([[ ${IP_VERSION} == "ipv4" ]] && [[ ${Enablev4ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
([[ ${IP_VERSION} == "ipv6" ]] && [[ ${Enablev6ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
multiport="no"
[[ ${service} = \#* ]] && continue
[[ -z ${service} ]] && continue
@ -517,7 +560,7 @@ function enable_services {
&& ${display} RED "service.conf: Error - must begin with service name or port number: ${DEFAULT_COLOR}${service} ${protocol} ${interface} ${address} ${srcaddress}" && continue
[[ ${protocol} == "-" ]] \
&& ${display} RED "service.conf: Error - protocol can not be empty: ${DEFAULT_COLOR}${service} ${protocol} ${interface} ${address} ${srcaddress}" && continue
[[ ${service} =~ "," ]] && multiport="yes"
[[ ${service} =~ (-|:|,) ]] && multiport="yes"
# Do some creative work with variables to make building the iptables rules fairly painless
([[ ${service} != "-" ]] && [[ ${multiport} != "yes" ]]) && service="--dport ${service}"
([[ ${service} != "-" ]] && [[ ${multiport} == "yes" ]]) && service="-m multiport --dports ${service}"
@ -534,9 +577,10 @@ function enable_services {
[[ ${srcaddress} == "-" ]] && srcaddress=""
${VER_IPTABLES} -A ${InFilter} ${protocol} ${service} ${interface} ${address} ${srcaddress} ${conntrack_state} -j ACCEPT
unset service protocol interface address srcaddress conntrack_state
done < "${FWCONFIGDIR}/ipv${IPVER}/services.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
unset service protocol interface address srcaddress
fi
}
@ -579,10 +623,10 @@ function enable_portfw {
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} loading"
if [ -e "${FWCONFIGDIR}/ipv${IPVER}/portfw.conf" ]; then
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} read ${FWCONFIGDIR}/ipv${IPVER}/portfw.conf successful"
use_conntrack="no"
([[ ${IP_VERSION} == "ipv4" ]] && [[ ${Enablev4ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
([[ ${IP_VERSION} == "ipv6" ]] && [[ ${Enablev6ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
while read -r service protocol intip intport interface address srcaddress; do
use_conntrack="no"
([[ ${IP_VERSION} == "ipv4" ]] && [[ ${Enablev4ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
([[ ${IP_VERSION} == "ipv6" ]] && [[ ${Enablev6ConnectionTracking} == "yes" ]]) && conntrack_state="${M_STATE} ${C_STATE} NEW"
[[ ${service} = \#* ]] && continue
[[ -z ${service} ]] && continue
[[ ${service} == "-" ]] \
@ -617,7 +661,7 @@ function enable_portfw {
${VER_IPTABLES} -A ${PortForward} -t nat ${protocol} ${service} ${interface} ${address} ${srcaddress} -j DNAT ${intdest}
${VER_IPTABLES} -A ${FwdFilter} ${interface} ${intip} ${protocol} ${intport} ${srcaddress} ${conntrack_state} -j ACCEPT
unset service protocol intip intport interface address srcaddress conntrack_state
done < "${FWCONFIGDIR}/ipv${IPVER}/portfw.conf"
${debug} ${DebugColor} "${FUNCNAME}:${DEFAULT_COLOR} done"
fi

7
release.json Normal file
View File

@ -0,0 +1,7 @@
{
"version": "2.2.1",
"state": "stable",
"scope": "minor fixes",
"changes": "See CHANGELOG",
"download": "https://git.sosdg.org/brielle/SRFirewall/releases"
}