forked from extern/shorewall_code
Compare commits
87 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cb3273b13b | ||
|
f0c75b5119 | ||
|
23bc6f1ab5 | ||
|
54e6412c49 | ||
|
61ac08dc7f | ||
|
f65b10c375 | ||
|
35c7f304f7 | ||
|
2b6d657fb0 | ||
|
668cb6deda | ||
|
98aad094fb | ||
|
8ed644a0ec | ||
|
45f8d31021 | ||
|
03d2088cf7 | ||
|
6534201284 | ||
|
282ca14182 | ||
|
4b7d346911 | ||
|
131a2cd40d | ||
|
ae90ab1f68 | ||
|
5e57c895b3 | ||
|
aab1df7421 | ||
|
9f3cc88cf0 | ||
|
aaa80882a0 | ||
|
1b6de901e0 | ||
|
56780a5d1f | ||
|
22c1bc2e9c | ||
|
5048e68cb5 | ||
|
1897794dbf | ||
|
4fca96f10e | ||
|
2d2ded7efc | ||
|
e5e427f278 | ||
|
5e8fd570d1 | ||
|
e8428cc298 | ||
|
aa94772fc6 | ||
|
732ae3ce19 | ||
|
9cbcb328af | ||
|
82e84f724d | ||
|
23cf8328d5 | ||
|
7c31f70dc8 | ||
|
f1eafdc314 | ||
|
69745caa41 | ||
|
0b49477e0d | ||
|
c195bab01d | ||
|
1b550baf7e | ||
|
d829093caa | ||
|
1fa77ac470 | ||
|
5083246266 | ||
|
c0d6c9e7c0 | ||
|
0d682fe78b | ||
|
410a20dda3 | ||
|
0685d0edfd | ||
|
474604b1fe | ||
|
6fef1f34ba | ||
|
93f0183550 | ||
|
5a599552f2 | ||
|
a42972644c | ||
|
b271c52603 | ||
|
49514e2d58 | ||
|
a265685e20 | ||
|
442e6ac152 | ||
|
14e5a2d5ca | ||
|
6e32f052c8 | ||
|
780eb0402c | ||
|
bfb9852eb6 | ||
|
a8b6a301f2 | ||
|
150f7ab798 | ||
|
b11d63a7bd | ||
|
84b283533b | ||
|
e36547f8be | ||
|
0632723a6c | ||
|
43543b5c32 | ||
|
ffc5a3c7df | ||
|
b6d1293b2e | ||
|
ec21b03c5b | ||
|
25dcf8c5d6 | ||
|
c02b71b530 | ||
|
78269d57bc | ||
|
fc91648315 | ||
|
067f435ac5 | ||
|
2039f38faf | ||
|
07654d8f8d | ||
|
b5e8f9bd50 | ||
|
f9995a9515 | ||
|
9c950082f6 | ||
|
defdd320cf | ||
|
c2fe389da8 | ||
|
45d1ef3978 | ||
|
65e174a073 |
7
Shorewall-core/configure
vendored
7
Shorewall-core/configure
vendored
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Shorewall Packet Filtering Firewall RPM configuration program - V4.6
|
||||
# Shorewall Packet Filtering Firewall configuration program - V5.2
|
||||
#
|
||||
# (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
@@ -109,6 +109,9 @@ if [ -z "$vendor" ]; then
|
||||
opensuse)
|
||||
vendor=suse
|
||||
;;
|
||||
alt|basealt|altlinux)
|
||||
vendor=alt
|
||||
;;
|
||||
*)
|
||||
vendor="$ID"
|
||||
;;
|
||||
@@ -132,6 +135,8 @@ if [ -z "$vendor" ]; then
|
||||
if [ -f /etc/debian_version ]; then
|
||||
params[HOST]=debian
|
||||
ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
|
||||
elif [ -f /etc/altlinux-release ] ; then
|
||||
params[HOST]=alt
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
params[HOST]=redhat
|
||||
rcfile=shorewallrc.redhat
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/perl -w
|
||||
#
|
||||
# Shorewall Packet Filtering Firewall RPM configuration program - V4.5
|
||||
# Shorewall Packet Filtering Firewall configuration program - V5.2
|
||||
#
|
||||
# (c) 2012, 2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
@@ -74,6 +74,8 @@ unless ( defined $vendor ) {
|
||||
} elsif ( $id eq 'ubuntu' || $id eq 'debian' ) {
|
||||
my $init = `ls -l /sbin/init`;
|
||||
$vendor = $init =~ /systemd/ ? 'debian.systemd' : 'debian.sysvinit';
|
||||
} elsif ( $id eq 'alt' || $id eq 'basealt' || $id eq 'altlinux' ) {
|
||||
$vendor = 'alt';
|
||||
} else {
|
||||
$vendor = $id;
|
||||
}
|
||||
@@ -117,6 +119,9 @@ if ( defined $vendor ) {
|
||||
} else {
|
||||
$rcfilename = 'shorewallrc.debian.sysvinit';
|
||||
}
|
||||
} elsif ( -f '/etc/altlinux-release' ){
|
||||
$vendor = 'alt';
|
||||
$rcfilename = 'shorewallrc.alt';
|
||||
} elsif ( -f '/etc/redhat-release' ){
|
||||
$vendor = 'redhat';
|
||||
$rcfilename = 'shorewallrc.redhat';
|
||||
|
@@ -172,6 +172,9 @@ if [ -z "$BUILD" ]; then
|
||||
opensuse)
|
||||
BUILD=suse
|
||||
;;
|
||||
alt|basealt|altlinux)
|
||||
BUILD=alt
|
||||
;;
|
||||
*)
|
||||
BUILD="$ID"
|
||||
;;
|
||||
@@ -180,6 +183,8 @@ if [ -z "$BUILD" ]; then
|
||||
BUILD=debian
|
||||
elif [ -f /etc/gentoo-release ]; then
|
||||
BUILD=gentoo
|
||||
elif [ -f /etc/altlinux-release ]; then
|
||||
BUILD=alt
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
BUILD=redhat
|
||||
elif [ -f /etc/slackware-version ] ; then
|
||||
@@ -238,7 +243,7 @@ case "$HOST" in
|
||||
apple)
|
||||
echo "Installing Mac-specific configuration...";
|
||||
;;
|
||||
debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt)
|
||||
debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt|alt)
|
||||
;;
|
||||
*)
|
||||
fatal_error "Unknown HOST \"$HOST\""
|
||||
|
@@ -1201,11 +1201,17 @@ show_saves_command() {
|
||||
echo
|
||||
|
||||
for f in ${VARDIR}/*-iptables; do
|
||||
fn=$(basename $f)
|
||||
fn=${fn%-iptables}
|
||||
mtime=$(ls -lt $f | tail -n 1 | cut -d ' ' -f '6 7 8' )
|
||||
[ $fn = "$RESTOREFILE" ] && fn="$fn (default)"
|
||||
echo " $mtime ${fn%-iptables}"
|
||||
case $f in
|
||||
*\**)
|
||||
;;
|
||||
*)
|
||||
fn=$(basename $f)
|
||||
fn=${fn%-iptables}
|
||||
mtime=$(ls -lt $f | tail -n 1 | cut -d ' ' -f '6 7 8' )
|
||||
[ $fn = "$RESTOREFILE" ] && fn="$fn (default)"
|
||||
echo " $mtime ${fn%-iptables}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo
|
||||
@@ -2760,7 +2766,7 @@ determine_capabilities() {
|
||||
g_tool=$(mywhich $tool)
|
||||
|
||||
if [ -z "$g_tool" ]; then
|
||||
fatal-error "No executable $tool binary can be found on your PATH"
|
||||
fatal_error "No executable $tool binary can be found on your PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -3769,7 +3775,7 @@ ipcalc_command() {
|
||||
elif [ $# -eq 3 ]; then
|
||||
address=$2
|
||||
vlsm=$(ip_vlsm $3)
|
||||
elif [ $# -eq 0 ]; then
|
||||
elif [ $# -eq 1 ]; then
|
||||
missing_argument
|
||||
else
|
||||
too_many_arguments $4
|
||||
@@ -3858,7 +3864,7 @@ noiptrace_command() {
|
||||
verify_firewall_script() {
|
||||
if [ ! -f $g_firewall ]; then
|
||||
echo " ERROR: $g_product is not properly installed" >&2
|
||||
if [ -L $g_firewall ]; then
|
||||
if [ -h $g_firewall ]; then
|
||||
echo " $g_firewall is a symbolic link to a" >&2
|
||||
echo " non-existant file" >&2
|
||||
else
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.2 -- /usr/share/shorewall/lib.common
|
||||
#
|
||||
# (c) 2010-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2010-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -419,7 +419,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
@@ -501,7 +501,7 @@ ip_network() {
|
||||
|
||||
#
|
||||
# The following hack is supplied to compensate for the fact that many of
|
||||
# the popular light-weight Bourne shell derivatives don't support XOR ("^").
|
||||
# the popular light-weight Bourne shell derivatives do not support XOR ("^").
|
||||
#
|
||||
ip_broadcast() {
|
||||
local x
|
||||
@@ -751,6 +751,8 @@ mutex_on()
|
||||
lockf=${LOCKFILE:=${VARDIR}/lock}
|
||||
local lockpid
|
||||
local lockd
|
||||
local lockbin
|
||||
local openwrt
|
||||
|
||||
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
||||
|
||||
@@ -760,29 +762,33 @@ mutex_on()
|
||||
|
||||
[ -d "$lockd" ] || mkdir -p "$lockd"
|
||||
|
||||
lockbin=$(mywhich lock)
|
||||
[ -n "$lockbin" -a -h "$lockbin" ] && openwrt=Yes
|
||||
|
||||
if [ -f $lockf ]; then
|
||||
lockpid=`cat ${lockf} 2> /dev/null`
|
||||
if [ -z "$lockpid" ] || [ $lockpid = 0 ]; then
|
||||
rm -f ${lockf}
|
||||
error_message "WARNING: Stale lockfile ${lockf} removed"
|
||||
elif [ $lockpid -eq $$ ]; then
|
||||
return 0
|
||||
elif ! ps | grep -v grep | qt grep ${lockpid}; then
|
||||
rm -f ${lockf}
|
||||
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
|
||||
elif [ -z "$openwrt" ]; then
|
||||
if [ $lockpid -eq $$ ]; then
|
||||
fatal_error "Mutex_on confusion"
|
||||
elif ! qt ps --pid ${lockpid}; then
|
||||
rm -f ${lockf}
|
||||
error_message "WARNING: Stale lockfile ${lockf} from pid ${lockpid} removed"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if qt mywhich lockfile; then
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||
if [ -n "$openwrt" ]; then
|
||||
lock ${lockf} || fatal_error "Can't lock ${lockf}"
|
||||
g_havemutex="lock -u ${lockf}"
|
||||
elif qt mywhich lockfile; then
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf} || fatal_error "Can't lock ${lockf}"
|
||||
g_havemutex="rm -f ${lockf}"
|
||||
chmod u+w ${lockf}
|
||||
echo $$ > ${lockf}
|
||||
chmod u-w ${lockf}
|
||||
elif qt mywhich lock; then
|
||||
lock ${lockf}
|
||||
g_havemutex="lock -u ${lockf} && rm -f ${lockf}"
|
||||
chmod u=r ${lockf}
|
||||
else
|
||||
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||
sleep 1
|
||||
|
@@ -60,7 +60,7 @@ mywhich() {
|
||||
remove_file() # $1 = file to remove
|
||||
{
|
||||
if [ -n "$1" ] ; then
|
||||
if [ -f $1 -o -L $1 ] ; then
|
||||
if [ -f $1 -o -h $1 ] ; then
|
||||
rm -f $1
|
||||
echo "$1 Removed"
|
||||
fi
|
||||
@@ -84,7 +84,7 @@ remove_file_with_wildcard() # $1 = file with wildcard to remove
|
||||
if [ -d $f ] ; then
|
||||
rm -rf $f
|
||||
echo "$f Removed"
|
||||
elif [ -f $f -o -L $f ] ; then
|
||||
elif [ -f $f -o -h $f ] ; then
|
||||
rm -f $f
|
||||
echo "$f Removed"
|
||||
fi
|
||||
|
@@ -3216,30 +3216,38 @@
|
||||
<refsect1>
|
||||
<title>FILES</title>
|
||||
|
||||
<para>/etc/shorewall/</para>
|
||||
<para>/etc/shorewall/*</para>
|
||||
|
||||
<para>/etc/shorewall6/</para>
|
||||
<para>/etc/shorewall6/*</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See ALSO</title>
|
||||
|
||||
<para><ulink
|
||||
url="/starting_and_stopping_shorewall.htm">http://www.shorewall.net/starting_and_stopping_shorewall.htm</ulink></para>
|
||||
<simplelist>
|
||||
<member><ulink
|
||||
url="/starting_and_stopping_shorewall.htm">http://www.shorewall.net/starting_and_stopping_shorewall.htm</ulink>
|
||||
- Describes operational aspects of Shorewall.</member>
|
||||
|
||||
<para>shorewall-accounting(5), shorewall-actions(5),
|
||||
shorewall-arprules(5), shorewall-blrules(5), shorewall.conf(5),
|
||||
shorewall-conntrack(5), shorewall-ecn(5), shorewall-exclusion(5),
|
||||
shorewall-hosts(5), shorewall-init(5), shorewall_interfaces(5),
|
||||
shorewall-ipsets(5), shorewall-logging(), shorewall-maclist(5),
|
||||
shorewall-mangle(5), shorewall-masq(5), shorewall-modules(5),
|
||||
shorewall-nat(5), shorewall-nesting(5), shorewall-netmap(5),
|
||||
shorewall-params(5), shorewall-policy(5), shorewall-providers(5),
|
||||
shorewall-proxyarp(5), shorewall6-proxyndp(5), shorewall-routes(5),
|
||||
shorewall-rtrules(5), shorewall-rtrules(5), shorewall-rules(5),
|
||||
shorewall-secmarks(5), shorewall-snat(5), shorewall-tcclasses(5),
|
||||
shorewall-tcdevices(5), shorewall-tcfilters(5), shorewall-tcinterfaces(5),
|
||||
shorewall-tcpri(5), shorewall-tunnels(5), shorewall-vardir(5),
|
||||
shorewall-zones(5)</para>
|
||||
<member><ulink url="shorewall-files.html">shorewall-files(5)</ulink> -
|
||||
Describes the various configuration files along with features and
|
||||
conventions common to those files.</member>
|
||||
|
||||
<member><ulink url="shorewall-names.html">shorewall-names(5)</ulink> -
|
||||
Describes naming of objects within a Shorewall configuration.</member>
|
||||
|
||||
<member><ulink
|
||||
url="shorewall-addresses.html">shorewall-addresses(5)</ulink> -
|
||||
Describes how to specify addresses within a Shorewall
|
||||
configuration.</member>
|
||||
|
||||
<member><ulink
|
||||
url="shorewall-exclusion.html">shorewall-exclusion(5)</ulink> -
|
||||
Describes how to exclude certain hosts and/or networks from matching a
|
||||
rule.</member>
|
||||
|
||||
<member><ulink url="shorewall-nesting.html">shorewall-nesting(5)</ulink>
|
||||
- Describes how to nest one Shorewall zone inside another.</member>
|
||||
</simplelist>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall Packet Filtering Firewall Control Program - V5.1
|
||||
# Shorewall Packet Filtering Firewall Control Program - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017
|
||||
# Tom Eastep (teastep@shorewall.net)
|
||||
|
25
Shorewall-core/shorewallrc.alt
Normal file
25
Shorewall-core/shorewallrc.alt
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# ALT/BaseALT/ALTLinux Shorewall 5.2 rc file
|
||||
#
|
||||
BUILD= #Default is to detect the build system
|
||||
HOST=alt
|
||||
PREFIX=/usr #Top-level directory for shared files, libraries, etc.
|
||||
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
|
||||
LIBEXECDIR=${PREFIX}/libexec #Directory for executable scripts.
|
||||
PERLLIBDIR=${SHAREDIR}/perl5 #Directory to install Shorewall Perl module directory
|
||||
CONFDIR=/etc #Directory where subsystem configurations are installed
|
||||
SBINDIR=/sbin #Directory where system administration programs are installed
|
||||
MANDIR=${SHAREDIR}/man #Directory where manpages are installed.
|
||||
INITDIR=${CONFDIR}/rc.d/init.d #Directory where SysV init scripts are installed.
|
||||
INITFILE=$PRODUCT #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.alt.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
|
||||
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
|
||||
VARLIB=/var/lib #Directory where product variable data is stored.
|
||||
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
|
||||
DEFAULT_PAGER=/usr/bin/less #Pager to use if none specified in shorewall[6].conf
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall interface helper utility - V4.2
|
||||
# Shorewall interface helper utility - V5.2
|
||||
#
|
||||
# (c) 2007,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
150
Shorewall-init/init.alt.sh
Executable file
150
Shorewall-init/init.alt.sh
Executable file
@@ -0,0 +1,150 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall init script
|
||||
#
|
||||
# chkconfig: - 09 91
|
||||
# description: Initialize the shorewall firewall at boot time
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall-init
|
||||
# Required-Start: $local_fs
|
||||
# Required-Stop: $local_fs
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Initialize the shorewall firewall at boot time
|
||||
# Description: Place the firewall in a safe state at boot time
|
||||
# prior to bringing up the network.
|
||||
### END INIT INFO
|
||||
|
||||
# Do not load RH compatibility interface.
|
||||
WITHOUT_RC_COMPAT=1
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
#
|
||||
# The installer may alter this
|
||||
#
|
||||
. /usr/share/shorewall/shorewallrc
|
||||
NAME="Shorewall-init firewall"
|
||||
PROG="shorewall-init"
|
||||
SHOREWALL="$SBINDIR/$PROG"
|
||||
LOGGER="logger -i -t $PROG"
|
||||
|
||||
# Get startup options (override default)
|
||||
OPTIONS=
|
||||
|
||||
LOCKFILE=/var/lock/subsys/shorewall-init
|
||||
|
||||
# check if shorewall-init is configured or not
|
||||
if [ -f "/etc/sysconfig/shorewall-init" ]; then
|
||||
. /etc/sysconfig/shorewall-init
|
||||
if [ -z "$PRODUCTS" ]; then
|
||||
echo "No PRODUCTS configured"
|
||||
exit 6
|
||||
fi
|
||||
else
|
||||
echo "/etc/sysconfig/shorewall-init not found"
|
||||
exit 6
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
# set the STATEDIR variable
|
||||
setstatedir() {
|
||||
local statedir
|
||||
if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
local PRODUCT
|
||||
local STATEDIR
|
||||
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
else
|
||||
RETVAL=6
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
||||
ipset -R < "$SAVE_IPSETS"
|
||||
fi
|
||||
|
||||
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
local PRODUCT
|
||||
local STATEDIR
|
||||
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
else
|
||||
RETVAL=6
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload|condrestart|condreload)
|
||||
# "Not implemented"
|
||||
;;
|
||||
condstop)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
stop
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
status "$PROG"
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: ${0##*/} {start|stop|restart|reload|condrestart|condstop|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 2010,2012-2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2016 - Matt Darfeuille (matdarf@gmail.com)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 2010,2012-2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -181,6 +181,9 @@ if [ -z "$BUILD" ]; then
|
||||
opensuse)
|
||||
BUILD=suse
|
||||
;;
|
||||
alt|basealt|altlinux)
|
||||
BUILD=alt
|
||||
;;
|
||||
*)
|
||||
BUILD="$ID"
|
||||
;;
|
||||
@@ -191,6 +194,8 @@ if [ -z "$BUILD" ]; then
|
||||
BUILD=debian
|
||||
elif [ -f /etc/gentoo-release ]; then
|
||||
BUILD=gentoo
|
||||
elif [ -f /etc/altlinux-release ]; then
|
||||
BUILD=alt
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
BUILD=redhat
|
||||
elif [ -f /etc/SuSE-release ]; then
|
||||
@@ -253,6 +258,9 @@ case "$HOST" in
|
||||
openwrt)
|
||||
echo "Installing Openwrt-specific configuration..."
|
||||
;;
|
||||
alt)
|
||||
echo "Installing ALT-specific configuration...";
|
||||
;;
|
||||
linux)
|
||||
fatal_error "Shorewall-init is not supported on this system"
|
||||
;;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.0
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 2012-2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
117
Shorewall-lite/init.alt.sh
Executable file
117
Shorewall-lite/init.alt.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall-Lite init script
|
||||
#
|
||||
# chkconfig: - 28 90
|
||||
# description: Packet filtering firewall
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall-lite
|
||||
# Required-Start: $local_fs $remote_fs $syslog $network
|
||||
# Should-Start: $time $named
|
||||
# Required-Stop:
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Packet filtering firewall
|
||||
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
|
||||
# Netfilter (iptables) based firewall
|
||||
### END INIT INFO
|
||||
|
||||
# Do not load RH compatibility interface.
|
||||
WITHOUT_RC_COMPAT=1
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
#
|
||||
# The installer may alter this
|
||||
#
|
||||
. /usr/share/shorewall/shorewallrc
|
||||
|
||||
NAME="Shorewall-Lite firewall"
|
||||
PROG="shorewall"
|
||||
SHOREWALL="$SBINDIR/$PROG -l"
|
||||
LOGGER="logger -i -t $PROG"
|
||||
|
||||
# Get startup options (override default)
|
||||
OPTIONS=
|
||||
|
||||
SourceIfNotEmpty $SYSCONFDIR/${PROG}-lite
|
||||
|
||||
LOCKFILE="/var/lock/subsys/${PROG}-lite"
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
reload() {
|
||||
action $"Reloadinging $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
clear() {
|
||||
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
condrestart)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condreload)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condstop)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
stop
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
"$SHOREWALL" status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2015 - Matt Darfeuille - (matdarf@gmail.com)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
RCDLINKS="2,S41 3,S41 6,K41"
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -190,6 +190,9 @@ if [ -z "$BUILD" ]; then
|
||||
opensuse)
|
||||
BUILD=suse
|
||||
;;
|
||||
alt|basealt|altlinux)
|
||||
BUILD=alt
|
||||
;;
|
||||
*)
|
||||
BUILD="$ID"
|
||||
;;
|
||||
@@ -198,6 +201,8 @@ if [ -z "$BUILD" ]; then
|
||||
BUILD=debian
|
||||
elif [ -f /etc/gentoo-release ]; then
|
||||
BUILD=gentoo
|
||||
elif [ -f /etc/altlinux-release ]; then
|
||||
BUILD=alt
|
||||
elif [ -f ${CONFDIR}/redhat-release ]; then
|
||||
BUILD=redhat
|
||||
elif [ -f ${CONFDIR}/SuSE-release ]; then
|
||||
@@ -266,6 +271,9 @@ case "$HOST" in
|
||||
openwrt)
|
||||
echo "Installing OpenWRT-specific configuration..."
|
||||
;;
|
||||
alt)
|
||||
echo "Installing ALT-specific configuration...";
|
||||
;;
|
||||
linux)
|
||||
;;
|
||||
*)
|
||||
|
@@ -151,7 +151,7 @@ fi
|
||||
|
||||
remove_file ${SBINDIR}/$PRODUCT
|
||||
|
||||
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
|
||||
if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
|
||||
if [ $HOST = openwrt ]; then
|
||||
if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
|
||||
/etc/init.d/$PRODUCT disable
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall WAN Interface monitor - V4.4
|
||||
# Shorewall WAN Interface monitor - V5.2
|
||||
#
|
||||
# Inspired by Angsuman Chakraborty's gwping script.
|
||||
#
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Shorewall WAN Interface monitor - V4.4
|
||||
# Shorewall WAN Interface monitor - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
9
Shorewall/Macros/IPFS-swarm
Normal file
9
Shorewall/Macros/IPFS-swarm
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.IPFS-swarm
|
||||
#
|
||||
# This macro handles IPFS data traffic (the connection to IPFS swarm).
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 4001
|
12
Shorewall/Macros/macro.Cockpit
Normal file
12
Shorewall/Macros/macro.Cockpit
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.Cockpit
|
||||
#
|
||||
# This macro handles Time protocol (RFC868).
|
||||
# Unless you are supporting extremely old hardware or software,
|
||||
# you shouldn't be using this. NTP is a superior alternative.
|
||||
#
|
||||
# By Eric Teeter
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 9090
|
9
Shorewall/Macros/macro.IPFS-API
Normal file
9
Shorewall/Macros/macro.IPFS-API
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.IPFS-API
|
||||
#
|
||||
# This macro handles IPFS API port (commands for the IPFS daemon).
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 5001
|
9
Shorewall/Macros/macro.IPFS-gateway
Normal file
9
Shorewall/Macros/macro.IPFS-gateway
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.IPFS-gateway
|
||||
#
|
||||
# This macro handles the IPFS gateway to HTTP.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 8080
|
9
Shorewall/Macros/macro.IPFS-swarm
Normal file
9
Shorewall/Macros/macro.IPFS-swarm
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.IPFS-swarm
|
||||
#
|
||||
# This macro handles IPFS data traffic (the connection to IPFS swarm).
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 4001
|
@@ -153,6 +153,9 @@ our %EXPORT_TAGS = (
|
||||
STICKY
|
||||
STICKO
|
||||
REALPREROUTING
|
||||
REALINPUT
|
||||
REALOUTPUT
|
||||
REALPOSTROUTING
|
||||
ACTIONCHAIN
|
||||
|
||||
unreachable_warning
|
||||
@@ -183,13 +186,12 @@ our %EXPORT_TAGS = (
|
||||
input_chain
|
||||
input_option_chain
|
||||
zone_input_chain
|
||||
use_input_chain
|
||||
use_interface_chain
|
||||
output_chain
|
||||
output_option_chain
|
||||
prerouting_chain
|
||||
postrouting_chain
|
||||
zone_output_chain
|
||||
use_output_chain
|
||||
masq_chain
|
||||
syn_flood_chain
|
||||
mac_chain
|
||||
@@ -425,7 +427,7 @@ our $VERSION = 'MODULEVERSION';
|
||||
# Established - ^<z1-z2>
|
||||
# Related - +<z1-z2>
|
||||
# Invalid - _<z1-z2>
|
||||
# Untracked - &<z1-z2>
|
||||
# Untracked - =<z1-z2>
|
||||
#
|
||||
our %chain_table;
|
||||
our $raw_table;
|
||||
@@ -490,16 +492,19 @@ use constant { NO_RESTRICT => 0, # FORWARD chain rule - Both -i an
|
||||
# Mangle Table allowed chains enumeration
|
||||
#
|
||||
use constant {
|
||||
PREROUTING => 1, #Actually tcpre
|
||||
INPUT => 2, #Actually tcin
|
||||
FORWARD => 4, #Actually tcfor
|
||||
OUTPUT => 8, #Actually tcout
|
||||
POSTROUTING => 16, #Actually tcpost
|
||||
ALLCHAINS => 31,
|
||||
STICKY => 32,
|
||||
STICKO => 64,
|
||||
REALPREROUTING => 128,
|
||||
ACTIONCHAIN => 256,
|
||||
PREROUTING => 1, #Actually tcpre
|
||||
INPUT => 2, #Actually tcin
|
||||
FORWARD => 4, #Actually tcfor
|
||||
OUTPUT => 8, #Actually tcout
|
||||
POSTROUTING => 16, #Actually tcpost
|
||||
STICKY => 32,
|
||||
STICKO => 64,
|
||||
REALPREROUTING => 128,
|
||||
REALINPUT => 256,
|
||||
REALOUTPUT => 512,
|
||||
REALPOSTROUTING => 1024,
|
||||
ALLCHAINS => 2047,
|
||||
ACTIONCHAIN => 2048,
|
||||
};
|
||||
|
||||
#
|
||||
@@ -2269,7 +2274,7 @@ sub invalid_chain($$) {
|
||||
# Name of the untracked chain between an ordered pair of zones
|
||||
#
|
||||
sub untracked_chain($$) {
|
||||
'&' . &rules_chain(@_);
|
||||
'=' . &rules_chain(@_);
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2319,7 +2324,7 @@ sub invalid_log($$) {
|
||||
# Name of the untracked chain between an ordered pair of zones
|
||||
#
|
||||
sub untracked_log($$) {
|
||||
'&' . &rules_log(@_);
|
||||
'=' . &rules_log(@_);
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2425,10 +2430,11 @@ sub zone_input_chain($) {
|
||||
}
|
||||
|
||||
#
|
||||
# Returns true if we're to use the interface's input chain
|
||||
# Returns true if we're to use the interface's input or chain, depending on the second argument
|
||||
# (use_input_chain or use_output_chain).
|
||||
#
|
||||
sub use_input_chain($$) {
|
||||
my ( $interface, $chainref ) = @_;
|
||||
sub use_interface_chain($$) {
|
||||
my ( $interface, $which ) = @_;
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
#
|
||||
@@ -2456,17 +2462,11 @@ sub use_input_chain($$) {
|
||||
# the zone has multiple interfaces
|
||||
# and this interface has option rules
|
||||
#
|
||||
return 1 if $interfaceref->{options}{use_input_chain} && keys %{ zone_interfaces( $zone ) } > 1;
|
||||
return 1 if $interfaceref->{options}{$which} && keys %{ zone_interfaces( $zone ) } > 1;
|
||||
#
|
||||
# Interface associated with a single zone -- use the zone's input chain if it has one
|
||||
#
|
||||
return 0 if $chainref;
|
||||
#
|
||||
# Use the <zone>->fw rules chain if it is referenced.
|
||||
#
|
||||
$chainref = $filter_table->{rules_chain( $zone, firewall_zone )};
|
||||
|
||||
! ( $chainref->{referenced} || $chainref->{is_policy} )
|
||||
return 0;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2503,41 +2503,6 @@ sub zone_output_chain($) {
|
||||
$_[0] . '_output';
|
||||
}
|
||||
|
||||
#
|
||||
# Returns true if we're to use the interface's output chain
|
||||
#
|
||||
sub use_output_chain($$) {
|
||||
my ( $interface, $chainref) = @_;
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
#
|
||||
# We must use the interfaces's chain if the interface is associated with multiple Zones
|
||||
#
|
||||
return 1 if ( keys %{interface_zones $interface} ) > 1;
|
||||
#
|
||||
# Use interface's chain if there are multiple nets on the interface
|
||||
#
|
||||
return 1 if $nets > 1;
|
||||
#
|
||||
# Use interface's chain if it is a bridge with ports
|
||||
#
|
||||
return 1 if $interfaceref->{ports};
|
||||
#
|
||||
# Don't need it if it isn't associated with any zone
|
||||
#
|
||||
return 0 unless $nets;
|
||||
#
|
||||
# Interface associated with a single zone -- use the zone's output chain if it has one
|
||||
#
|
||||
return 0 if $chainref;
|
||||
#
|
||||
# Use the fw-><zone> rules chain if it is referenced.
|
||||
#
|
||||
$chainref = $filter_table->{rules_chain( firewall_zone , $interfaceref->{zone} )};
|
||||
|
||||
! ( $chainref->{referenced} || $chainref->{is_policy} )
|
||||
}
|
||||
|
||||
#
|
||||
# Masquerade Chain for an interface
|
||||
#
|
||||
@@ -3334,10 +3299,20 @@ sub initialize_chain_table($) {
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.nat_DOCKER ] && cat ${VARDIR}/.nat_DOCKER >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-INGRESS' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-INGRESS ] && cat ${VARDIR}/.filter_DOCKER-INGRESS >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-USER' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-USER ] && cat ${VARDIR}/.filter_DOCKER-USER >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-ISOLATION' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-INGRESS ] && cat ${VARDIR}/.filter_DOCKER-INGRESS >&3' );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION >&3' );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-ISOLATION-STAGE-1' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-1 ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-1 >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-ISOLATION-STAGE-2' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-2 ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-2 >&3' );
|
||||
}
|
||||
|
||||
my $ruleref = transform_rule( $globals{LOGLIMIT} );
|
||||
@@ -5287,8 +5262,8 @@ sub do_imac( $ ) {
|
||||
#
|
||||
sub verify_mark( $ ) {
|
||||
my $mark = $_[0];
|
||||
my $limit = $globals{EXCLUSION_MASK};
|
||||
my $mask = $globals{TC_MASK};
|
||||
my $limit = $config{TC_EXPERT} ? $globals{TPROXY_MARK} + 1 : $globals{EXCLUSION_MASK};
|
||||
my $mask = $config{TC_EXPERT} ? $globals{TPROXY_MARK} : $globals{TC_MASK};
|
||||
my $value = numeric_value( $mark );
|
||||
|
||||
fatal_error "Invalid Mark or Mask value ($mark)"
|
||||
@@ -5372,69 +5347,91 @@ sub do_ratelimit( $$ ) {
|
||||
|
||||
fatal_error "Rate Limiting not available with $action" if $norate{$action};
|
||||
|
||||
my @rates = split_list $rates, 'rate';
|
||||
my @rates = split_list3 $rates, 'rate';
|
||||
|
||||
if ( @rates == 2 ) {
|
||||
$rates[0] = 's:' . $rates[0];
|
||||
$rates[1] = 'd:' . $rates[1];
|
||||
$rates[0] = 's:' . $rates[0] unless $rates[0] =~ /^s(?:\/\d+)?:/;
|
||||
$rates[1] = 'd:' . $rates[1] unless $rates[1] =~ /^d(?:\/\d+)?:/;
|
||||
} elsif ( @rates > 2 ) {
|
||||
fatal error "Only two rates may be specified";
|
||||
}
|
||||
|
||||
my $limit = '';
|
||||
|
||||
for my $rate ( @rates ) {
|
||||
#
|
||||
# "-m hashlimit" match for the passed LIMIT/BURST
|
||||
#
|
||||
if ( $rate =~ /^([sd]):{1,2}/ ) {
|
||||
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
|
||||
my $mode;
|
||||
my $match;
|
||||
my $units;
|
||||
|
||||
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
my $units;
|
||||
# 1 2 34 5 6 78 9 10 11
|
||||
if ( $rate =~ /^(?:([sd])(?:\/(\d+))?:)?(?:(([A-Za-z]\w*)?(?:\((\d+),(\d+)\))?:)|:)?((\d+)(\/(sec|min|hour|day))?)(?::(\d+))?$/ ) {
|
||||
fatal_error "Invalid Rate ($8)" unless $8;
|
||||
|
||||
$limit .= "-m hashlimit ";
|
||||
|
||||
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
fatal_error "Invalid Burst ($7)" unless $7;
|
||||
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
$limit .= "--$match $3 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
if ( $1 ) {
|
||||
require_capability( 'HASHLIMIT_MATCH' , 'Per-ip rate limiting', 's' );
|
||||
$mode = $1 eq 's' ? 'srcip' : 'dstip';
|
||||
}
|
||||
|
||||
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
|
||||
if ( $mode || $2 || $4 || $5 ) {
|
||||
$limit .= '-m hashlimit ';
|
||||
$match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
} else {
|
||||
$limit .= '-m limit ';
|
||||
$match = 'limit';
|
||||
}
|
||||
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
$limit .= "--$match $7 ";
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
}
|
||||
if ( supplied $11 ) {
|
||||
fatal_error "Invalid Burst ($11)" unless $11;
|
||||
$limit .= $match eq 'limit' ? "--limit-burst $11 " : "--hashlimit-burst $11 ";
|
||||
}
|
||||
|
||||
$limit .= "--hashlimit-htable-expire $expire ";
|
||||
|
||||
if ( $mode || $4 ) {
|
||||
require_capability( 'HASHLIMIT_MATCH', 'Specifying a table name', 's' );
|
||||
$limit .= "--hashlimit-name ";
|
||||
$limit .= $4 ? $4 : 'shorewall' . $hashlimitset++;
|
||||
}
|
||||
|
||||
if ( supplied $2 ) {
|
||||
my $vlsm = numeric_value($2);
|
||||
fatal_error "Invalid VLSM ($2)" unless $vlsm and $vlsm <= ( $family == F_IPV4 ? VLSMv4 : VLSMv6 );
|
||||
$limit .= $mode eq 'srcip' ? " --hashlimit-srcmask $vlsm" : " --hashlimit-dstmask $vlsm";
|
||||
}
|
||||
|
||||
if ( supplied $5 ) {
|
||||
require_capability( 'HASHLIMIT_MATCH', 'Specifying hash table size', 's' );
|
||||
my ( $htsize, $max ) = ( numeric_value($5), numeric_value($6) );
|
||||
|
||||
fatal_error "Invalid hash table buckets ($5)" unless $htsize;
|
||||
fatal_error "Invalid hash max entries($6)" unless $max;
|
||||
fatal_error "Hash max entries must be > hash table buckets" unless $max > $htsize;
|
||||
|
||||
$limit .= " --hashlimit-htable-size $htsize --hashlimit-htable-max $max";
|
||||
}
|
||||
|
||||
if ( $mode ) {
|
||||
$limit .= " --hashlimit-mode $mode";
|
||||
$units = $10;
|
||||
}
|
||||
} else {
|
||||
if ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($1)" unless $2;
|
||||
fatal_error "Invalid Burst ($5)" unless $5;
|
||||
$limit = "-m limit --limit $1 --limit-burst $5 ";
|
||||
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
|
||||
fatal_error "Invalid Rate (${1}${2})" unless $1;
|
||||
$limit = "-m limit --limit $rate ";
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
}
|
||||
|
||||
$limit .= " --hashlimit-htable-expire $expire ";
|
||||
} else {
|
||||
$limit .= ' ';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5819,7 +5816,7 @@ sub do_condition( $$ ) {
|
||||
|
||||
$chain =~ s/[^\w-]//g;
|
||||
# $1 $2 - $3
|
||||
while ( $condition =~ m( ^(.*?) @({)?(?:0|chain)(?(2)}) (.*)$ )x ) {
|
||||
while ( $condition =~ m( ^(.*?) @(\{)?(?:0|chain)(?(2)}) (.*)$ )x ) {
|
||||
$condition = join( '', $1, $chain, $3 );
|
||||
}
|
||||
|
||||
@@ -5868,36 +5865,48 @@ sub do_nfacct( $ ) {
|
||||
# Match Source Interface
|
||||
#
|
||||
sub match_source_dev( $;$ ) {
|
||||
my ( $interface, $nodev ) = @_;;
|
||||
my ( $interface, $nodev ) = @_;
|
||||
my $invert = ( $interface =~ s/^!// ) ? '! ' : '';
|
||||
my $interfaceref = known_interface( $interface );
|
||||
$interface = $interfaceref->{physical} if $interfaceref;
|
||||
return '' if $interface eq '+';
|
||||
|
||||
if ( $interface eq '+' ) {
|
||||
fatal_error "Invalid interface (!+)" if $invert;
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $interfaceref && $interfaceref->{options}{port} ) {
|
||||
if ( $nodev ) {
|
||||
"-m physdev --physdev-in $interface ";
|
||||
"${invert}-m physdev --physdev-in $interface ";
|
||||
} else {
|
||||
my $bridgeref = find_interface $interfaceref->{bridge};
|
||||
"-i $bridgeref->{physical} -m physdev --physdev-in $interface ";
|
||||
"-i $bridgeref->{physical} ${invert}-m physdev --physdev-in $interface ";
|
||||
}
|
||||
} else {
|
||||
"-i $interface ";
|
||||
"${invert}-i $interface ";
|
||||
}
|
||||
}
|
||||
|
||||
sub imatch_source_dev( $;$ ) {
|
||||
my ( $interface, $nodev ) = @_;;
|
||||
my ( $interface, $nodev ) = @_;
|
||||
my $invert = ( $interface =~ s/^!// ) ? '! ' : '';
|
||||
my $interfaceref = known_interface( $interface );
|
||||
$interface = $interfaceref->{physical} if $interfaceref;
|
||||
return () if $interface eq '+';
|
||||
|
||||
if ( $interface eq '+' ) {
|
||||
fatal_error "Invalid interface (!+)" if $invert;
|
||||
return ();
|
||||
}
|
||||
|
||||
if ( $interfaceref && $interfaceref->{options}{port} ) {
|
||||
if ( $nodev ) {
|
||||
( physdev => "--physdev-in $interface" );
|
||||
( physdev => "${invert}--physdev-in $interface" );
|
||||
} else {
|
||||
my $bridgeref = find_interface $interfaceref->{bridge};
|
||||
( i => $bridgeref->{physical}, physdev => "--physdev-in $interface" );
|
||||
( i => $bridgeref->{physical}, physdev => "${invert}--physdev-in $interface" );
|
||||
}
|
||||
} else {
|
||||
( i => $interface );
|
||||
( i => $invert . $interface );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5905,54 +5914,66 @@ sub imatch_source_dev( $;$ ) {
|
||||
# Match Dest device
|
||||
#
|
||||
sub match_dest_dev( $;$ ) {
|
||||
my ( $interface, $nodev ) = @_;;
|
||||
my ( $interface, $nodev ) = @_;
|
||||
my $interfaceref = known_interface( $interface );
|
||||
my $invert = ( $interface =~ s/^!// ) ? '! ' : '';
|
||||
$interface = $interfaceref->{physical} if $interfaceref;
|
||||
return '' if $interface eq '+';
|
||||
|
||||
if ( $interface eq '+' ) {
|
||||
fatal_error "Invalid interface (!+)" if $invert;
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( $interfaceref && $interfaceref->{options}{port} ) {
|
||||
if ( $nodev ) {
|
||||
if ( have_capability( 'PHYSDEV_BRIDGE' ) ) {
|
||||
"-m physdev --physdev-is-bridged --physdev-out $interface ";
|
||||
"${invert}-m physdev --physdev-is-bridged --physdev-out $interface ";
|
||||
} else {
|
||||
"-m physdev --physdev-out $interface ";
|
||||
"${invert}-m physdev --physdev-out $interface ";
|
||||
}
|
||||
} else {
|
||||
my $bridgeref = find_interface $interfaceref->{bridge};
|
||||
|
||||
if ( have_capability( 'PHYSDEV_BRIDGE' ) ) {
|
||||
"-o $bridgeref->{physical} -m physdev --physdev-is-bridged --physdev-out $interface ";
|
||||
"-o $bridgeref->{physical} ${invert}-m physdev --physdev-is-bridged --physdev-out $interface ";
|
||||
} else {
|
||||
"-o $bridgeref->{physical} -m physdev --physdev-out $interface ";
|
||||
"-o $bridgeref->{physical} ${invert}-m physdev --physdev-out $interface ";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
"-o $interface ";
|
||||
"${invert}-o $interface ";
|
||||
}
|
||||
}
|
||||
|
||||
sub imatch_dest_dev( $;$ ) {
|
||||
my ( $interface, $nodev ) = @_;;
|
||||
my ( $interface, $nodev ) = @_;
|
||||
my $invert = ( $interface =~ s/^!// ) ? '!' : '';
|
||||
my $interfaceref = known_interface( $interface );
|
||||
$interface = $interfaceref->{physical} if $interfaceref;
|
||||
return () if $interface eq '+';
|
||||
|
||||
if ( $interface eq '+' ) {
|
||||
fatal_error "Invalid interface (!+)" if $invert;
|
||||
return ();
|
||||
}
|
||||
|
||||
if ( $interfaceref && $interfaceref->{options}{port} ) {
|
||||
if ( $nodev ) {
|
||||
if ( have_capability( 'PHYSDEV_BRIDGE' ) ) {
|
||||
( physdev => "--physdev-is-bridged --physdev-out $interface" );
|
||||
( physdev => "${invert}--physdev-is-bridged --physdev-out $interface" );
|
||||
} else {
|
||||
( physdev => "--physdev-out $interface" );
|
||||
( physdev => "${invert}--physdev-out $interface" );
|
||||
}
|
||||
} else {
|
||||
my $bridgeref = find_interface $interfaceref->{bridge};
|
||||
|
||||
if ( have_capability( 'PHYSDEV_BRIDGE' ) ) {
|
||||
( o => $bridgeref->{physical}, physdev => "--physdev-is-bridged --physdev-out $interface" );
|
||||
( o => $bridgeref->{physical}, physdev => "${invert}--physdev-is-bridged --physdev-out $interface" );
|
||||
} else {
|
||||
( o => $bridgeref->{physical}, physdev => "--physdev-out $interface" );
|
||||
( o => $bridgeref->{physical}, physdev => "${invert}--physdev-out $interface" );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
( o => $interface );
|
||||
( o => $invert . $interface );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7568,6 +7589,11 @@ sub verify_source_interface( $$$$ ) {
|
||||
my ( $iiface, $restriction, $table, $chainref ) = @_;
|
||||
|
||||
my $rule = '';
|
||||
my $oiiface = $iiface;
|
||||
#
|
||||
# Ignore exclusion for now
|
||||
#
|
||||
$iiface =~ s/^!//;
|
||||
|
||||
fatal_error "Unknown Interface ($iiface)" unless known_interface $iiface;
|
||||
|
||||
@@ -7597,7 +7623,7 @@ sub verify_source_interface( $$$$ ) {
|
||||
}
|
||||
|
||||
$chainref->{restricted} |= $restriction;
|
||||
$rule .= match_source_dev( $iiface );
|
||||
$rule .= match_source_dev( $oiiface );
|
||||
}
|
||||
|
||||
$rule;
|
||||
@@ -7692,6 +7718,11 @@ sub verify_dest_interface( $$$$ ) {
|
||||
my ( $diface, $restriction, $chainref, $iiface ) = @_;
|
||||
|
||||
my $rule = '';
|
||||
my $odiface = $diface;
|
||||
#
|
||||
# Ignore exclusion for now
|
||||
#
|
||||
$diface =~ s/^!//;
|
||||
|
||||
fatal_error "Unknown Interface ($diface)" unless known_interface $diface;
|
||||
|
||||
@@ -7721,7 +7752,7 @@ sub verify_dest_interface( $$$$ ) {
|
||||
}
|
||||
|
||||
$chainref->{restricted} |= $restriction;
|
||||
$rule .= match_dest_dev( $diface );
|
||||
$rule .= match_dest_dev( $odiface );
|
||||
}
|
||||
|
||||
$rule;
|
||||
@@ -8459,6 +8490,18 @@ sub enter_cmd_mode() {
|
||||
$mode = CMD_MODE;
|
||||
}
|
||||
|
||||
#
|
||||
# These two assure that we're in a particular mode
|
||||
#
|
||||
|
||||
sub ensure_cat_mode() {
|
||||
enter_cat_mode unless $mode == CAT_MODE;
|
||||
}
|
||||
|
||||
sub ensure_cmd_mode() {
|
||||
enter_cmd_mode unless $mode == CMD_MODE;
|
||||
}
|
||||
|
||||
#
|
||||
# Emits the passed rule (input to iptables-restore) or command
|
||||
#
|
||||
@@ -8474,7 +8517,7 @@ sub emitr( $$ ) {
|
||||
#
|
||||
# A rule
|
||||
#
|
||||
enter_cat_mode unless $mode == CAT_MODE;
|
||||
ensure_cat_mode;
|
||||
|
||||
if ( $file_comments && ( my $origin = $ruleref->{origin} ) ) {
|
||||
emit_unindented '# ' . $origin;
|
||||
@@ -8485,7 +8528,7 @@ sub emitr( $$ ) {
|
||||
#
|
||||
# A command
|
||||
#
|
||||
enter_cmd_mode unless $mode == CMD_MODE;
|
||||
ensure_cmd_mode;
|
||||
|
||||
if ( exists $ruleref->{cmd} ) {
|
||||
emit join( '', ' ' x $ruleref->{cmdlevel}, $ruleref->{cmd} );
|
||||
@@ -8518,6 +8561,14 @@ sub enter_cmd_mode1() {
|
||||
$mode = CMD_MODE;
|
||||
}
|
||||
|
||||
sub ensure_cat_mode1() {
|
||||
enter_cat_mode1 unless $mode == CAT_MODE;
|
||||
}
|
||||
|
||||
sub ensure_cmd_mode1() {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
}
|
||||
|
||||
sub emitr1( $$ ) {
|
||||
my ( $chainref, $ruleref ) = @_;
|
||||
|
||||
@@ -8526,14 +8577,14 @@ sub emitr1( $$ ) {
|
||||
#
|
||||
# A rule
|
||||
#
|
||||
enter_cat_mode1 unless $mode == CAT_MODE;
|
||||
ensure_cat_mode1;
|
||||
|
||||
print format_rule( $chainref, $ruleref ) . "\n";
|
||||
} else {
|
||||
#
|
||||
# A command
|
||||
#
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
ensure_cmd_mode1;
|
||||
|
||||
if ( exists $ruleref->{cmd} ) {
|
||||
emitstd $ruleref->{cmd};
|
||||
@@ -8558,7 +8609,20 @@ sub save_docker_rules($) {
|
||||
qq( $tool -t nat -S POSTROUTING | tail -n +2 | fgrep -v SHOREWALL > \${VARDIR}/.nat_POSTROUTING),
|
||||
qq( $tool -t filter -S DOCKER | tail -n +2 > \${VARDIR}/.filter_DOCKER),
|
||||
qq( [ -n "\$g_dockeringress" ] && $tool -t filter -S DOCKER-INGRESS | tail -n +2 > \${VARDIR}/.filter_DOCKER-INGRESS),
|
||||
qq( [ -n "\$g_dockernetwork" ] && $tool -t filter -S DOCKER-ISOLATION | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION)
|
||||
qq( [ -n "\$g_dockeruser" ] && $tool -t filter -S DOCKER-USER | tail -n +2 > \${VARDIR}/.filter_DOCKER-USER),
|
||||
qq(),
|
||||
qq( case "\$g_dockernetwork" in),
|
||||
qq( One\)),
|
||||
qq( rm -f \${VARDIR}/.filter_DOCKER-ISOLATION*),
|
||||
qq( $tool -t filter -S DOCKER-ISOLATION | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION),
|
||||
qq( ;;),
|
||||
qq( Two\)),
|
||||
qq( rm -f \${VARDIR}/.filter_DOCKER-ISOLATION*),
|
||||
qq( $tool -t filter -S DOCKER-ISOLATION-STAGE-1 | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-1),
|
||||
qq( $tool -t filter -S DOCKER-ISOLATION-STAGE-2 | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION-STAGE-2),
|
||||
qq( ;;),
|
||||
qq( esac),
|
||||
qq(),
|
||||
);
|
||||
|
||||
if ( known_interface( 'docker0' ) ) {
|
||||
@@ -8574,7 +8638,8 @@ sub save_docker_rules($) {
|
||||
q( rm -f ${VARDIR}/.nat_POSTROUTING),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-INGRESS),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-ISOLATION),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-USER),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-ISOLATION*),
|
||||
q( rm -f ${VARDIR}/.filter_FORWARD),
|
||||
q(fi)
|
||||
)
|
||||
@@ -9073,21 +9138,26 @@ sub create_netfilter_load( $ ) {
|
||||
|
||||
if ( $name =~ /^DOCKER/ ) {
|
||||
if ( $name eq 'DOCKER' ) {
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-ISOLATION' ) {
|
||||
enter_cmd_mode;
|
||||
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
|
||||
ensure_cmd_mode;
|
||||
emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-USER' ) {
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
|
||||
} else {
|
||||
ensure_cat_mode;
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
} else {
|
||||
ensure_cat_mode;
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
|
||||
@@ -9105,17 +9175,19 @@ sub create_netfilter_load( $ ) {
|
||||
#
|
||||
# Then emit the rules
|
||||
#
|
||||
ensure_cat_mode;
|
||||
|
||||
for my $chainref ( @chains ) {
|
||||
emitr( $chainref, $_ ) for @{$chainref->{rules}};
|
||||
}
|
||||
#
|
||||
# Commit the changes to the table
|
||||
#
|
||||
enter_cat_mode unless $mode == CAT_MODE;
|
||||
ensure_cat_mode;
|
||||
emit_unindented 'COMMIT';
|
||||
}
|
||||
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
|
||||
pop_indent, emit "fi\n";
|
||||
#
|
||||
@@ -9131,7 +9203,7 @@ sub create_netfilter_load( $ ) {
|
||||
'',
|
||||
"cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux",
|
||||
'if [ $? != 0 ]; then',
|
||||
qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"),
|
||||
qq( fatal_error "$utility Failed. Input is in \${VARDIR}/.${utility}-input"),
|
||||
'fi'
|
||||
);
|
||||
|
||||
@@ -9180,24 +9252,31 @@ sub preview_netfilter_load() {
|
||||
assert( $chainref->{cmdlevel} == 0 , $name );
|
||||
if ( $name =~ /^DOCKER/ ) {
|
||||
if ( $name eq 'DOCKER' ) {
|
||||
enter_cmd_mode1;
|
||||
ensure_cmd_mode1;
|
||||
print( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
|
||||
print "\n";
|
||||
} elsif ( $name eq 'DOCKER-ISOLATION' ) {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
print( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
ensure_cmd_mode1;
|
||||
print( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
print "\n";
|
||||
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
|
||||
ensure_cmd_mode1;
|
||||
print( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
|
||||
print "\n";
|
||||
enter_cat_mode1;
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
ensure_cmd_mode1;
|
||||
print( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
print "\n";
|
||||
enter_cat_mode1;
|
||||
} else {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
} elsif ( $name eq 'DOCKER-USER' ) {
|
||||
ensure_cmd_mode1;
|
||||
print( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
|
||||
print "\n";
|
||||
} else {
|
||||
ensure_cmd_mode1;
|
||||
print( ":$name - [0:0]\n" );
|
||||
}
|
||||
} else {
|
||||
ensure_cat_mode1;
|
||||
print( ":$name - [0:0]\n" );
|
||||
}
|
||||
|
||||
@@ -9207,13 +9286,15 @@ sub preview_netfilter_load() {
|
||||
#
|
||||
# Then emit the rules
|
||||
#
|
||||
ensure_cat_mode1;
|
||||
|
||||
for my $chainref ( @chains ) {
|
||||
emitr1($chainref, $_ ) for @{$chainref->{rules}};
|
||||
}
|
||||
#
|
||||
# Commit the changes to the table
|
||||
#
|
||||
enter_cat_mode1 unless $mode == CAT_MODE;
|
||||
ensure_cat_mode1;
|
||||
print "COMMIT\n";
|
||||
}
|
||||
|
||||
@@ -9273,21 +9354,26 @@ sub create_stop_load( $ ) {
|
||||
assert( $chainref->{cmdlevel} == 0 , $name );
|
||||
if ( $name =~ /^DOCKER/ ) {
|
||||
if ( $name eq 'DOCKER' ) {
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-ISOLATION' ) {
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
|
||||
ensure_cmd_mode;
|
||||
emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode;
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-USER' ) {
|
||||
ensure_cmd_mode;
|
||||
emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
|
||||
} else {
|
||||
ensure_cat_mode;
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
} else {
|
||||
ensure_cat_mode;
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
|
||||
@@ -9297,6 +9383,8 @@ sub create_stop_load( $ ) {
|
||||
#
|
||||
# Then emit the rules
|
||||
#
|
||||
ensure_cat_mode;
|
||||
|
||||
for my $chainref ( @chains ) {
|
||||
emitr( $chainref, $_ ) for @{$chainref->{rules}};
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#! /usr/bin/perl -w
|
||||
#
|
||||
# The Shoreline Firewall Packet Filtering Firewall Compiler - V5.0
|
||||
# The Shoreline Firewall Packet Filtering Firewall Compiler - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -269,7 +269,12 @@ sub generate_script_2() {
|
||||
'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes',
|
||||
);
|
||||
emit( 'chain_exists DOCKER-INGRESS && g_dockeringress=Yes' );
|
||||
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes' );
|
||||
emit( 'chain_exists DOCKER-USER && g_dockeruser=Yes' );
|
||||
emit( 'if chain_exists DOCKER-ISOLATION; then',
|
||||
' g_dockernetwork=One',
|
||||
'elif chain_exists DOCKER-ISOLATION-STAGE-1; then',
|
||||
' g_dockernetwork=Two',
|
||||
'fi' );
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
@@ -382,7 +387,7 @@ sub generate_script_3() {
|
||||
my $fn = find_file( $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules' );
|
||||
|
||||
if ( -f $fn && ( $config{EXPORTMODULES} || ( $export && ! $fn =~ "^$globals{SHAREDIR}/" ) ) ) {
|
||||
emit 'echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir';
|
||||
emit 'echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir';
|
||||
emit 'cat > ${VARDIR}/.modules << EOF';
|
||||
open_file $fn;
|
||||
|
||||
|
@@ -465,7 +465,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
TPROXY_TARGET => 'TPROXY Target',
|
||||
FLOW_FILTER => 'Flow Classifier',
|
||||
FWMARK_RT_MASK => 'fwmark route mask',
|
||||
MARK_ANYWHERE => 'Mark in the filter table',
|
||||
MARK_ANYWHERE => 'Mark in the filter and nat tables',
|
||||
HEADER_MATCH => 'Header Match',
|
||||
ACCOUNT_TARGET => 'ACCOUNT Target',
|
||||
AUDIT_TARGET => 'AUDIT Target',
|
||||
@@ -2529,6 +2529,10 @@ sub split_rawline2( $$;$$$ ) {
|
||||
# Delete trailing comment
|
||||
#
|
||||
$currentline =~ s/\s*#.*//;
|
||||
#
|
||||
# Convert ${...} to $...
|
||||
#
|
||||
$currentline =~ s/\$\{(.*?)\}/\$$1/g;
|
||||
|
||||
my @result = &split_line2( @_ );
|
||||
|
||||
@@ -2829,7 +2833,7 @@ sub evaluate_expression( $$$$ ) {
|
||||
}
|
||||
|
||||
# $1 $2 $3 - $4
|
||||
while ( $expression =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $expression =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
|
||||
if ( $var =~ /^\d+$/ ) {
|
||||
@@ -2846,7 +2850,7 @@ sub evaluate_expression( $$$$ ) {
|
||||
|
||||
if ( $chain ) {
|
||||
# $1 $2 $3 - $4
|
||||
while ( $expression =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $expression =~ m( ^(.*?) \@(\{)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
$var = numeric_value( $var ) if $var =~ /^\d/;
|
||||
$val = $var ? $actparams{$var} : $chain;
|
||||
@@ -2857,7 +2861,7 @@ sub evaluate_expression( $$$$ ) {
|
||||
}
|
||||
|
||||
# $1 $2 $3 - $4
|
||||
while ( $expression =~ m( ^(.*?) __({)? (\w+) (?(2)}) (.*)$ )x ) {
|
||||
while ( $expression =~ m( ^(.*?) __(\{)? (\w+) (?(2)}) (.*)$ )x ) {
|
||||
my ( $first, $cap, $rest ) = ( $1, $3, $4);
|
||||
|
||||
if ( exists $capdesc{$cap} ) {
|
||||
@@ -3787,7 +3791,7 @@ sub expand_variables( \$ ) {
|
||||
my ( $lineref, $count ) = ( $_[0], 0 );
|
||||
my $chain = $actparams{chain};
|
||||
# $1 $2 $3 - $4
|
||||
while ( $$lineref =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $$lineref =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
|
||||
@@ -3826,7 +3830,7 @@ sub expand_variables( \$ ) {
|
||||
#
|
||||
$$lineref =~ s/\\@/??/g;
|
||||
# $1 $2 $3 - $4
|
||||
while ( $$lineref =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $$lineref =~ m( ^(.*?) \@(\{)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
my $val = $var ? $actparams{$var} : $actparams{chain};
|
||||
$usedcaller = USEDCALLER if $var eq 'caller';
|
||||
@@ -3842,7 +3846,7 @@ sub expand_variables( \$ ) {
|
||||
sub expand_shorewallrc_variables( \$ ) {
|
||||
my ( $lineref, $count ) = ( $_[0], 0 );
|
||||
# $1 $2 $3 - $4
|
||||
while ( $$lineref =~ m( ^(.*?) \$({)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $$lineref =~ m( ^(.*?) \$(\{)? (\d+|[a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
||||
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
|
||||
@@ -5459,7 +5463,7 @@ sub update_config_file( $ ) {
|
||||
update_default( 'BLACKLIST_DEFAULT', 'AllowICMPs,dropBcasts,dropNotSyn,dropInvalid' );
|
||||
}
|
||||
|
||||
for ( qw/DROP_DEFAULT REJECT_DEFAULT/ ) {
|
||||
for ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT/ ) {
|
||||
my $policy = $config{ $_ };
|
||||
|
||||
if ( $policy =~ /\bA_(?:Drop|Reject)\b/ ) {
|
||||
@@ -5921,7 +5925,7 @@ sub get_params( $ ) {
|
||||
#
|
||||
delete $params{$_};
|
||||
} else {
|
||||
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' ) {
|
||||
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' || $_ eq 'SW_CONFDIR' ) {
|
||||
fatal_error "The variable name $_ is reserved and may not be set in the params file"
|
||||
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
|
||||
}
|
||||
@@ -6599,7 +6603,7 @@ sub get_configuration( $$$ ) {
|
||||
default_yes_no 'BALANCE_PROVIDERS' , $config{USE_DEFAULT_RT} ? 'Yes' : '';
|
||||
default_yes_no 'USE_NFLOG_SIZE' , '';
|
||||
|
||||
if ( ( $val = $config{AUTOMAKE} ) !~ /^[Rr]ecursive$/ ) {
|
||||
if ( ( $val = ( $config{AUTOMAKE} || '' ) ) !~ /^[Rr]ecursive$/ ) {
|
||||
default_yes_no( 'AUTOMAKE' , '' ) unless $val && $val =~ /^\d{1,2}$/;
|
||||
}
|
||||
|
||||
|
@@ -667,8 +667,18 @@ sub create_docker_rules() {
|
||||
|
||||
my $chainref = $filter_table->{FORWARD};
|
||||
|
||||
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
|
||||
add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', );
|
||||
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
|
||||
add_commands( $chainref, '[ -n "$g_dockeruser" ] && echo "-A FORWARD -j DOCKER-USER" >&3', );
|
||||
add_commands( $chainref ,
|
||||
'',
|
||||
'case "$g_dockernetwork" in',
|
||||
' One)',
|
||||
' echo "-A FORWARD -j DOCKER-ISOLATION" >&3',
|
||||
' ;;',
|
||||
' Two)',
|
||||
' echo "-A FORWARD -j DOCKER-ISOLATION-STAGE-1" >&3',
|
||||
' ;;',
|
||||
'esac' );
|
||||
|
||||
if ( my $dockerref = known_interface('docker0') ) {
|
||||
add_commands( $chainref, 'if [ -n "$g_docker" ]; then' );
|
||||
@@ -810,7 +820,7 @@ sub add_common_rules ( $ ) {
|
||||
$dbl_dst_target = $dbl_src_target;
|
||||
}
|
||||
} elsif ( $dbl_level ) {
|
||||
my $chainref = set_optflags( new_standard_chain( $dbl_src_target = 'dbl_log' ) , DONT_OPTIMIZE | DONT_DELETE );
|
||||
my $chainref = set_optflags( new_standard_chain( $dbl_src_target = $dbl_dst_target = 'dbl_log' ) , DONT_OPTIMIZE | DONT_DELETE );
|
||||
|
||||
log_rule_limit( $dbl_level,
|
||||
$chainref,
|
||||
@@ -1714,9 +1724,9 @@ sub add_interface_jumps {
|
||||
add_ijump( $filter_table->{input_chain $bridge },
|
||||
j => $inputref ,
|
||||
imatch_source_dev( $interface, 1 )
|
||||
) unless $input_jump_added{$interface} || ! use_input_chain $interface, $inputref;
|
||||
) unless $input_jump_added{$interface} || ! use_interface_chain( $interface, 'use_input_chain' );
|
||||
|
||||
unless ( $output_jump_added{$interface} || ! use_output_chain $interface, $outputref ) {
|
||||
unless ( $output_jump_added{$interface} || ! use_interface_chain( $interface, 'use_output_chain') ) {
|
||||
add_ijump( $filter_table->{output_chain $bridge} ,
|
||||
j => $outputref ,
|
||||
imatch_dest_dev( $interface, 1 ) )
|
||||
@@ -1725,10 +1735,10 @@ sub add_interface_jumps {
|
||||
} else {
|
||||
add_ijump ( $filter_table->{FORWARD}, j => 'ACCEPT', imatch_source_dev( $interface) , imatch_dest_dev( $interface) ) unless $interfaceref->{nets} || ! $interfaceref->{options}{bridge};
|
||||
|
||||
add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++;
|
||||
add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_input_chain( $interface, $inputref ) && ! $input_jump_added{$interface}++;
|
||||
add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++;
|
||||
add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_interface_chain( $interface, 'use_input_chain' ) && ! $input_jump_added{$interface}++;
|
||||
|
||||
if ( use_output_chain $interface, $outputref ) {
|
||||
if ( use_interface_chain( $interface, 'use_output_chain' ) ) {
|
||||
add_ijump $filter_table->{OUTPUT} , j => $outputref , imatch_dest_dev( $interface ) unless get_interface_option( $interface, 'port' ) || $output_jump_added{$interface}++;
|
||||
}
|
||||
}
|
||||
@@ -1917,7 +1927,7 @@ sub add_output_jumps( $$$$$$$$ ) {
|
||||
my @ipsec_out_match = match_ipsec_out $zone , $hostref;
|
||||
my @zone_interfaces = keys %{zone_interfaces( $zone )};
|
||||
|
||||
if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) {
|
||||
if ( @vservers || use_interface_chain( $interface, 'use_output_chain' ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) {
|
||||
#
|
||||
# - There are vserver zones (so OUTPUT will have multiple source; or
|
||||
# - We must use the interface output chain; or
|
||||
@@ -2051,7 +2061,7 @@ sub add_input_jumps( $$$$$$$$$ ) {
|
||||
my @source = imatch_source_net $net;
|
||||
my @ipsec_in_match = match_ipsec_in $zone , $hostref;
|
||||
|
||||
if ( @vservers || use_input_chain( $interface, $interfacechainref ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
|
||||
if ( @vservers || use_interface_chain( $interface, 'use_input_chain' ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
|
||||
#
|
||||
# - There are vserver zones (so INPUT will have multiple destinations; or
|
||||
# - We must use the interface input chain; or
|
||||
|
@@ -60,7 +60,7 @@ our @routemarked_providers;
|
||||
our %routemarked_interfaces;
|
||||
our @routemarked_interfaces;
|
||||
our %provider_interfaces;
|
||||
our @load_interfaces;
|
||||
our @load_providers;
|
||||
|
||||
our $balancing;
|
||||
our $fallback;
|
||||
@@ -99,7 +99,7 @@ sub initialize( $ ) {
|
||||
%routemarked_interfaces = ();
|
||||
@routemarked_interfaces = ();
|
||||
%provider_interfaces = ();
|
||||
@load_interfaces = ();
|
||||
@load_providers = ();
|
||||
$balancing = 0;
|
||||
$balanced_providers = 0;
|
||||
$fallback_providers = 0;
|
||||
@@ -163,8 +163,8 @@ sub setup_route_marking() {
|
||||
add_ijump_extended $mangle_table->{OUTPUT} , j => $chainref2, $origin, mark => "--mark $mark/$mask";
|
||||
|
||||
if ( have_ipsec ) {
|
||||
if ( have_capability( 'MARK_ANYWHERE' ) ) {
|
||||
add_ijump_extended $filter_table->{forward_chain($interface)}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", , state_imatch('NEW'), policy => '--dir in --pol ipsec';
|
||||
if ( have_capability( 'MARK_ANYWHERE' ) && ( my $chainref = $filter_table->{forward_chain($interface)} ) ) {
|
||||
add_ijump_extended $chainref, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", , state_imatch('NEW'), policy => '--dir in --pol ipsec';
|
||||
} elsif ( have_capability( 'MANGLE_FORWARD' ) ) {
|
||||
add_ijump_extended $mangle_table->{FORWARD}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", i => $physical, state_imatch('NEW'), policy => '--dir in --pol ipsec';
|
||||
}
|
||||
@@ -185,16 +185,16 @@ sub setup_route_marking() {
|
||||
add_ijump $chainref, j => 'CONNMARK', targetopts => "--save-mark --mask $mask", mark => "! --mark 0/$mask";
|
||||
}
|
||||
|
||||
if ( @load_interfaces ) {
|
||||
if ( @load_providers ) {
|
||||
my $chainref1 = new_chain 'mangle', 'balance';
|
||||
my @match;
|
||||
|
||||
add_ijump $chainref, g => $chainref1, mark => "--mark 0/$mask";
|
||||
add_ijump $mangle_table->{OUTPUT}, j => $chainref1, state_imatch( 'NEW,RELATED' ), mark => "--mark 0/$mask";
|
||||
|
||||
for my $physical ( @load_interfaces ) {
|
||||
for my $provider ( @load_providers ) {
|
||||
|
||||
my $chainref2 = new_chain( 'mangle', load_chain( $physical ) );
|
||||
my $chainref2 = new_chain( 'mangle', load_chain( $provider ) );
|
||||
|
||||
set_optflags( $chainref2, DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE );
|
||||
|
||||
@@ -446,7 +446,7 @@ sub process_a_provider( $ ) {
|
||||
fatal_error 'NAME must be specified' if $table eq '-';
|
||||
|
||||
unless ( $pseudo ) {
|
||||
fatal_error "Invalid Provider Name ($table)" unless $table =~ /^[\w]+$/;
|
||||
fatal_error "Invalid Provider Name ($table)" unless $table =~ /^[A-Za-z][\w]*$/;
|
||||
|
||||
my $num = numeric_value $number;
|
||||
|
||||
@@ -636,6 +636,7 @@ sub process_a_provider( $ ) {
|
||||
}
|
||||
|
||||
fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)};
|
||||
fatal_error "An interface supporting multiple providers may not be optional" if $shared && $optional;
|
||||
|
||||
unless ( $pseudo ) {
|
||||
if ( $local ) {
|
||||
@@ -779,7 +780,7 @@ sub process_a_provider( $ ) {
|
||||
push @routemarked_providers, $providers{$table};
|
||||
}
|
||||
|
||||
push @load_interfaces, $physical if $load;
|
||||
push @load_providers, $table if $load;
|
||||
|
||||
push @providers, $table;
|
||||
|
||||
@@ -941,8 +942,9 @@ sub add_a_provider( $$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
emit( "echo $load > \${VARDIR}/${physical}_load",
|
||||
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${physical}_mark" ) if $load;
|
||||
emit( "echo $load > \${VARDIR}/${table}_load",
|
||||
'echo ' . in_hex( $mark ) . '/' . in_hex( $globals{PROVIDER_MASK} ) . " > \${VARDIR}/${table}_mark",
|
||||
"echo $physical > \${VARDIR}/${table}_interface" ) if $load;
|
||||
|
||||
emit( '',
|
||||
"cat <<EOF >> \${VARDIR}/undo_${table}_routing" );
|
||||
@@ -1097,7 +1099,7 @@ CEOF
|
||||
$weight = 1;
|
||||
}
|
||||
|
||||
emit ( "distribute_load $maxload @load_interfaces" ) if $load;
|
||||
emit ( "distribute_load $maxload @load_providers" ) if $load;
|
||||
|
||||
unless ( $shared ) {
|
||||
emit( "setup_${dev}_tc" ) if $tcdevices->{$interface};
|
||||
@@ -1244,7 +1246,7 @@ CEOF
|
||||
}
|
||||
|
||||
emit ( '',
|
||||
"distribute_load $maxload @load_interfaces" ) if $load;
|
||||
"distribute_load $maxload @load_providers" ) if $load;
|
||||
|
||||
if ( $persistent ) {
|
||||
emit ( '',
|
||||
@@ -1615,7 +1617,7 @@ sub finish_providers() {
|
||||
emit( 'fi',
|
||||
'' );
|
||||
} else {
|
||||
if ( ( $fallback || @load_interfaces ) && $config{USE_DEFAULT_RT} ) {
|
||||
if ( ( $fallback || @load_providers ) && $config{USE_DEFAULT_RT} ) {
|
||||
emit ( q(#),
|
||||
q(# Delete any default routes in the 'main' table),
|
||||
q(#),
|
||||
@@ -1909,24 +1911,24 @@ sub setup_providers() {
|
||||
pop_indent;
|
||||
emit 'fi';
|
||||
|
||||
setup_route_marking if @routemarked_interfaces || @load_interfaces;
|
||||
setup_route_marking if @routemarked_interfaces || @load_providers;
|
||||
} else {
|
||||
emit "\nif [ -z \"\$g_noroutes\" ]; then";
|
||||
|
||||
push_indent;
|
||||
|
||||
emit "undo_routing";
|
||||
emit "restore_default_route $config{USE_DEFAULT_RT}";
|
||||
|
||||
if ( $pseudoproviders ) {
|
||||
emit '';
|
||||
emit "start_$providers{$_}->{what}_$_" for @providers;
|
||||
emit '';
|
||||
}
|
||||
|
||||
emit "undo_routing";
|
||||
emit "restore_default_route $config{USE_DEFAULT_RT}";
|
||||
|
||||
my $standard_routes = @{$providers{main}{routes}} || @{$providers{default}{routes}};
|
||||
|
||||
if ( $config{NULL_ROUTE_RFC1918} ) {
|
||||
emit '';
|
||||
setup_null_routing;
|
||||
emit "\nrun_ip route flush cache" unless $standard_routes;
|
||||
}
|
||||
@@ -2485,7 +2487,7 @@ sub handle_stickiness( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( @routemarked_providers || @load_interfaces ) {
|
||||
if ( @routemarked_providers || @load_providers ) {
|
||||
delete_jumps $mangle_table->{PREROUTING}, $setstickyref unless @{$setstickyref->{rules}};
|
||||
delete_jumps $mangle_table->{OUTPUT}, $setstickoref unless @{$setstickoref->{rules}};
|
||||
}
|
||||
@@ -2493,9 +2495,9 @@ sub handle_stickiness( $ ) {
|
||||
|
||||
sub setup_load_distribution() {
|
||||
emit ( '',
|
||||
"distribute_load $maxload @load_interfaces" ,
|
||||
"distribute_load $maxload @load_providers" ,
|
||||
''
|
||||
) if @load_interfaces;
|
||||
) if @load_providers;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -2781,7 +2781,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||
LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } ,
|
||||
|
||||
HELPER => sub {
|
||||
fatal_error "HELPER requires require that the helper be specified in the HELPER column" if $helper eq '-';
|
||||
fatal_error "HELPER requires that a helper be specified in the HELPER column" if $helper eq '-';
|
||||
fatal_error "HELPER rules may only appear in the NEW section" unless $section == NEW_SECTION;
|
||||
$action = ''; } ,
|
||||
|
||||
@@ -3137,13 +3137,14 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||
if ( $actiontype & ( NATRULE | NONAT ) && ! ( $actiontype & NATONLY ) ) {
|
||||
#
|
||||
# Either a DNAT, REDIRECT or ACCEPT+ rule or an Action with NAT;
|
||||
# don't apply rate limiting twice
|
||||
#
|
||||
$rule .= join( '',
|
||||
do_proto($proto, $ports, $sports),
|
||||
do_ratelimit( $ratelimit, 'ACCEPT' ),
|
||||
do_user( $user ) ,
|
||||
do_test( $mark , $globals{TC_MASK} ) ,
|
||||
do_connlimit( $connlimit ),
|
||||
do_ratelimit( $ratelimit, 'ACCEPT' ),
|
||||
do_time( $time ) ,
|
||||
do_headers( $headers ) ,
|
||||
do_condition( $condition , $chain ) ,
|
||||
@@ -3239,12 +3240,12 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||
# - the destination IP will be the server IP ($dest) -- also done above
|
||||
# - there will be no log level (we log NAT rules in the nat table rather than in the filter table).
|
||||
# - the target will be ACCEPT.
|
||||
# - don't apply rate limiting twice
|
||||
#
|
||||
unless ( $actiontype & NATONLY ) {
|
||||
$rule = join( '',
|
||||
$matches,
|
||||
do_proto( $proto, $ports, $sports ),
|
||||
do_ratelimit( $ratelimit, 'ACCEPT' ),
|
||||
do_user $user,
|
||||
do_test( $mark , $globals{TC_MASK} ),
|
||||
do_condition( $condition , $chain ),
|
||||
@@ -4077,6 +4078,10 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
O => OUTPUT,
|
||||
T => POSTROUTING,
|
||||
R => REALPREROUTING,
|
||||
NP => REALPREROUTING,
|
||||
NI => REALINPUT,
|
||||
NO => REALOUTPUT,
|
||||
NT => REALPOSTROUTING
|
||||
);
|
||||
|
||||
my %chainlabels = ( 1 => 'PREROUTING',
|
||||
@@ -4085,14 +4090,17 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
8 => 'OUTPUT',
|
||||
16 => 'POSTROUTING' );
|
||||
|
||||
my %chainnames = ( 1 => 'tcpre',
|
||||
2 => 'tcin',
|
||||
4 => 'tcfor',
|
||||
8 => 'tcout',
|
||||
16 => 'tcpost',
|
||||
32 => 'sticky',
|
||||
64 => 'sticko',
|
||||
128 => 'PREROUTING',
|
||||
my %chainnames = ( 1 => 'tcpre',
|
||||
2 => 'tcin',
|
||||
4 => 'tcfor',
|
||||
8 => 'tcout',
|
||||
16 => 'tcpost',
|
||||
32 => 'sticky',
|
||||
64 => 'sticko',
|
||||
128 => 'PREROUTING',
|
||||
256 => 'INPUT',
|
||||
512 => 'OUTPUT',
|
||||
1024 => 'POSTROUTING',
|
||||
);
|
||||
|
||||
my $inchain = defined $chainref;
|
||||
@@ -4116,6 +4124,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $actiontype;
|
||||
my $commandref;
|
||||
my $prerule = '';
|
||||
my $table = 'mangle';
|
||||
my $tabletype = MANGLE_TABLE;
|
||||
#
|
||||
# Subroutine for handling MARK and CONNMARK. We use an enclosure so as to keep visibility of the
|
||||
# function's local variables without making them static. process_mangle_rule1() is called
|
||||
@@ -4157,7 +4167,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
$option ||= ( $and_or eq '|' ? '--or-mark' : $and_or ? '--and-mark' : '--set-mark' );
|
||||
|
||||
my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} );
|
||||
my $chainref = ensure_chain( $table, $chain = $chainnames{$chain} );
|
||||
|
||||
$restriction |= $chainref->{restriction};
|
||||
|
||||
@@ -4476,7 +4486,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $tgt, $options ) = split( ' ', $params, 2 );
|
||||
my $target_type = $builtin_target{$tgt};
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
|
||||
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & $tabletype;
|
||||
$target = $params;
|
||||
$usergenerated = 1;
|
||||
},
|
||||
@@ -4492,7 +4502,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $tgt, $options ) = split( ' ', $params, 2 );
|
||||
my $target_type = $builtin_target{$tgt};
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
|
||||
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & $tabletype;
|
||||
$target = $params;
|
||||
$usergenerated = 1;
|
||||
},
|
||||
@@ -4564,7 +4574,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
RESTORE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING | REALPREROUTING | REALINPUT | REALOUTPUT | REALPOSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -4600,7 +4610,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
SAVE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING | REALPREROUTING | REALINPUT | REALOUTPUT | REALPOSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -4846,6 +4856,14 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
fatal_error "A chain designator may not be specified in an action body" if $inaction;
|
||||
my $temp = $designators{$designator};
|
||||
fatal_error "Invalid chain designator ( $designator )" unless $temp;
|
||||
|
||||
if ( $designator =~ /^N/ ) {
|
||||
fatal_error "Only MARK, CONNMARK, SAVE and RESTORE may be used in the nat table" unless $cmd =~ /^(?:(?:(?:CONN)MARK)|SAVE|RESTORE)[(]?/;
|
||||
require_capability('MARK_ANYWHERE', "The $designator designator", 's');
|
||||
$table = 'nat';
|
||||
$tabletype = NAT_TABLE;
|
||||
}
|
||||
|
||||
$designator = $temp;
|
||||
}
|
||||
|
||||
@@ -4878,12 +4896,21 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
if ( $source ne '-' ) {
|
||||
if ( $source eq $fw ) {
|
||||
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' if $designator && $designator != OUTPUT;
|
||||
$chain = OUTPUT;
|
||||
if ( $designator ) {
|
||||
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' unless $designator & ( OUTPUT | REALOUTPUT );
|
||||
$chain = $designator;
|
||||
} else {
|
||||
$chain = OUTPUT;
|
||||
}
|
||||
|
||||
$source = '-';
|
||||
} elsif ( $source =~ s/^($fw):// ) {
|
||||
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' if $designator && $designator != OUTPUT;
|
||||
$chain = OUTPUT;
|
||||
if ( $designator ) {
|
||||
fatal_error 'Rules with SOURCE $FW must use the OUTPUT chain' unless $designator & ( OUTPUT | REALOUTPUT );
|
||||
$chain = $designator;
|
||||
} else {
|
||||
$chain = OUTPUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4953,11 +4980,11 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
} else {
|
||||
$resolve_chain->();
|
||||
fatal_error "$cmd rules are not allowed in the $chainlabels{$chain} chain" unless $commandref->{allowedchains} & $chain;
|
||||
unless ( $chain == OUTPUT || $chain == POSTROUTING ) {
|
||||
unless ( $chain & ( OUTPUT | POSTROUTING | REALOUTPUT | REALPOSTROUTING ) ) {
|
||||
fatal_error 'A USER/GROUP may only be specified when the SOURCE is $FW' unless $user eq '-';
|
||||
}
|
||||
|
||||
$chainref = ensure_chain( 'mangle', $chainnames{$chain} );
|
||||
$chainref = ensure_chain( $table, $chainnames{$chain} );
|
||||
}
|
||||
|
||||
$restriction |= $chainref->{restriction};
|
||||
@@ -5547,6 +5574,15 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
$chainref = $interface ? ensure_chain('nat', $pre_nat ? snat_chain $interface : masq_chain $interface) : $nat_table->{INPUT};
|
||||
}
|
||||
|
||||
if ( $chainref->{complete} ) {
|
||||
if ( $interface ) {
|
||||
warning_message( "Interface $interface entry generated no $toolname rule" );
|
||||
} else {
|
||||
warning_message( "Entry generated no $toolname rule" );
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
$baserule .= do_condition( $condition , $chainref->{name} );
|
||||
#
|
||||
# Handle IPSEC options, if any
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall Packet Filtering Firewall Param File Helper - V4.4
|
||||
# The Shoreline Firewall Packet Filtering Firewall Param File Helper - V5.2
|
||||
#
|
||||
# (c) 2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -601,26 +601,29 @@ interface_enabled() {
|
||||
}
|
||||
|
||||
distribute_load() {
|
||||
local provider
|
||||
local interface
|
||||
local currentload # Total load of enabled interfaces
|
||||
local load # Specified load of an enabled interface
|
||||
local mark # Mark of an enabled interface
|
||||
local totalload # Total load of all interfaces - usually 1.000000
|
||||
local nload # Normalized load of an enabled interface
|
||||
local var # Interface name to embed in a variable name
|
||||
local currentload # Total load of enabled providers
|
||||
local load # Specified load of an enabled provider
|
||||
local mark # Mark of an enabled provider
|
||||
local totalload # Total load of all providers - usually 1.000000
|
||||
local nload # Normalized load of an enabled provider
|
||||
|
||||
totalload=$1
|
||||
shift
|
||||
|
||||
currentload=0
|
||||
|
||||
for interface in $@; do
|
||||
for provider in $@; do
|
||||
|
||||
interface=$(cat ${VARDIR}/${provider}_interface)
|
||||
eval ${provider}_interface=$interface
|
||||
|
||||
if interface_enabled $interface; then
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
load=$(cat ${VARDIR}/${interface}_load)
|
||||
eval ${var}_load=$load
|
||||
mark=$(cat ${VARDIR}/${interface}_mark)
|
||||
eval ${var}_mark=$mark
|
||||
load=$(cat ${VARDIR}/${provider}_load)
|
||||
eval ${provider}_load=$load
|
||||
mark=$(cat ${VARDIR}/${provider}_mark)
|
||||
eval ${provider}_mark=$mark
|
||||
currentload=$( bc <<EOF
|
||||
scale=8
|
||||
$currentload + $load
|
||||
@@ -630,12 +633,13 @@ EOF
|
||||
done
|
||||
|
||||
if [ $currentload ]; then
|
||||
for interface in $@; do
|
||||
qt $g_tool -t mangle -F ~$interface
|
||||
for provider in $@; do
|
||||
eval interface=\$${provider}_interface
|
||||
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
eval load=\$${var}_load
|
||||
eval mark=\$${var}_mark
|
||||
qt $g_tool -t mangle -F ~$provider
|
||||
|
||||
eval load=\$${provider}_load
|
||||
eval mark=\$${provider}_mark
|
||||
|
||||
if [ -n "$load" ]; then
|
||||
nload=$(bc <<EOF
|
||||
@@ -651,10 +655,10 @@ EOF
|
||||
|
||||
case $nload in
|
||||
.*|0.*)
|
||||
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $nload -j MARK --set-mark $mark
|
||||
run_iptables -t mangle -A ~$provider -m statistic --mode random --probability $nload -j MARK --set-mark $mark
|
||||
;;
|
||||
*)
|
||||
run_iptables -t mangle -A ~$interface -j MARK --set-mark $mark
|
||||
run_iptables -t mangle -A ~$provider -j MARK --set-mark $mark
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -675,7 +679,7 @@ interface_is_usable() # $1 = interface
|
||||
status=0
|
||||
|
||||
if ! loopback_interface $1; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ] && [ -z "$($IP -$g_family link list dev $1 2> /dev/null | fgrep 'state DOWN')" ]; then
|
||||
if [ "$COMMAND" != enable ]; then
|
||||
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
|
||||
status=$?
|
||||
@@ -959,7 +963,7 @@ add_gateway() # $1 = Delta $2 = Table Number
|
||||
local delta
|
||||
local dev
|
||||
|
||||
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/[\]//g'`
|
||||
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/linkdown//g; s/[\]//g'`
|
||||
|
||||
if [ -z "$route" ]; then
|
||||
run_ip route add default scope global table $2 $1
|
||||
@@ -993,7 +997,7 @@ delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device
|
||||
local gateway
|
||||
local dev
|
||||
|
||||
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/[\]//g'`
|
||||
route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/linkdown//g; s/[\]//g'`
|
||||
gateway=$1
|
||||
|
||||
if [ -n "$route" ]; then
|
||||
@@ -1101,7 +1105,7 @@ interface_is_usable() # $1 = interface
|
||||
status=0
|
||||
|
||||
if [ "$1" != lo ]; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ]; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ] && [ -z "$($IP -$g_family link list dev $1 2> /dev/null | fgrep 'state DOWN')" ]; then
|
||||
if [ "$COMMAND" != enable ]; then
|
||||
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
|
||||
status=$?
|
||||
|
@@ -67,5 +67,4 @@ loadmodule ipt_LOG
|
||||
loadmodule nf_log_ipv4
|
||||
loadmodule xt_LOG
|
||||
loadmodule xt_NFLOG
|
||||
loadmodule ipt_ULOG
|
||||
loadmodule nfnetlink_log
|
||||
|
117
Shorewall/init.alt.sh
Executable file
117
Shorewall/init.alt.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall init script
|
||||
#
|
||||
# chkconfig: - 28 90
|
||||
# description: Packet filtering firewall
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall
|
||||
# Required-Start: $local_fs $remote_fs $syslog $network
|
||||
# Should-Start: $time $named
|
||||
# Required-Stop:
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Packet filtering firewall
|
||||
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
|
||||
# Netfilter (iptables) based firewall
|
||||
### END INIT INFO
|
||||
|
||||
# Do not load RH compatibility interface.
|
||||
WITHOUT_RC_COMPAT=1
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
#
|
||||
# The installer may alter this
|
||||
#
|
||||
. /usr/share/shorewall/shorewallrc
|
||||
|
||||
NAME="Shorewall firewall"
|
||||
PROG="shorewall"
|
||||
SHOREWALL="$SBINDIR/$PROG"
|
||||
LOGGER="logger -i -t $PROG"
|
||||
|
||||
# Get startup options (override default)
|
||||
OPTIONS=
|
||||
|
||||
SourceIfNotEmpty $SYSCONFDIR/$PROG
|
||||
|
||||
LOCKFILE=/var/lock/subsys/shorewall
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
reload() {
|
||||
action $"Reloading $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
clear() {
|
||||
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
condrestart)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condreload)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condstop)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
stop
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
"$SHOREWALL" status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
RCDLINKS="2,S41 3,S41 6,K41"
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.2
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005, 2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.2
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -197,6 +197,9 @@ if [ -z "$BUILD" ]; then
|
||||
opensuse)
|
||||
BUILD=suse
|
||||
;;
|
||||
alt|basealt|altlinux)
|
||||
BUILD=alt
|
||||
;;
|
||||
*)
|
||||
BUILD="$ID"
|
||||
;;
|
||||
@@ -205,6 +208,8 @@ if [ -z "$BUILD" ]; then
|
||||
BUILD=debian
|
||||
elif [ -f /etc/gentoo-release ]; then
|
||||
BUILD=gentoo
|
||||
elif [ -f /etc/altlinux-release ]; then
|
||||
BUILD=alt
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
BUILD=redhat
|
||||
elif [ -f /etc/slackware-version ] ; then
|
||||
@@ -269,6 +274,9 @@ case "$HOST" in
|
||||
openwrt)
|
||||
echo "Installing OpenWRT-specific configuration..."
|
||||
;;
|
||||
alt)
|
||||
echo "Installing ALT-specific configuration...";
|
||||
;;
|
||||
linux)
|
||||
;;
|
||||
*)
|
||||
|
@@ -412,10 +412,14 @@ uptodate() {
|
||||
elif [ -n "$(${find} ${dir} -maxdepth $AUTOMAKE -type f -newer $1 -print)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
elif [ $AUTOMAKE = recursive ]; then
|
||||
elif [ "$AUTOMAKE" = recursive ]; then
|
||||
if [ -n "$(${find} ${dir} -newer $1 -print -quit)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
elif [ -z "$AUTOMAKE" ]; then
|
||||
if [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print -quit)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
elif [ -n "$(${find} ${dir} -maxdepth $AUTOMAKE -type f -newer $1 -print -quit)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
@@ -452,6 +456,16 @@ compiler() {
|
||||
|
||||
ensure_root
|
||||
#
|
||||
# Let params and the compiler know the base configuration directory
|
||||
#
|
||||
if [ -n "$g_shorewalldir" ]; then
|
||||
SW_CONFDIR="$g_shorewalldir"
|
||||
else
|
||||
SW_CONFDIR="$g_confdir"
|
||||
fi
|
||||
|
||||
export SW_CONFDIR
|
||||
#
|
||||
# We've now set g_shorewalldir so recalculate CONFIG_PATH
|
||||
#
|
||||
[ -n "$g_haveconfig" ] || ensure_config_path
|
||||
@@ -1063,6 +1077,41 @@ restart_command() {
|
||||
return $rc
|
||||
}
|
||||
|
||||
read_yesno_with_timeout() {
|
||||
local timeout
|
||||
timeout=${1:-60}
|
||||
|
||||
case $timeout in
|
||||
*s)
|
||||
;;
|
||||
*m)
|
||||
timeout=$((${timeout%m} * 60))
|
||||
;;
|
||||
*h)
|
||||
timeout=$((${timeout%h} * 3600))
|
||||
;;
|
||||
esac
|
||||
|
||||
read -t $timeout yn 2> /dev/null
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
# read doesn't support timeout
|
||||
test -x /bin/bash || return 2 # bash is not installed so the feature is not available
|
||||
/bin/bash -c "read -t $timeout yn ; if [ \"\$yn\" == \"y\" ] ; then exit 0 ; else exit 1 ; fi" # invoke bash and use its version of read
|
||||
return $?
|
||||
else
|
||||
# read supports timeout
|
||||
case "$yn" in
|
||||
y|Y)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Safe-start/safe-reload/safe-restart Command Executor
|
||||
#
|
||||
@@ -1652,7 +1701,7 @@ remote_commands() # $* = original arguments less the command.
|
||||
#
|
||||
# Handle nonstandard remote VARDIR
|
||||
#
|
||||
progress_message2 "Getting VARDIR on system $system..."
|
||||
progress_message3 "Getting VARDIR on system $system..."
|
||||
temp=$(rsh_command $program show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
|
||||
|
||||
[ -n "$temp" ] && litedir="$temp"
|
||||
|
199
Shorewall/manpages/shorewall-addresses.xml
Normal file
199
Shorewall/manpages/shorewall-addresses.xml
Normal file
@@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||
<refentry>
|
||||
<refmeta>
|
||||
<refentrytitle>shorewall-addresses</refentrytitle>
|
||||
|
||||
<manvolnum>5</manvolnum>
|
||||
|
||||
<refmiscinfo>Configuration Files</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>addresses</refname>
|
||||
|
||||
<refpurpose>Specifying addresses within a Shorewall
|
||||
configuration</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>In both Shorewall and Shorewall6, there are two basic types of
|
||||
addresses:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>Host Address</term>
|
||||
|
||||
<listitem>
|
||||
<para>This address type refers to a single host.</para>
|
||||
|
||||
<para>In IPv4, the format is <emphasis>i.j.k.l</emphasis> where
|
||||
<emphasis>i</emphasis> through <emphasis>l</emphasis> are decimal
|
||||
numbers between 1 and 255.</para>
|
||||
|
||||
<para>In IPv6, the format is <emphasis>a:b:c:d:e:f:g:h</emphasis>
|
||||
where <emphasis>a</emphasis> through <emphasis>h</emphasis> consist
|
||||
of 1 to 4 hexadecimal digits (leading zeros may be omitted). a
|
||||
single series of 0 addresses may be omitted. For example
|
||||
2001:227:e857:1:0:0:0:0:1 may be written 2001:227:e857:1::1.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Network Address</term>
|
||||
|
||||
<listitem>
|
||||
<para>A network address refers to 1 or more hosts and consists of a
|
||||
host address followed by a slash ("/") and a <firstterm>Variable
|
||||
Length Subnet Mask</firstterm> (VLSM). This is known as
|
||||
<firstterm>Classless Internet Domain Routing</firstterm> (CIDR)
|
||||
notation.</para>
|
||||
|
||||
<para>The VLSM is a decimal number. For IPv4, it is in the range 0
|
||||
through 32. For IPv6, the range is 0 through 128. The number
|
||||
represents the number of leading bits in the address that represent
|
||||
the network address; the remainder of the bits are a host address
|
||||
and are generally given as zero.</para>
|
||||
|
||||
<para>Examples:</para>
|
||||
|
||||
<para>IPv4: 192.168.1.0/24</para>
|
||||
|
||||
<para>IPv6: 2001:227:e857:1:0:0:0:0:1/64</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>In the Shorewall documentation and manpages, we have tried to make
|
||||
it clear which type of address is accepted in each specific case.</para>
|
||||
|
||||
<para>Because Shorewall uses a colon (":") as a separator in many
|
||||
contexts, IPv6 addresses are best written using the standard convention in
|
||||
which the address itself is enclosed in square brackets:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>[2001:227:e857:1::1]</member>
|
||||
|
||||
<member>[2001:227:e857:1::]/64</member>
|
||||
</simplelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Specifying SOURCE and DEST</title>
|
||||
|
||||
<para>Entries in Shorewall configuration files often deal with the source
|
||||
(SOURCE) and destination (DEST) of connections and Shorewall implements a
|
||||
uniform way for specifying them.</para>
|
||||
|
||||
<para>A SOURCE or DEST consists of one to three parts separated by colons
|
||||
(":"):</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>ZONE — The name of a zone declared in
|
||||
<filename>/etc/shorewall/zones</filename> or
|
||||
<filename>/etc/shorewall6/zones</filename>. This part is only
|
||||
available in the rules file
|
||||
(<filename>/etc/shorewall/rules</filename>,
|
||||
<filename>/etc/shorewall/blrules</filename>,<filename>
|
||||
/etc/shorewall6/rules</filename> and
|
||||
<filename>/etc/shorewall6/blrules</filename>).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>INTERFACE — The name of an interface that matches an entry in
|
||||
<filename>/etc/shorewall/interfaces</filename>
|
||||
(<filename>/etc/shorewall6/interfaces</filename>).</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!' which
|
||||
matches all interfaces except the one specified.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>ADDRESS LIST — A list of one or more addresses (host or network)
|
||||
or address ranges, separated by commas. In an IPv6 configuration, this
|
||||
list must be included in square or angled brackets ("[...]" or
|
||||
"<...>"). The list may have exclusion.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>Examples.</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>All hosts in the <emphasis role="bold">net</emphasis> zone —
|
||||
<emphasis role="bold">net</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Subnet 192.168.1.0/29 in the <emphasis
|
||||
role="bold">loc</emphasis> zone — <emphasis
|
||||
role="bold">loc:192.168.1.0/29</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>All hosts in the net zone connecting through <filename
|
||||
class="devicefile">ppp0</filename> — <emphasis
|
||||
role="bold">net:ppp0</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>All hosts interfaced by <filename
|
||||
class="devicefile">eth3</filename> — <emphasis
|
||||
role="bold">eth3</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Subnet 10.0.1.0/24 interfacing through <filename><filename
|
||||
class="devicefile">eth2</filename></filename> — <emphasis
|
||||
role="bold">eth2:10.0.1.0/24</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Host 2002:ce7c:92b4:1:a00:27ff:feb1:46a9 in the <emphasis
|
||||
role="bold">loc</emphasis> zone — <emphasis
|
||||
role="bold">loc:[2002:ce7c:92b4:1:a00:27ff:feb1:46a9]</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The primary IP address of eth0 in the $FW zone - <emphasis
|
||||
role="bold">$FW:&eth0</emphasis></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>All hosts in Vatican City - <emphasis
|
||||
role="bold">net:^VA</emphasis> (Requires the <emphasis>GeoIP
|
||||
Match</emphasis> capability).</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>IP Address Ranges</title>
|
||||
|
||||
<para>If you kernel and iptables have <emphasis>IP Range match
|
||||
support</emphasis>, you may use IP address ranges in Shorewall
|
||||
configuration file entries; IP address ranges have the syntax
|
||||
<<emphasis>low IP address</emphasis>>-<<emphasis>high IP
|
||||
address</emphasis>>.</para>
|
||||
|
||||
<para>Example: 192.168.1.5-192.168.1.12.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title/>
|
||||
|
||||
<para/>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>See ALSO</title>
|
||||
|
||||
<para>For more information about addressing, see the<ulink
|
||||
url="shorewall_setup_guide.htm#Addressing"> Setup Guide</ulink>.</para>
|
||||
</refsect1>
|
||||
</refentry>
|
@@ -280,9 +280,9 @@
|
||||
<term>IPv4 Example 1:</term>
|
||||
|
||||
<listitem>
|
||||
<para>Drop Teredo packets from the net.</para>
|
||||
<para>Drop 6to4 packets from the net.</para>
|
||||
|
||||
<programlisting>DROP net:[2001::/32] all</programlisting>
|
||||
<programlisting>DROP net:192.88.99.1 all</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -290,10 +290,10 @@
|
||||
<term>IPv4 Example 2:</term>
|
||||
|
||||
<listitem>
|
||||
<para>Don't subject packets from 2001:DB8::/64 to the remaining
|
||||
<para>Don't subject packets from 70.90.191.120/29 to the remaining
|
||||
rules in the file.</para>
|
||||
|
||||
<programlisting>WHITELIST net:[2001:DB8::/64] all</programlisting>
|
||||
<programlisting>WHITELIST net:70.90.191.120/29 all</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
967
Shorewall/manpages/shorewall-files.xml
Normal file
967
Shorewall/manpages/shorewall-files.xml
Normal file
@@ -0,0 +1,967 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||
<refentry>
|
||||
<refmeta>
|
||||
<refentrytitle>shorewall-files</refentrytitle>
|
||||
|
||||
<manvolnum>5</manvolnum>
|
||||
|
||||
<refmiscinfo>Configuration Files</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>files</refname>
|
||||
|
||||
<refpurpose>Shorewall Configuration Files</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>/etc/shorewall[6]/*</command>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>The following are the Shorewall[6] configuration files:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para><ulink
|
||||
url="shorewall.conf.html"><filename>/etc/shorewall/shorewall.conf</filename>
|
||||
and <filename>/etc/shorewall6/shorewall6.conf</filename></ulink> -
|
||||
used to set global firewall parameters.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-params.html">/etc/shorewall[6]/params</ulink></filename>
|
||||
- use this file to set shell variables that you will expand in other
|
||||
files. It is always processed by /bin/sh or by the shell specified
|
||||
through SHOREWALL_SHELL in
|
||||
<filename>/etc/shorewall/shorewall.conf.</filename></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-zones.html">/etc/shorewall[6]/zones</ulink></filename>
|
||||
- partition the firewall's view of the world into zones.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><ulink
|
||||
url="shorewall-policy.html"><filename>/etc/shorewall[6]/policy</filename></ulink>
|
||||
- establishes firewall high-level policy.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/initdone</filename> - An optional
|
||||
Perl script that will be invoked by the Shorewall rules compiler when
|
||||
the compiler has finished it's initialization.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-interfaces.html">/etc/shorewall[6]/interfaces</ulink></filename>
|
||||
- describes the interfaces on the firewall system.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-hosts.html">/etc/shorewall[6]/hosts</ulink></filename>
|
||||
- allows defining zones in terms of individual hosts and
|
||||
subnetworks.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-masq.html">/etc/shorewall[6]/masq</ulink></filename> -
|
||||
directs the firewall where to use many-to-one (dynamic) Network
|
||||
Address Translation (a.k.a. Masquerading) and Source Network Address
|
||||
Translation (SNAT). Superseded by /etc/shorewall[6]/snat in Shorewall
|
||||
5.0.14 and not supported in Shorewall 5.1.0 and later versions.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-mangle.html">/etc/shorewall[6]/mangle</ulink></filename>
|
||||
- supersedes <filename>/etc/shorewall/tcrules</filename> in Shorewall
|
||||
4.6.0. Contains rules for packet marking, TTL, TPROXY, etc.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-rules.html">/etc/shorewall[6]/rules</ulink></filename>
|
||||
- defines rules that are exceptions to the overall policies
|
||||
established in /etc/shorewall/policy.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-nat.html">/etc/shorewall[6]/nat</ulink></filename> -
|
||||
defines one-to-one NAT rules.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-proxyarp.html">/etc/shorewall6/proxyarp</ulink></filename>
|
||||
- defines use of Proxy ARP.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-proxyndp.html">/etc/shorewall6/proxyndp</ulink></filename>
|
||||
- defines use of Proxy NDP.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/routestopped</filename> - defines
|
||||
hosts accessible when Shorewall is stopped. Superseded in Shorewall
|
||||
4.6.8 by <filename>/etc/shorewall/stoppedrules</filename>. Not
|
||||
supported in Shorewall 5.0.0 and later versions.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-tcrules.html">/etc/shorewall[6]/tcrules</ulink>
|
||||
</filename>- The file has a rather unfortunate name because it is used
|
||||
to define marking of packets for later use by both traffic
|
||||
control/shaping and policy routing. This file is superseded by
|
||||
<filename>/etc/shorewall/mangle</filename> in Shorewall 4.6.0. Not
|
||||
supported in Shorewall 5.0.0 and later releases.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-tos.html">/etc/shorewall[6]/tos</ulink></filename> -
|
||||
defines rules for setting the TOS field in packet headers. Superseded
|
||||
in Shorewall 4.5.1 by the TOS target in
|
||||
<filename>/etc/shorewall/tcrules</filename> (which file has since been
|
||||
superseded by <filename>/etc/shorewall/mangle</filename>). Not
|
||||
supported in Shorewall 5.0.0 and later versions.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><ulink
|
||||
url="shorewall-tunnels.html"><filename>/etc/shorewall[6]/tunnels</filename></ulink>
|
||||
- defines tunnels (VPN) with end-points on the firewall system.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><ulink
|
||||
url="shorewall-blacklist.html"><filename>/etc/shorewall[6]/blacklist</filename></ulink>
|
||||
- Deprecated in favor of <filename>/etc/shorewall/blrules</filename>.
|
||||
Lists blacklisted IP/subnet/MAC addresses. Not supported in Shorewall
|
||||
5.0.0 and later releases.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/blrules</filename> — Added in
|
||||
Shorewall 4.5.0. Define blacklisting and whitelisting. Supersedes
|
||||
<filename>/etc/shorewall/blacklist</filename>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/init</filename> - shell commands
|
||||
that you wish to execute at the beginning of a <quote>shorewall
|
||||
start</quote>, "shorewall reload" or <quote>shorewall
|
||||
restart</quote>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/start</filename> - shell commands
|
||||
that you wish to execute near the completion of a <quote>shorewall
|
||||
start</quote>, "shorewall reload" or <quote>shorewall
|
||||
restart</quote></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/started</filename> - shell commands
|
||||
that you wish to execute after the completion of a <quote>shorewall
|
||||
start</quote>, "shorewall reload" or <quote>shorewall
|
||||
restart</quote></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/stop </filename>- commands that you
|
||||
wish to execute at the beginning of a <quote>shorewall
|
||||
stop</quote>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/etc/shorewall[6]/stopped</filename> - shell commands
|
||||
that you wish to execute at the completion of a <quote>shorewall
|
||||
stop</quote>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><ulink url="shorewall-ecn.html">/etc/shorewall/ecn</ulink> -
|
||||
disable Explicit Congestion Notification (ECN - RFC 3168) to remote
|
||||
hosts or networks. Superseded by ECN entries in
|
||||
<filename>/etc/shorewall/mangle</filename> in Shorewall 5.0.6.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-accounting.html">/etc/shorewall/accounting</ulink></filename>
|
||||
- define IP traffic accounting rules</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-actions.html">/etc/shorewall[6]/actions</ulink></filename>
|
||||
and <filename>/usr/share/shorewall[6]/action.template</filename> allow
|
||||
user-defined actions.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="???">/etc/shorewall[6]/providers</ulink></filename> - defines
|
||||
alternate routing tables.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-rtrules.html">/etc/shorewall[6]/rtrules</ulink></filename>
|
||||
- Defines routing rules to be used in conjunction with the routing
|
||||
tables defined in
|
||||
<filename>/etc/shorewall/providers</filename>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-tcdevices.html">/etc/shorewall[6]/tcdevices</ulink></filename>,
|
||||
<filename><ulink
|
||||
url="shorewall-tcclasses.html">/etc/shorewall[6]/tcclasses</ulink></filename>,
|
||||
<filename><ulink
|
||||
url="shorewall-tcfilters.html">/etc/shorewall[6]/tcfilters</ulink></filename>
|
||||
- Define complex traffic shaping.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-tcrules.html">/etc/shorewall[6]/tcrules</ulink></filename>
|
||||
- Mark or classify traffic for traffic shaping or multiple providers.
|
||||
Deprecated in Shorewall 4.6.0 in favor of
|
||||
<filename>/etc/shorewall/mangle</filename>. Not supported in Shorewall
|
||||
5.0.0 and later releases.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><ulink
|
||||
url="shorewall-tcinterfaces.html"><filename>/etc/shorewall[6]/tcinterfaces</filename></ulink>
|
||||
and <filename><ulink
|
||||
url="shorewall-tcpri.html">/etc/shorewall[6]/tcpri</ulink></filename>
|
||||
- Define simple traffic shaping.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-secmarks.html">/etc/shorewall[6]/secmarks</ulink></filename>
|
||||
- Added in Shorewall 4.4.13. Attach an SELinux context to selected
|
||||
packets.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-vardir.html">/etc/shorewall[6]/vardir</ulink></filename>
|
||||
- Determines the directory where Shorewall maintains its state.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-arprules.html">/etc/shorewall/arprules</ulink></filename>
|
||||
— Added in Shorewall 4.5.12. Allows specification of arptables
|
||||
rules.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-mangle.html">/etc/shorewall/mangle</ulink></filename>
|
||||
-- Added in Shorewall 4.6.0. Supersedes<filename>
|
||||
/etc/shorewall/tcrules</filename>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename><ulink
|
||||
url="shorewall-snat.html">/etc/shorewall[6]/snat</ulink></filename> -
|
||||
directs the firewall where to use many-to-one (dynamic) Network
|
||||
Address Translation (a.k.a. Masquerading) and Source Network Address
|
||||
Translation (SNAT). Superseded /etc/shorewall[6]/masq in Shorewall
|
||||
5.0.14</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/usr/share/shorewall[6]/actions.std</filename> -
|
||||
Actions defined by Shorewall.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/usr/share/shorewall[6]/action.*</filename> - Details
|
||||
of actions defined by Shorewall.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/usr/share/shorewall[6]/macro.*</filename> - Details
|
||||
of macros defined by Shorewall.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/usr/share/shorewall[6]/modules</filename> — Specifies
|
||||
the kernel modules to be loaded during shorewall start/restart.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><filename>/usr/share/shorewall[6]/helpers</filename> — Added in
|
||||
Shorewall 4.4.7. Specifies the kernel modules to be loaded during
|
||||
shorewall start/restart when LOAD_HELPERS_ONLY=Yes in
|
||||
<filename>shorewall.conf</filename>.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>CONFIG_PATH</title>
|
||||
|
||||
<para>The CONFIG_PATH option in <ulink
|
||||
url="???">shorewall[6].conf(5)</ulink> determines where the compiler
|
||||
searches for configuration files. The default setting is
|
||||
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall which means that the
|
||||
compiler first looks in /etc/shorewall and if it doesn't find the file, it
|
||||
then looks in /usr/share/shorewall.</para>
|
||||
|
||||
<para>You can change this setting to have the compiler look in different
|
||||
places. For example, if you want to put your own versions of standard
|
||||
macros in /etc/shorewall/Macros, then you could set
|
||||
CONFIG_PATH=/etc/shorewall:/etc/shorewall/Macros:/usr/share/shorewall and
|
||||
the compiler will use your versions rather than the standard ones.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Comments</title>
|
||||
|
||||
<para>You may place comments in configuration files by making the first
|
||||
non-whitespace character a pound sign (<quote>#</quote>). You may also
|
||||
place comments at the end of any line, again by delimiting the comment
|
||||
from the rest of the line with a pound sign.</para>
|
||||
|
||||
<example id="comment">
|
||||
<title>Comments in a Configuration File</title>
|
||||
|
||||
<programlisting># This is a comment
|
||||
ACCEPT net $FW tcp www #This is an end-of-line comment</programlisting>
|
||||
</example>
|
||||
|
||||
<important>
|
||||
<para>Except in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf(5)</ulink> and <ulink
|
||||
url="shorewall-params.html">params(5)</ulink>, if a comment ends with a
|
||||
backslash ("\"), the next line will also be treated as a comment. See
|
||||
<link linkend="Continuation">Line Continuation</link> below.</para>
|
||||
</important>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Blank Lines</title>
|
||||
|
||||
<para>Most of the configuration files are organized into space-separated
|
||||
columns. If you don't want to supply a value in a column but want to
|
||||
supply a value in a following column, simply enter '-' to make the column
|
||||
appear empty.</para>
|
||||
|
||||
<para>Example:<programlisting>#INTERFACE BROADCAST OPTIONS
|
||||
br0 - routeback</programlisting></para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title id="Continuation">Line Continuation</title>
|
||||
|
||||
<para>Lines may be continued using the usual backslash (<quote>\</quote>)
|
||||
followed immediately by a new line character (Enter key).</para>
|
||||
|
||||
<programlisting>ACCEPT net $FW tcp \↵
|
||||
smtp,www,pop3,imap #Services running on the firewall</programlisting>
|
||||
|
||||
<important>
|
||||
<para>What follows does NOT apply to <ulink
|
||||
url="manpages/shorewall-params.html">shorewall-params(5)</ulink> and
|
||||
<ulink url="shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
|
||||
</important>
|
||||
|
||||
<para>In certain cases, leading white space is ignored in continuation
|
||||
lines:</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>The continued line ends with a colon (":")</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The continued line ends with a comma (",")</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>Example (<filename>/etc/shorewall/rules</filename>):</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT
|
||||
ACCEPT net:\
|
||||
206.124.146.177,\
|
||||
206.124.146.178,\
|
||||
206.124.146.180\
|
||||
dmz tcp 873</programlisting>
|
||||
|
||||
<para>The leading white space on the first through third continuation
|
||||
lines is ignored so the SOURCE column effectively contains
|
||||
"net:206.124.146.177,206.124.147.178,206.124.146.180". Because the third
|
||||
continuation line does not end with a comma or colon, the leading white
|
||||
space in the last line is not ignored.</para>
|
||||
|
||||
<important>
|
||||
<para>A trailing backslash is not ignored in a comment. So the continued
|
||||
rule above can be commented out with a single '#' as follows:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT
|
||||
<emphasis role="bold">#</emphasis>ACCEPT net:\
|
||||
206.124.146.177,\
|
||||
206.124.146.178,\
|
||||
206.124.146.180\
|
||||
dmz tcp 873</programlisting>
|
||||
</important>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Alternative Specification of Column Values</title>
|
||||
|
||||
<para>Some of the configuration files now have a large number of columns.
|
||||
That makes it awkward to specify a value for one of the right-most columns
|
||||
as you must have the correct number of intervening '-' columns.</para>
|
||||
|
||||
<para>This problem is addressed by allowing column values to be specified
|
||||
as <replaceable>column-name</replaceable>/<replaceable>value</replaceable>
|
||||
pairs.</para>
|
||||
|
||||
<para>There is considerable flexibility in how you specify the
|
||||
pairs:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>At any point, you can enter a left curly bracket ('{') followed
|
||||
by one or more specifications of the following forms:</para>
|
||||
|
||||
<simplelist>
|
||||
<member><replaceable>column-name</replaceable>=<replaceable>value</replaceable></member>
|
||||
|
||||
<member><replaceable>column-name</replaceable>=<replaceable>>value</replaceable></member>
|
||||
|
||||
<member><replaceable>column-name</replaceable>:<replaceable>value</replaceable></member>
|
||||
</simplelist>
|
||||
|
||||
<para>The pairs must be followed by a right curly bracket
|
||||
("}").</para>
|
||||
|
||||
<para>The value may optionally be enclosed in double quotes.</para>
|
||||
|
||||
<para>The pairs must be separated by white space, but you can add a
|
||||
comma adjacent to the <replaceable>values</replaceable> for
|
||||
readability as in:</para>
|
||||
|
||||
<simplelist>
|
||||
<member><emphasis role="bold">{ proto=>udp, port=1024
|
||||
}</emphasis></member>
|
||||
</simplelist>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>You can also separate the pairs from columns by using a
|
||||
semicolon:</para>
|
||||
|
||||
<simplelist>
|
||||
<member><emphasis role="bold">; proto:udp,
|
||||
port:1024</emphasis></member>
|
||||
</simplelist>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>In Shorewall 5.0.3, the sample configuration files and the man pages
|
||||
were updated to use the same column names in both the column headings and
|
||||
in the alternate specification format. The following table shows the
|
||||
column names for each of the table-oriented configuration files.</para>
|
||||
|
||||
<note>
|
||||
<para>Column names are <emphasis
|
||||
role="bold">case-insensitive</emphasis>.</para>
|
||||
</note>
|
||||
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><emphasis role="bold">File</emphasis></entry>
|
||||
|
||||
<entry><emphasis role="bold">Column names</emphasis></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>accounting</entry>
|
||||
|
||||
<entry>action,chain, source, dest, proto, dport, sport, user,
|
||||
mark, ipsec, headers</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>conntrack</entry>
|
||||
|
||||
<entry>action,source,dest,proto,dport,sport,user,switch</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>blacklist</entry>
|
||||
|
||||
<entry>networks,proto,port,options</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>blrules</entry>
|
||||
|
||||
<entry>action,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helper</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>ecn</entry>
|
||||
|
||||
<entry>interface,hosts. Beginning with Shorewall 4.5.4, 'host' is
|
||||
a synonym for 'hosts'.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>hosts</entry>
|
||||
|
||||
<entry>zone,hosts,options. Beginning with Shorewall 4.5.4, 'host'
|
||||
is a synonym for 'hosts'.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>interfaces</entry>
|
||||
|
||||
<entry>zone,interface,broadcast,options</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>maclist</entry>
|
||||
|
||||
<entry>disposition,interface,mac,addresses</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>mangle</entry>
|
||||
|
||||
<entry>action,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>masq</entry>
|
||||
|
||||
<entry>interface,source,address,proto,port,ipsec,mark,user,switch</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>nat</entry>
|
||||
|
||||
<entry>external,interface,internal,allints,local</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>netmap</entry>
|
||||
|
||||
<entry>type,net1,interface,net2,net3,proto,dport,sport</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>notrack</entry>
|
||||
|
||||
<entry>source,dest,proto,dport,sport,user</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>policy</entry>
|
||||
|
||||
<entry>source,dest,policy,loglevel,limit,connlimit</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>providers</entry>
|
||||
|
||||
<entry>table,number,mark,duplicate,interface,gateway,options,copy</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>proxyarp and proxyndp</entry>
|
||||
|
||||
<entry>address,interface,external,haveroute,persistent</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>rtrules</entry>
|
||||
|
||||
<entry>source,dest,provider,priority</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>routes</entry>
|
||||
|
||||
<entry>provider,dest,gateway,device</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>routestopped</entry>
|
||||
|
||||
<entry>interface,hosts,options,proto,dport,sport</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>rules</entry>
|
||||
|
||||
<entry>action,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helper</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>secmarks</entry>
|
||||
|
||||
<entry>secmark,chain,source,dest,proto,dport,sport,user,mark</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcclasses</entry>
|
||||
|
||||
<entry>interface,mark,rate,ceil,prio,options</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcdevices</entry>
|
||||
|
||||
<entry>interface,in_bandwidth,out_bandwidth,options,redirect</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcfilters</entry>
|
||||
|
||||
<entry>class,source,dest,proto,dport,sport,tos,length</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcinterfaces</entry>
|
||||
|
||||
<entry>interface,type,in_bandwidth,out_bandwidth</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcpri</entry>
|
||||
|
||||
<entry>band,proto,port,address,interface,helper</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tcrules</entry>
|
||||
|
||||
<entry>mark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers.
|
||||
Beginning with Shorewall 4.5.3, 'action' is a synonym for
|
||||
'mark'.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tos</entry>
|
||||
|
||||
<entry>source,dest,proto,dport,sport,tos,mark</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>tunnels</entry>
|
||||
|
||||
<entry>type,zone,gateway,gateway_zone. Beginning with Shorewall
|
||||
4.5.3, 'gateways' is a synonym for 'gateway'. Beginning with
|
||||
Shorewall 4.5.4, 'gateway_zones' is a synonym for
|
||||
'gateway_zone'.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry>zones</entry>
|
||||
|
||||
<entry>zone,type,options,in_options,out_options</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
<para>Example (rules file):</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT
|
||||
DNAT net loc:10.0.0.1 tcp 80 ; mark="88"</programlisting>
|
||||
|
||||
<para>Here's the same line in several equivalent formats:</para>
|
||||
|
||||
<programlisting>{ action=>DNAT, source=>net, dest=>loc:10.0.0.1, proto=>tcp, dport=>80, mark=>88 }
|
||||
; action:"DNAT" source:"net" dest:"loc:10.0.0.1" proto:"tcp" dport:"80" mark:"88"
|
||||
DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }</programlisting>
|
||||
|
||||
<para>Beginning with Shorewall 5.0.11, ip[6]table comments can be attached
|
||||
to individual rules using the <option>comment</option> keyword.</para>
|
||||
|
||||
<para>Example from the rules file:</para>
|
||||
|
||||
<programlisting> ACCEPT net $FW { proto=tcp, dport=22, comment="Accept \"SSH\"" }</programlisting>
|
||||
|
||||
<para>As shown in that example, when the comment contains whitespace, it
|
||||
must be enclosed in double quotes and any embedded double quotes must be
|
||||
escaped using a backslash ("\").</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Time Columns</title>
|
||||
|
||||
<para>Several of the files include a TIME column that allows you to specify
|
||||
times when the rule is to be applied. Contents of this column is a list of
|
||||
<replaceable>timeelement</replaceable>s separated by apersands
|
||||
(&).</para>
|
||||
|
||||
<para>Each <replaceable>timeelement</replaceable> is one of the
|
||||
following:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>timestart=<replaceable>hh</replaceable>:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Defines the starting time of day.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>timestop=<replaceable>hh</replaceable>:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Defines the ending time of day.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>contiguous</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shoreawll 5.0.12. When <emphasis
|
||||
role="bold">timestop</emphasis> is smaller than <emphasis
|
||||
role="bold">timestart</emphasis> value, match this as a single time
|
||||
period instead of distinct intervals. See the Examples below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>utc</term>
|
||||
|
||||
<listitem>
|
||||
<para>Times are expressed in Greenwich Mean Time.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>localtz</term>
|
||||
|
||||
<listitem>
|
||||
<para>Deprecated by the Netfilter team in favor of <emphasis
|
||||
role="bold">kerneltz</emphasis>. Times are expressed in Local Civil
|
||||
Time (default).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>kerneltz</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.2. Times are expressed in Local Kernel
|
||||
Time (requires iptables 1.4.12 or later).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>weekdays=ddd[,ddd]...</term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>ddd</replaceable> is one of
|
||||
<option>Mon</option>, <option>Tue</option>, <option>Wed</option>,
|
||||
<option>Thu</option>, <option>Fri</option>, <option>Sat</option> or
|
||||
<option>Sun</option></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>monthdays=dd[,dd],...</term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>dd</replaceable> is an ordinal day of the
|
||||
month</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>datestart=<replaceable>yyyy</replaceable>[-<replaceable>mm</replaceable>[-<replaceable>dd</replaceable>[<option>T</option><replaceable>hh</replaceable>[:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]]]]]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Defines the starting date and time.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>datestop=<replaceable>yyyy</replaceable>[-<replaceable>mm</replaceable>[-<replaceable>dd</replaceable>[<option>T</option><replaceable>hh</replaceable>[:<replaceable>mm</replaceable>[:<replaceable>ss</replaceable>]]]]]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Defines the ending date and time.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>Examples:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>To match on weekends, use:</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
|
||||
<para>weekdays=Sat,Sun</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Or, to match (once) on a national holiday block:</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
|
||||
<para>datestart=2016-12-24&datestop=2016-12-27</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Since the stop time is actually inclusive, you would need the
|
||||
following stop time to not match the first second of the new
|
||||
day:</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
|
||||
<para>datestart=2016-12-24T17:00&datestop=2016-12-27T23:59:59</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>During Lunch Hour</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>The fourth Friday in the month:</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
|
||||
<para>weekdays=Fri&monthdays=22,23,24,25,26,27,28</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Matching across days might not do what is expected. For
|
||||
instance,</term>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
|
||||
<para>weekdays=Mon&timestart=23:00&timestop=01:00</para>
|
||||
|
||||
<para>Will match Monday, for one hour from midnight to 1 a.m., and
|
||||
then again for another hour from 23:00 onwards. If this is unwanted,
|
||||
e.g. if you would like 'match for two hours from Montay 23:00
|
||||
onwards' you need to also specify the <emphasis
|
||||
role="bold">contiguous</emphasis> option in the example
|
||||
above.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Switches</title>
|
||||
|
||||
<para>here are times when you would like to enable or disable one or more
|
||||
rules in the configuration without having to do a <command>shorewall
|
||||
reload</command> or <command>shorewall restart</command>. This may be
|
||||
accomplished using the SWITCH column in <ulink
|
||||
url="manpages/shorewall-rules.html">shorewall-rules</ulink> (5) or <ulink
|
||||
url="manpages6/shorewall6-rules.html">shorewall6-rules</ulink> (5). Using
|
||||
this column requires that your kernel and iptables include
|
||||
<firstterm>Condition Match Support</firstterm> and you must be running
|
||||
Shorewall 4.4.24 or later. See the output of <command>shorewall show
|
||||
capabilities</command> and <command>shorewall version</command> to
|
||||
determine if you can use this feature.</para>
|
||||
|
||||
<para>The SWITCH column contains the name of a
|
||||
<firstterm>switch.</firstterm> Each switch is initially in the <emphasis
|
||||
role="bold">off</emphasis> position. You can turn on the switch named
|
||||
<emphasis>switch1</emphasis> by:</para>
|
||||
|
||||
<simplelist>
|
||||
<member><command>echo 1 >
|
||||
/proc/net/nf_condition/switch1</command></member>
|
||||
</simplelist>
|
||||
|
||||
<para>You can turn it off again by:</para>
|
||||
|
||||
<simplelist>
|
||||
<member><command>echo 0 >
|
||||
/proc/net/nf_condition/switch1</command></member>
|
||||
</simplelist>
|
||||
|
||||
<para>If you simply include the switch name in the SWITCH column, then the
|
||||
rule is enabled only when the switch is <emphasis
|
||||
role="bold">on</emphasis>. If you precede the switch name with ! (e.g.,
|
||||
!switch1), then the rule is enabled only when the switch is <emphasis
|
||||
role="bold">off</emphasis>. Switch settings are retained over
|
||||
<command>shorewall restart</command>.</para>
|
||||
|
||||
<para>Shorewall requires that switch names:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>begin with a letter and be composed of letters, digits,
|
||||
underscore ('_') or hyphen ('-'); and</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>be 30 characters or less in length.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>Multiple rules can be controlled by the same switch.</para>
|
||||
|
||||
<para>Example:</para>
|
||||
|
||||
<blockquote>
|
||||
<para>Forward port 80 to dmz host $BACKUP if switch 'primary_down' is
|
||||
on.</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH
|
||||
DNAT net dmz:$BACKUP tcp 80 - - - - - - - - <emphasis
|
||||
role="bold">primary_down</emphasis> </programlisting>
|
||||
</blockquote>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>FILES</title>
|
||||
|
||||
<para>/etc/shorewall[6]/*</para>
|
||||
</refsect1>
|
||||
</refentry>
|
@@ -90,8 +90,44 @@
|
||||
<para>INPUT chain.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>NP</term>
|
||||
|
||||
<listitem>
|
||||
<para>PREROUTING chain in the nat table.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>NI</term>
|
||||
|
||||
<listitem>
|
||||
<para>INPUT chain in the nat table.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>NO</term>
|
||||
|
||||
<listitem>
|
||||
<para>OUTPUT chain in the nat table.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>NT</term>
|
||||
|
||||
<listitem>
|
||||
<para>POSTROUTING chain in the nat table.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>The nat table designators were added in Shorewall 5.2.1. When
|
||||
a nat table designator is given, only the CONNMARK, MARK, SAVE and
|
||||
RESTORE commands may be used.</para>
|
||||
|
||||
<para>Unless otherwise specified for the particular
|
||||
<replaceable>command</replaceable>, the default chain is PREROUTING
|
||||
when MARK_IN_FORWARD_CHAIN=No in <ulink
|
||||
@@ -821,15 +857,20 @@ Normal-Service => 0x00</programlisting>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><replaceable>interface</replaceable></term>
|
||||
<term>[!]<replaceable>interface</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>interface</replaceable> is the
|
||||
logical name of an interface defined in <ulink
|
||||
logical name of an <replaceable>interface</replaceable>
|
||||
defined in <ulink
|
||||
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
||||
Matches packets entering the firewall from the named
|
||||
interface. May not be used in CLASSIFY rules or in rules using
|
||||
the :T chain qualifier.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces except the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -863,23 +904,31 @@ Normal-Service => 0x00</programlisting>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>interface</replaceable>:<replaceable>address</replaceable>,[...][<replaceable>exclusion</replaceable>]</term>
|
||||
<term>[!]<replaceable>interface</replaceable>:<replaceable>address</replaceable>,[...][<replaceable>exclusion</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>This form combines the preceding two forms and matches
|
||||
when both the incoming interface and source IP address
|
||||
match.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces except the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||
<term>[!]<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This form matches packets arriving through the named
|
||||
<replaceable>interface</replaceable> and whose source IP
|
||||
address does not match any of the addresses in the
|
||||
<replaceable>exclusion</replaceable>.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces except the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
310
Shorewall/manpages/shorewall-names.xml
Normal file
310
Shorewall/manpages/shorewall-names.xml
Normal file
@@ -0,0 +1,310 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||
<refentry>
|
||||
<refmeta>
|
||||
<refentrytitle>shorewall-names</refentrytitle>
|
||||
|
||||
<manvolnum>5</manvolnum>
|
||||
|
||||
<refmiscinfo>Configuration Files</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>names</refname>
|
||||
|
||||
<refpurpose>Shorewall object names</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>When you define an object in Shorewall (<ulink
|
||||
url="manpages/shorewall-zones.html">Zone</ulink>, <link
|
||||
linkend="Logical">Logical Interface</link>, <ulink
|
||||
url="ipsets.html">ipsets</ulink>, <ulink
|
||||
url="Actions.html">Actions</ulink>, etc., you give it a name. Shorewall
|
||||
names start with a letter and consist of letters, digits or underscores
|
||||
("_"). Except for Zone names, Shorewall does not impose a limit on name
|
||||
length.</para>
|
||||
|
||||
<para>When an ipset is referenced, the name must be preceded by a plus
|
||||
sign ("+").</para>
|
||||
|
||||
<para>The last character of an interface may also be a plus sign to
|
||||
indicate a wildcard name.</para>
|
||||
|
||||
<para>Physical interface names match names shown by 'ip link ls'; if the
|
||||
name includes an at sign ("@"), do not include that character or any
|
||||
character that follows. For example, "sit1@NONE" is referred to as simply
|
||||
'sit1".</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Zone and Chain Names</title>
|
||||
|
||||
<para>For a pair of zones, Shorewall creates two Netfilter chains; one for
|
||||
connections in each direction. The names of these chains are formed by
|
||||
separating the names of the two zones by either "2" or "-".</para>
|
||||
|
||||
<para>Example: Traffic from zone A to zone B would go through chain A2B
|
||||
(think "A to B") or "A-B".</para>
|
||||
|
||||
<para>In Shorewall 4.6, the default separator is "-" but you can override
|
||||
that by setting ZONE_SEPARATOR="2" in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5).</para>
|
||||
|
||||
<note>
|
||||
<para>Prior to Shorewall 4.6, the default separator was "2".</para>
|
||||
</note>
|
||||
|
||||
<para>Zones themselves have names that begin with a letter and are
|
||||
composed of letters, numerals, and "_". The maximum length of a name is
|
||||
dependent on the setting of LOGFORMAT in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5). See <ulink
|
||||
url="manpages/shorewall-zones.html">shorewall-zones</ulink> (5) for
|
||||
details.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Using DNS Names</title>
|
||||
|
||||
<caution>
|
||||
<para>I personally recommend strongly against using DNS names in
|
||||
Shorewall configuration files. If you use DNS names and you are called
|
||||
out of bed at 2:00AM because Shorewall won't start as a result of DNS
|
||||
problems then don't say that you were not forewarned.</para>
|
||||
</caution>
|
||||
|
||||
<para>Host addresses in Shorewall configuration files may be specified as
|
||||
either IP addresses or DNS Names.</para>
|
||||
|
||||
<para>DNS names in iptables rules aren't nearly as useful as they first
|
||||
appear. When a DNS name appears in a rule, the iptables utility resolves
|
||||
the name to one or more IP addresses and inserts those addresses into the
|
||||
rule. So changes in the DNS->IP address relationship that occur after
|
||||
the firewall has started have absolutely no effect on the firewall's rule
|
||||
set.</para>
|
||||
|
||||
<para>For some sites, using DNS names is very risky. Here's an
|
||||
example:</para>
|
||||
|
||||
<programlisting>teastep@ursa:~$ dig pop.gmail.com
|
||||
|
||||
; <<>> DiG 9.4.2-P1 <<>> pop.gmail.com
|
||||
;; global options: printcmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1774
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 7, ADDITIONAL: 0
|
||||
|
||||
;; QUESTION SECTION:
|
||||
;pop.gmail.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
pop.gmail.com. <emphasis role="bold">300</emphasis> IN CNAME gmail-pop.l.google.com.
|
||||
gmail-pop.l.google.com. <emphasis role="bold">300</emphasis> IN A 209.85.201.109
|
||||
gmail-pop.l.google.com. <emphasis role="bold">300</emphasis> IN A 209.85.201.111</programlisting>
|
||||
|
||||
<para>Note that the TTL is 300 -- 300 seconds is only 5 minutes. So five
|
||||
minutes later, the answer may change!</para>
|
||||
|
||||
<para>So this rule may work for five minutes then suddently stop
|
||||
working:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT
|
||||
POP(ACCEPT) loc net:pop.gmail.com</programlisting>
|
||||
|
||||
<para>There are two options in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall[6].conf(5)</ulink> that
|
||||
affect the use of DNS names in Shorewall[6] config files:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>DEFER_DNS_RESOLUTION - When set to No, DNS names are resolved at
|
||||
compile time; when set to Yes, DNS Names are resolved at
|
||||
runtime.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>AUTOMAKE - When set to Yes, <command>start</command>,
|
||||
<command>restart</command> and <command>reload</command> only result
|
||||
in compilation if one of the files on the CONFIG_PATH has changed
|
||||
since the the last compilation.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>So by setting AUTOMAKE=Yes, and DEFER_DNS_RESOLUTION=No, compilation
|
||||
will only take place at boot time if a change had been make to the config
|
||||
but no <command>restart</command> or <command>reload</command> had taken
|
||||
place. This is clearly spelled out in the shorewall.conf manpage. So with
|
||||
these settings, so long as a 'reload' or 'restart' takes place after the
|
||||
Shorewall configuration is changes, there should be no DNS-related
|
||||
problems at boot time.</para>
|
||||
|
||||
<important>
|
||||
<para>When DEFER_DNS_RESOLUTION=No and AUTOMAKE=Yes and a DNS change
|
||||
makes it necessary to recompile an existing firewall script, the
|
||||
<option>-c</option> option must be used with the
|
||||
<command>reload</command> or <command>restart</command> command to force
|
||||
recompilation.</para>
|
||||
</important>
|
||||
|
||||
<para>If your firewall rules include DNS names then, even if
|
||||
DEFER_DNS_RESOLUTION=No and AUTOMAKE=Yes:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>If your <filename>/etc/resolv.conf </filename>is wrong then your
|
||||
firewall may not start.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>If your <filename>/etc/nsswitch.conf</filename> is wrong then
|
||||
your firewall may not start.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>If your Name Server(s) is(are) down then your firewall may not
|
||||
start.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>If your startup scripts try to start your firewall before
|
||||
starting your DNS server then your firewall may not start.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Factors totally outside your control (your ISP's router is down
|
||||
for example), can prevent your firewall from starting.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>You must bring up your network interfaces prior to starting your
|
||||
firewall, or the firewall may not start.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>Each DNS name must be fully qualified and include a minimum of two
|
||||
periods (although one may be trailing). This restriction is imposed by
|
||||
Shorewall to insure backward compatibility with existing configuration
|
||||
files.</para>
|
||||
|
||||
<example id="validdns">
|
||||
<title>Valid DNS Names</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>mail.shorewall.net</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>shorewall.net. (note the trailing period).</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</example>
|
||||
|
||||
<example id="invaliddns">
|
||||
<title>Invalid DNS Names</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>mail (not fully qualified)</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>shorewall.net (only one period)</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</example>
|
||||
|
||||
<para>DNS names may not be used as:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The server address in a DNAT rule (/etc/shorewall/rules
|
||||
file)</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>In the ADDRESS column of an entry in /etc/shorewall/masq.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para/>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>In the <filename>/etc/shorewall/nat</filename> file.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>These restrictions are imposed by Netfilter and not by
|
||||
Shorewall.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title id="Logical">Logical Interface Names</title>
|
||||
|
||||
<para>When dealing with a complex configuration, it is often awkward to
|
||||
use physical interface names in the Shorewall configuration.</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>You need to remember which interface is which.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>If you move the configuration to another firewall, the interface
|
||||
names might not be the same.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>Beginning with Shorewall 4.4.4, you can use logical interface names
|
||||
which are mapped to the actual interface using the
|
||||
<option>physical</option> option in <ulink
|
||||
url="manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
|
||||
(5).</para>
|
||||
|
||||
<para>Here is an example:</para>
|
||||
|
||||
<programlisting>#ZONE INTERFACE OPTIONS
|
||||
net <emphasis role="bold">COM_IF </emphasis> dhcp,blacklist,tcpflags,optional,upnp,routefilter=0,nosmurfs,logmartians=0,<emphasis
|
||||
role="bold">physical=eth0</emphasis>
|
||||
net <emphasis role="bold">EXT_IF</emphasis> dhcp,blacklist,tcpflags,optional,routefilter=0,nosmurfs,logmartians=0,proxyarp=1,<emphasis
|
||||
role="bold">physical=eth2</emphasis>
|
||||
loc <emphasis role="bold">INT_IF </emphasis> dhcp,logmartians=1,routefilter=1,tcpflags,nets=172.20.1.0/24,<emphasis
|
||||
role="bold">physical=eth1</emphasis>
|
||||
dmz <emphasis role="bold">VPS_IF </emphasis> logmartians=1,routefilter=0,routeback,<emphasis
|
||||
role="bold">physical=venet0</emphasis>
|
||||
loc <emphasis role="bold">TUN_IF</emphasis> <emphasis role="bold">physical=tun+</emphasis></programlisting>
|
||||
|
||||
<para>In this example, COM_IF is a logical interface name that refers to
|
||||
Ethernet interface <filename class="devicefile">eth0</filename>, EXT_IF is
|
||||
a logical interface name that refers to Ethernet interface <filename
|
||||
class="devicefile">eth2</filename>, and so on.</para>
|
||||
|
||||
<para>Here are a couple of more files from the same configuration:</para>
|
||||
|
||||
<para><ulink url="manpages/shorewall-masq.html">shorewall-masq</ulink>
|
||||
(5):</para>
|
||||
|
||||
<programlisting>#INTERFACE SOURCE ADDRESS
|
||||
|
||||
COMMENT Masquerade Local Network
|
||||
<emphasis role="bold">COM_IF</emphasis> 0.0.0.0/0
|
||||
<emphasis role="bold">EXT_IF </emphasis> !206.124.146.0/24 206.124.146.179:persistent</programlisting>
|
||||
|
||||
<para><ulink
|
||||
url="manpages/shorewall-providers.html">shorewall-providers</ulink>
|
||||
(5)</para>
|
||||
|
||||
<programlisting>#NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY
|
||||
Avvanta 1 0x10000 main <emphasis role="bold">EXT_IF </emphasis> 206.124.146.254 loose,fallback <emphasis
|
||||
role="bold">INT_IF,VPS_IF,TUN_IF</emphasis>
|
||||
Comcast 2 0x20000 main <emphasis role="bold">COM_IF</emphasis> detect balance <emphasis
|
||||
role="bold">INT_IF,VPS_IF,TUN_IF</emphasis></programlisting>
|
||||
|
||||
<para>Note in particular that Shorewall translates TUN_IF to <filename
|
||||
class="devicefile">tun*</filename> in the COPY column.</para>
|
||||
</refsect1>
|
||||
</refentry>
|
@@ -295,21 +295,21 @@
|
||||
<para>where limit is one of:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>[<emphasis
|
||||
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
<member>[<emphasis role="bold">-</emphasis>|[{<emphasis
|
||||
role="bold">s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[[<replaceable>name</replaceable>][(ht-buckets,ht-max)]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
|
||||
|
||||
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
|
||||
<member>[<replaceable>name</replaceable>1:]<emphasis>rate1</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2:]<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
@@ -331,7 +331,14 @@
|
||||
role="bold">shorewall</emphasis> is assumed. Where more than one
|
||||
POLICY or rule specifies the same name, the connections counts for
|
||||
the policies are aggregated and the individual rates apply to the
|
||||
aggregated count.</para>
|
||||
aggregated count. Beginning with Shorewall 5.2.1, the <emphasis
|
||||
role="bold">s</emphasis> or <emphasis role="bold">d</emphasis> may
|
||||
be followed by a slash ("/") and an integer
|
||||
<replaceable>vlsm</replaceable>. When a
|
||||
<replaceable>vlsm</replaceable> is specified, all source or
|
||||
destination addresses encountered will be grouped according to the
|
||||
given prefix length and the so-created subnet will be subject to the
|
||||
rate limit.</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.5, two<replaceable>
|
||||
limit</replaceable>s may be specified, separated by a comma. In this
|
||||
@@ -342,6 +349,17 @@
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
|
||||
|
||||
<para>Beginning with Shorewall 5.2.1, the table name, if any, may be
|
||||
followed by two integers separated by commas and enclosed in
|
||||
parentheses. The first integer
|
||||
(<replaceable>ht-buckets</replaceable>) specifies the number of
|
||||
buckets in the generated hash table. The second integer
|
||||
(<replaceable>ht-max</replaceable>) specifies the maximum number of
|
||||
entries in the hash table.</para>
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">s:client(1024,65536):10/sec</emphasis></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -461,8 +461,7 @@
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.16. This action allows you to
|
||||
construct most of the rule yourself using iptables syntax. The
|
||||
part that you specify must follow two semicolons (';;')
|
||||
and is
|
||||
part that you specify must follow two semicolons (';;') and is
|
||||
completely free-form. If the target of the rule (the part
|
||||
following 'j') is something that Shorewall supports in the
|
||||
ACTION column, then you may enclose it in parentheses (e.g.,
|
||||
@@ -1046,7 +1045,7 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
|
||||
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>When this form is used,
|
||||
@@ -1059,6 +1058,11 @@
|
||||
Only packets from hosts in the <replaceable>zone</replaceable>
|
||||
that arrive through the named interface will match the
|
||||
rule.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces associated with the zone except
|
||||
the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1397,7 +1401,7 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
|
||||
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>When this form is used,
|
||||
@@ -1410,6 +1414,11 @@
|
||||
Only packets to hosts in the <replaceable>zone</replaceable>
|
||||
that are sent through the named interface will match the
|
||||
rule.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces associated with the zone except
|
||||
the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1463,12 +1472,17 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...]</term>
|
||||
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...]</term>
|
||||
|
||||
<listitem>
|
||||
<para>This form combines the preceding two and requires that
|
||||
both the outgoing interface and destinationaddress
|
||||
match.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces associated with the zone except
|
||||
the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1483,7 +1497,7 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||
<term><replaceable>zone</replaceable>:[!]<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This form matches packets to the named
|
||||
@@ -1491,6 +1505,11 @@
|
||||
<replaceable>interface</replaceable> where the destination
|
||||
address does not match any entry in the
|
||||
<replaceable>exclusion</replaceable>.</para>
|
||||
|
||||
<para>Beginning with Shorweall 5.2.1, the
|
||||
<replaceable>interface</replaceable> may be preceded with '!'
|
||||
which matches all interfaces associated with the zone except
|
||||
the one specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1881,19 +1900,21 @@
|
||||
<simplelist>
|
||||
<member>[<emphasis role="bold">-</emphasis>|[{<emphasis
|
||||
role="bold">s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[<replaceable>name</replaceable>[(<replaceable>ht-buckets</replaceable>,<replaceable>ht-max</replaceable>)]:]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
|
||||
|
||||
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
|
||||
<member>[<emphasis
|
||||
role="bold">s</emphasis>[/<replaceable>vlsm1</replaceable>]:][<replaceable>name</replaceable>1[(<replaceable>ht-buckets1</replaceable>,<replaceable>ht-max1</replaceable>)]:]<emphasis>rate1</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<emphasis
|
||||
role="bold">d</emphasis>[/<replaceable>vlsm2</replaceable>:][<replaceable>name</replaceable>2[(<replaceable>ht-buckets2</replaceable>,<replaceable>ht-max2</replaceable>)]:]<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
@@ -1921,7 +1942,16 @@
|
||||
role="bold">shorewallN</emphasis> (where N is a unique integer) is
|
||||
assumed. Where more than one rule or POLICY specifies the same name,
|
||||
the connections counts for the rules are aggregated and the
|
||||
individual rates apply to the aggregated count.</para>
|
||||
individual rates apply to the aggregated count. Beginning with
|
||||
Shorewall 5.2.1, the <emphasis role="bold">s</emphasis> or <emphasis
|
||||
role="bold">d</emphasis> may be followed by a slash ("/") and an
|
||||
integer <replaceable>vlsm</replaceable>. When a
|
||||
<replaceable>vlsm</replaceable> is specified, all source or
|
||||
destination addresses encountered will be grouped according to the
|
||||
given prefix length and the so-created subnet will be subject to the
|
||||
rate limit.</para>
|
||||
|
||||
<para>Example: <emphasis role="bold">s/24::10/sec</emphasis></para>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.5, two<replaceable>
|
||||
limit</replaceable>s may be specified, separated by a comma. In this
|
||||
@@ -1938,6 +1968,17 @@
|
||||
name for the hash table that tracks the per-destination
|
||||
limit.</para>
|
||||
|
||||
<para>Beginning with Shorewall 5.2.1, the table name, if any, may be
|
||||
followed by two integers separated by commas and enclosed in
|
||||
parentheses. The first integer
|
||||
(<replaceable>ht-buckets</replaceable>) specifies the number of
|
||||
buckets in the generated hash table. The second integer
|
||||
(<replaceable>ht-max</replaceable>) specifies the maximum number of
|
||||
entries in the hash table.</para>
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">s:netfw(1024,65536):10/sec</emphasis></para>
|
||||
|
||||
<para>This column was formerly labelled RATE LIMIT.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@@ -500,7 +500,7 @@
|
||||
each listed directory is to be searched. AUTOMAKE=1 only searches
|
||||
each directory itself and is equivalent to AUTOMAKE=Yes. AUTOMAKE=2
|
||||
will search each directory and its immediate sub-directories;
|
||||
AUTOMAKE=3 will search each diretory, each of its immediate
|
||||
AUTOMAKE=3 will search each directory, each of its immediate
|
||||
sub-directories, and each of their immediate sub-directories,
|
||||
etc.</para>
|
||||
</listitem>
|
||||
|
@@ -151,7 +151,7 @@ fi
|
||||
|
||||
remove_file ${SBINDIR}/$PRODUCT
|
||||
|
||||
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
|
||||
if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
|
||||
FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
|
||||
elif [ -n "$INITFILE" ]; then
|
||||
FIREWALL=${INITDIR}/${INITFILE}
|
||||
|
117
Shorewall6-lite/init.alt.sh
Executable file
117
Shorewall6-lite/init.alt.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall6-Lite init script
|
||||
#
|
||||
# chkconfig: - 28 90
|
||||
# description: Packet filtering firewall
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall6
|
||||
# Required-Start: $local_fs $remote_fs $syslog $network
|
||||
# Should-Start: $time $named
|
||||
# Required-Stop:
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Packet filtering firewall
|
||||
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
|
||||
# Netfilter (iptables) based firewall
|
||||
### END INIT INFO
|
||||
|
||||
# Do not load RH compatibility interface.
|
||||
WITHOUT_RC_COMPAT=1
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
#
|
||||
# The installer may alter this
|
||||
#
|
||||
. /usr/share/shorewall/shorewallrc
|
||||
|
||||
NAME="Shorewall6-Lite firewall"
|
||||
PROG="shorewall"
|
||||
SHOREWALL="$SBINDIR/$PROG -6l"
|
||||
LOGGER="logger -i -t $PROG"
|
||||
|
||||
# Get startup options (override default)
|
||||
OPTIONS=
|
||||
|
||||
SourceIfNotEmpty $SYSCONFDIR/${PROG}6-lite
|
||||
|
||||
LOCKFILE="/var/lock/subsys/${PROG}6-lite"
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
reload() {
|
||||
action $"Reloadinging $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
clear() {
|
||||
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
condrestart)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condreload)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condstop)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
stop
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
"$SHOREWALL" status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2015 - Matt Darfeuille - (matdarf@gmail.com)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
RCDLINKS="2,S41 3,S41 6,K41"
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Shorewall6 version 4.0 - Sample Rules File for three-interface configuration.
|
||||
# Shorewall6 version 5.2 - Sample Rules File for three-interface configuration.
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Shorewall6 version 4 - Sample Zones File for three-interface configuration.
|
||||
# Shorewall6 version 5.2 - Sample Zones File for three-interface configuration.
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Shorewall6 version 4.0 - Sample Rules File for two-interface configuration.
|
||||
# Shorewall6 version 5.2 - Sample Rules File for two-interface configuration.
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Shorewall6 version 4.0 - Sample Zones File for two-interface configuration.
|
||||
# Shorewall6 version 5.2 - Sample Zones File for two-interface configuration.
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
|
117
Shorewall6/init.alt.sh
Executable file
117
Shorewall6/init.alt.sh
Executable file
@@ -0,0 +1,117 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall6 init script
|
||||
#
|
||||
# chkconfig: - 28 90
|
||||
# description: Packet filtering firewall
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall6
|
||||
# Required-Start: $local_fs $remote_fs $syslog $network
|
||||
# Should-Start: $time $named
|
||||
# Required-Stop:
|
||||
# Default-Start: 3 4 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: Packet filtering firewall
|
||||
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
|
||||
# Netfilter (iptables) based firewall
|
||||
### END INIT INFO
|
||||
|
||||
# Do not load RH compatibility interface.
|
||||
WITHOUT_RC_COMPAT=1
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
#
|
||||
# The installer may alter this
|
||||
#
|
||||
. /usr/share/shorewall/shorewallrc
|
||||
|
||||
NAME="Shorewall6 firewall"
|
||||
PROG="shorewall"
|
||||
SHOREWALL="$SBINDIR/$PROG -6"
|
||||
LOGGER="logger -i -t $PROG"
|
||||
|
||||
# Get startup options (override default)
|
||||
OPTIONS=
|
||||
|
||||
SourceIfNotEmpty $SYSCONFDIR/${PROG}6
|
||||
|
||||
LOCKFILE="/var/lock/subsys/${PROG}6"
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
action $"Applying $NAME rules:" "$SHOREWALL" "$OPTIONS" start "$STARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
action $"Stoping $NAME :" "$SHOREWALL" "$OPTIONS" stop "$STOPOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
action $"Restarting $NAME rules: " "$SHOREWALL" "$OPTIONS" restart "$RESTARTOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
reload() {
|
||||
action $"Reloadinging $NAME rules: " "$SHOREWALL" "$OPTIONS" reload "$RELOADOPTIONS" 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
clear() {
|
||||
action $"Clearing $NAME rules: " "$SHOREWALL" "$OPTIONS" clear 2>&1 | "$LOGGER"
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
clear)
|
||||
clear
|
||||
;;
|
||||
condrestart)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condreload)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
restart
|
||||
fi
|
||||
;;
|
||||
condstop)
|
||||
if [ -e "$LOCKFILE" ]; then
|
||||
stop
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
"$SHOREWALL" status
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: ${0##*/} {start|stop|restart|reload|clear|condrestart|condstop|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
RCDLINKS="2,S41 3,S41 6,K41"
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall6) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall6) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall6) Packet Filtering Firewall - V4.5
|
||||
# The Shoreline Firewall (Shorewall6) Packet Filtering Firewall - V5.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -85,7 +85,7 @@
|
||||
server. It then sends a packet addressed to itself and from the server.
|
||||
Such packets are sent back out the same interface that received them
|
||||
(<firstterm>hairpin</firstterm>). In cases where the
|
||||
<option>routerfilter</option> option can't be used, Shorewall 4.4.20 and
|
||||
<option>routefilter</option> option can't be used, Shorewall 4.4.20 and
|
||||
later will set up hairpinning traps (see the SFILTER_DISPOSITION and
|
||||
SFILTER_LOG_LEVEL options in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).</para>
|
||||
|
18
docs/FAQ.xml
18
docs/FAQ.xml
@@ -244,9 +244,25 @@ DNAT net:<emphasis>address</emphasis> loc:<emphasis>local-IP-address</empha
|
||||
work</title>
|
||||
|
||||
<para><emphasis role="bold">Answer:</emphasis> That is usually the
|
||||
result of one of four things:</para>
|
||||
result of one of five things:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>You are trying to redirect a UDP port and there is already a
|
||||
conntrack table entry for the flow, created via an ACCEPT
|
||||
rule.</para>
|
||||
|
||||
<para>Example:</para>
|
||||
|
||||
<programlisting> DNAT loc:192.168.0.2 dmz:192.168.1.3 udp 53</programlisting>
|
||||
|
||||
<para>Assuming that you have installed the
|
||||
<emphasis>conntrack</emphasis> package, you can delete all such
|
||||
conntrack table entries using:</para>
|
||||
|
||||
<programlisting> conntrack -D -s 192.168.0.2 -p udp --dport 53</programlisting>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>You are trying to test from inside your firewall (no, that
|
||||
won't work -- see <xref linkend="faq2"/>).</para>
|
||||
|
@@ -323,7 +323,7 @@ vpn eth0:192.168.1.0/24,206.162.148.9 <emphasis role="bold">ips
|
||||
|
||||
<blockquote>
|
||||
<programlisting>#ZONE HOSTS OPTIONS
|
||||
vpn eth0:0.0.0.0/o <emphasis role="bold">ipsec</emphasis></programlisting>
|
||||
vpn eth0:0.0.0.0/0 <emphasis role="bold">ipsec</emphasis></programlisting>
|
||||
</blockquote>
|
||||
|
||||
<para>Assuming that you want to give each local network free access to the
|
||||
|
@@ -18,21 +18,7 @@
|
||||
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
|
||||
|
||||
<copyright>
|
||||
<year>2005</year>
|
||||
|
||||
<year>2006</year>
|
||||
|
||||
<year>2007</year>
|
||||
|
||||
<year>2008</year>
|
||||
|
||||
<year>2009</year>
|
||||
|
||||
<year>2010</year>
|
||||
|
||||
<year>2011</year>
|
||||
|
||||
<year>2012 2013</year>
|
||||
<year>2005-2018</year>
|
||||
|
||||
<holder>Thomas M. Eastep,</holder>
|
||||
|
||||
@@ -67,7 +53,7 @@
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The LARTC HOWTO: <ulink
|
||||
url="http://www.lartc.org">http://www.lartc.org</ulink></para>
|
||||
url="http://comparitech.net/lartc">http://comparitech.net/lartc</ulink></para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
@@ -2568,6 +2554,15 @@ exit 0
|
||||
of<filename> /etc/shorewall/providers</filename>; <emphasis
|
||||
role="bold">detect</emphasis> is not permitted.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The <emphasis role="bold">optional</emphasis>
|
||||
provider/interface option doesn't work (and is disallowed beginning
|
||||
with Shorewall 5.2.1). If you need failover, you will need to
|
||||
front-end your firewall with a configurable switch and create a
|
||||
separate VLAN for each of your providers, thus providing a separate
|
||||
network interface for each provider.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>Taken together, b. and h. effectively preclude using this
|
||||
|
@@ -65,9 +65,10 @@
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>HTTP - better to use <ulink
|
||||
url="Shorewall_Squid_Usage.html">Squid</ulink> and <ulink
|
||||
url="http://dansguardian.org/">Dansguardian</ulink> for
|
||||
that.</para>
|
||||
url="Shorewall_Squid_Usage.html">Squid</ulink>, <ulink
|
||||
url="http://www.e2guardian.org/">E2guardian</ulink>, or <ulink
|
||||
url="http://comparitech.net/parental-control">Parental
|
||||
Control</ulink> for that.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
@@ -817,11 +817,11 @@ DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }</programlisting
|
||||
<programlisting>#ACTION SOURCE DEST
|
||||
|
||||
?COMMENT Drop DNS Amplification Attack Packets
|
||||
INLINE(DROP):info net $FW ; udp 53 ; -m u32 --u32 "0>>22&0x3C\@8&0xffff=0x0100 && 0>>22&0x3C\@12&0xffff0000=0x00010000"
|
||||
INLINE(DROP):info net $FW udp 53 ;; -m u32 --u32 "0>>22&0x3C\@8&0xffff=0x0100 && 0>>22&0x3C\@12&0xffff0000=0x00010000"
|
||||
?COMMENT
|
||||
|
||||
?COMMENT Rule generated by the IfEvent action
|
||||
INLINE net $FW ; -m recent --rcheck 10 --hitcount 5 --name SSH -s 1.2.3.4 -j MARK --or-mark 0x4000
|
||||
INLINE net $FW ;; -m recent --rcheck 10 --hitcount 5 --name SSH -s 1.2.3.4 -j MARK --or-mark 0x4000
|
||||
?COMMENT</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -1302,7 +1302,7 @@ SHELL cat /etc/shorewall/rules.d/*.rules 2> /dev/null || true</programlisting
|
||||
|
||||
<member><filename>macro</filename>.* files</member>
|
||||
|
||||
<member><filename>masq</filename></member>
|
||||
<member><filename>snat</filename></member>
|
||||
|
||||
<member><filename>nat</filename></member>
|
||||
|
||||
@@ -3300,7 +3300,7 @@ Comcast 2 0x20000 main <emphasis role="bold">COM_IF</emphasis>
|
||||
<para>If <emphasis role="bold">detect</emphasis> is specified in the
|
||||
ADDRESS column of an entry in <ulink
|
||||
url="manpages/shorewall-masq.html">shorewall-masq</ulink> (5) then the
|
||||
firewall still startS if the optional interface in the INTERFACE
|
||||
firewall still starts if the optional interface in the INTERFACE
|
||||
column does not have an IP address.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
Reference in New Issue
Block a user