forked from extern/shorewall_code
Compare commits
163 Commits
5.0.14.1
...
5.1.1-base
Author | SHA1 | Date | |
---|---|---|---|
|
e45b96ca20 | ||
|
eac2639684 | ||
|
70a395892f | ||
|
d2d11df4f6 | ||
|
b985654600 | ||
|
62ff6d3fa5 | ||
|
2bbb5c8c1e | ||
|
33b4ee4d31 | ||
|
889ca756a1 | ||
|
d111e4f186 | ||
|
634c8debda | ||
|
71dd5d016b | ||
|
6b408869d2 | ||
|
edf08bf408 | ||
|
4a01e910ff | ||
|
2a010f827b | ||
|
9c3a82f628 | ||
|
e6933f4c8d | ||
|
cc3b8793e0 | ||
|
ac5fd195ec | ||
|
45b9ddf188 | ||
|
2d16fac9ed | ||
|
f23970b4f7 | ||
|
04112647d3 | ||
|
2ca1ae734a | ||
|
b36b07b567 | ||
|
64c249a174 | ||
|
0019ca53e5 | ||
|
0d2a5089a9 | ||
|
50d09e76cb | ||
|
73772efb85 | ||
|
568f461763 | ||
|
f12b78d518 | ||
|
a15b2918a4 | ||
|
cb150f9c09 | ||
|
19ce2093d8 | ||
|
b8c322a05f | ||
|
f68d3fd9fa | ||
|
386b137e9b | ||
|
ce68f84d9d | ||
|
5aed31d37a | ||
|
0b3d1b1d36 | ||
|
6be89b4e2d | ||
|
75a9e45caf | ||
|
2f9ef4dda7 | ||
|
26f181ef2a | ||
|
b0ea9db0bd | ||
|
7a3865bcfc | ||
|
5174fe0161 | ||
|
65bf33bcf3 | ||
|
638c7c5bca | ||
|
c4bbb46e3f | ||
|
7b96d41065 | ||
|
1b97783c23 | ||
|
c9f45277b8 | ||
|
7ce0cc3e2e | ||
|
541291b729 | ||
|
9dcac6012b | ||
|
1a95db73e9 | ||
|
dcade04fba | ||
|
7717de872d | ||
|
be5a8c440f | ||
|
7c63428e82 | ||
|
4c03aaa0fc | ||
|
8dce87e129 | ||
|
cabef548a6 | ||
|
4af278338f | ||
|
fa6167797d | ||
|
44e9c7780f | ||
|
3caedbbbef | ||
|
b2f07b0e44 | ||
|
a86ea0c00a | ||
|
20c764ca5c | ||
|
b33d853703 | ||
|
30331fecda | ||
|
6ff1833ae0 | ||
|
eaf58d18aa | ||
|
a9583aaf3a | ||
|
c2c2dc0b22 | ||
|
e3951cb5a3 | ||
|
eb3067c006 | ||
|
e4ec1c81ec | ||
|
d2890df8b9 | ||
|
73f74ad576 | ||
|
7be8c579a7 | ||
|
28359c40f3 | ||
|
2ec17ce608 | ||
|
1cb32e3127 | ||
|
bac6848362 | ||
|
fa8e92cbd3 | ||
|
56d4d01984 | ||
|
f502e5b2e3 | ||
|
154395c20f | ||
|
089ff4eb33 | ||
|
7ce5c31c68 | ||
|
273b02c6da | ||
|
095c9212f4 | ||
|
612eee64d1 | ||
|
e98abac706 | ||
|
5ea78b8078 | ||
|
08c6b80e1e | ||
|
cb7ab3908a | ||
|
b4d42507b2 | ||
|
094ccbf978 | ||
|
036a6e5a83 | ||
|
b756c63b1e | ||
|
eea9882953 | ||
|
cc937ffaba | ||
|
192486eb0a | ||
|
6a43dd1564 | ||
|
5ea3334a66 | ||
|
e4804e1900 | ||
|
6c8dae45c4 | ||
|
a2e040998b | ||
|
53adfbe863 | ||
|
4a0a906510 | ||
|
7ceb0228e9 | ||
|
f537e3e15c | ||
|
4949569383 | ||
|
4a410c7b4c | ||
|
5ae062317f | ||
|
a1981823f4 | ||
|
0e40c5a4a1 | ||
|
77e83f0afd | ||
|
a45fe692cc | ||
|
799b17210c | ||
|
01306e1230 | ||
|
963dea54c5 | ||
|
fbbcc812a1 | ||
|
87870ac46e | ||
|
d895a5d67c | ||
|
414c5c7b0c | ||
|
c561f8eb03 | ||
|
ff81980552 | ||
|
38c9165c39 | ||
|
bd2df4836d | ||
|
875c352473 | ||
|
8a6dcc469b | ||
|
dae060bbb4 | ||
|
ccab75e69a | ||
|
de553e7b18 | ||
|
36517cdb1e | ||
|
bb5c3a50f5 | ||
|
8b99fe20b5 | ||
|
137b051e52 | ||
|
9eb390403b | ||
|
ab9f340c55 | ||
|
88284ed568 | ||
|
481afef2c3 | ||
|
6b38b3a515 | ||
|
80951d23c2 | ||
|
1e7f63834c | ||
|
74b94f71f8 | ||
|
ef4ab62dd3 | ||
|
42c1c2a205 | ||
|
6095d05af9 | ||
|
d989241712 | ||
|
652bc75448 | ||
|
d105da3964 | ||
|
c5b393a074 | ||
|
1b82dedb77 | ||
|
6398756647 | ||
|
daa2440d9a |
@@ -365,6 +365,12 @@ fi
|
|||||||
# Note: ${VARDIR} is created at run-time since it has always been
|
# Note: ${VARDIR} is created at run-time since it has always been
|
||||||
# a relocatable directory on a per-product basis
|
# a relocatable directory on a per-product basis
|
||||||
#
|
#
|
||||||
|
# Install the CLI
|
||||||
|
#
|
||||||
|
install_file shorewall ${DESTDIR}${SBINDIR}/shorewall 0755
|
||||||
|
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/shorewall
|
||||||
|
echo "Shorewall CLI program installed in ${DESTDIR}${SBINDIR}/shorewall"
|
||||||
|
#
|
||||||
# Install wait4ifup
|
# Install wait4ifup
|
||||||
#
|
#
|
||||||
install_file wait4ifup ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup 0755
|
install_file wait4ifup ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup 0755
|
||||||
@@ -380,6 +386,31 @@ for f in lib.* ; do
|
|||||||
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f"
|
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $SHAREDIR != /usr/share ]; then
|
||||||
|
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
|
||||||
|
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.core
|
||||||
|
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.cli
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install the Man Pages
|
||||||
|
#
|
||||||
|
if [ -n "$MANDIR" ]; then
|
||||||
|
cd manpages
|
||||||
|
|
||||||
|
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man8/
|
||||||
|
|
||||||
|
for f in *.8; do
|
||||||
|
gzip -9c $f > $f.gz
|
||||||
|
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
|
||||||
|
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "Man Pages Installed"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Symbolically link 'functions' to lib.base
|
# Symbolically link 'functions' to lib.base
|
||||||
#
|
#
|
||||||
|
@@ -20,412 +20,22 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# This library contains the code common to all Shorewall components except the
|
# This library is a compatibility wrapper around lib.core.
|
||||||
# generated scripts.
|
|
||||||
#
|
#
|
||||||
|
|
||||||
SHOREWALL_LIBVERSION=40509
|
if [ -z "$PRODUCT" ]; then
|
||||||
|
|
||||||
[ -n "${g_program:=shorewall}" ]
|
|
||||||
|
|
||||||
if [ -z "$g_readrc" ]; then
|
|
||||||
#
|
#
|
||||||
# This is modified by the installer when ${SHAREDIR} != /usr/share
|
# This is modified by the installer when ${SHAREDIR} != /usr/share
|
||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
g_sharedir="$SHAREDIR"/$g_program
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
g_confdir="$CONFDIR"/$g_program
|
|
||||||
g_readrc=1
|
if [ -z "$SHOREWALL_LIBVERSION" ]; then
|
||||||
|
. ${g_basedir}/lib.core
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_default_product
|
||||||
|
|
||||||
|
setup_product_environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
g_basedir=${SHAREDIR}/shorewall
|
|
||||||
|
|
||||||
case $g_program in
|
|
||||||
shorewall)
|
|
||||||
g_product="Shorewall"
|
|
||||||
g_family=4
|
|
||||||
g_tool=iptables
|
|
||||||
g_lite=
|
|
||||||
;;
|
|
||||||
shorewall6)
|
|
||||||
g_product="Shorewall6"
|
|
||||||
g_family=6
|
|
||||||
g_tool=ip6tables
|
|
||||||
g_lite=
|
|
||||||
;;
|
|
||||||
shorewall-lite)
|
|
||||||
g_product="Shorewall Lite"
|
|
||||||
g_family=4
|
|
||||||
g_tool=iptables
|
|
||||||
g_lite=Yes
|
|
||||||
;;
|
|
||||||
shorewall6-lite)
|
|
||||||
g_product="Shorewall6 Lite"
|
|
||||||
g_family=6
|
|
||||||
g_tool=ip6tables
|
|
||||||
g_lite=Yes
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -z "${VARLIB}" ]; then
|
|
||||||
VARLIB=${VARDIR}
|
|
||||||
VARDIR=${VARLIB}/$g_program
|
|
||||||
elif [ -z "${VARDIR}" ]; then
|
|
||||||
VARDIR="${VARLIB}/${PRODUCT}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Fatal Error
|
|
||||||
#
|
|
||||||
fatal_error() # $@ = Message
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Not configured Error
|
|
||||||
#
|
|
||||||
not_configured_error() # $@ = Message
|
|
||||||
{
|
|
||||||
echo " ERROR: $@" >&2
|
|
||||||
exit 6
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Conditionally produce message
|
|
||||||
#
|
|
||||||
progress_message() # $* = Message
|
|
||||||
{
|
|
||||||
local timestamp
|
|
||||||
timestamp=
|
|
||||||
|
|
||||||
if [ $VERBOSITY -gt 1 ]; then
|
|
||||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
|
||||||
echo "${timestamp}$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
progress_message2() # $* = Message
|
|
||||||
{
|
|
||||||
local timestamp
|
|
||||||
timestamp=
|
|
||||||
|
|
||||||
if [ $VERBOSITY -gt 0 ]; then
|
|
||||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
|
||||||
echo "${timestamp}$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
progress_message3() # $* = Message
|
|
||||||
{
|
|
||||||
local timestamp
|
|
||||||
timestamp=
|
|
||||||
|
|
||||||
if [ $VERBOSITY -ge 0 ]; then
|
|
||||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
|
||||||
echo "${timestamp}$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Undo the effect of 'separate_list()'
|
|
||||||
#
|
|
||||||
combine_list()
|
|
||||||
{
|
|
||||||
local f
|
|
||||||
local o
|
|
||||||
o=
|
|
||||||
|
|
||||||
for f in $* ; do
|
|
||||||
o="${o:+$o,}$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo $o
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Validate an IP address
|
|
||||||
#
|
|
||||||
valid_address() {
|
|
||||||
local x
|
|
||||||
local y
|
|
||||||
local ifs
|
|
||||||
ifs=$IFS
|
|
||||||
|
|
||||||
IFS=.
|
|
||||||
|
|
||||||
for x in $1; do
|
|
||||||
case $x in
|
|
||||||
[0-9]|[0-9][0-9]|[1-2][0-9][0-9])
|
|
||||||
[ $x -lt 256 ] || { IFS=$ifs; return 2; }
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
IFS=$ifs
|
|
||||||
return 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
IFS=$ifs
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Miserable Hack to work around broken BusyBox ash in OpenWRT
|
|
||||||
#
|
|
||||||
addr_comp() {
|
|
||||||
test $(bc <<EOF
|
|
||||||
$1 > $2
|
|
||||||
EOF
|
|
||||||
) -eq 1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Enumerate the members of an IP range -- When using a shell supporting only
|
|
||||||
# 32-bit signed arithmetic, the range cannot span 128.0.0.0.
|
|
||||||
#
|
|
||||||
# Comes in two flavors:
|
|
||||||
#
|
|
||||||
# ip_range() - produces a mimimal list of network/host addresses that spans
|
|
||||||
# the range.
|
|
||||||
#
|
|
||||||
# ip_range_explicit() - explicitly enumerates the range.
|
|
||||||
#
|
|
||||||
ip_range() {
|
|
||||||
local first
|
|
||||||
local last
|
|
||||||
local l
|
|
||||||
local x
|
|
||||||
local y
|
|
||||||
local z
|
|
||||||
local vlsm
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
!*)
|
|
||||||
#
|
|
||||||
# Let iptables complain if it's a range
|
|
||||||
#
|
|
||||||
echo $1
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
[0-9]*.*.*.*-*.*.*.*)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $1
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
first=$(decodeaddr ${1%-*})
|
|
||||||
last=$(decodeaddr ${1#*-})
|
|
||||||
|
|
||||||
if addr_comp $first $last; then
|
|
||||||
fatal_error "Invalid IP address range: $1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
l=$(( $last + 1 ))
|
|
||||||
|
|
||||||
while addr_comp $l $first; do
|
|
||||||
vlsm=
|
|
||||||
x=31
|
|
||||||
y=2
|
|
||||||
z=1
|
|
||||||
|
|
||||||
while [ $(( $first % $y )) -eq 0 ] && ! addr_comp $(( $first + $y )) $l; do
|
|
||||||
vlsm=/$x
|
|
||||||
x=$(( $x - 1 ))
|
|
||||||
z=$y
|
|
||||||
y=$(( $y * 2 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo $(encodeaddr $first)$vlsm
|
|
||||||
first=$(($first + $z))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_range_explicit() {
|
|
||||||
local first
|
|
||||||
local last
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
[0-9]*.*.*.*-*.*.*.*)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $1
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
first=$(decodeaddr ${1%-*})
|
|
||||||
last=$(decodeaddr ${1#*-})
|
|
||||||
|
|
||||||
if addr_comp $first $last; then
|
|
||||||
fatal_error "Invalid IP address range: $1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
while ! addr_comp $first $last; do
|
|
||||||
echo $(encodeaddr $first)
|
|
||||||
first=$(($first + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
|
|
||||||
|
|
||||||
#
|
|
||||||
# Netmask to VLSM
|
|
||||||
#
|
|
||||||
ip_vlsm() {
|
|
||||||
local mask
|
|
||||||
mask=$(decodeaddr $1)
|
|
||||||
local vlsm
|
|
||||||
vlsm=0
|
|
||||||
local x
|
|
||||||
x=$(( 128 << 24 )) # 0x80000000
|
|
||||||
|
|
||||||
while [ $(( $x & $mask )) -ne 0 ]; do
|
|
||||||
[ $mask -eq $x ] && mask=0 || mask=$(( $mask $LEFTSHIFT 1 )) # Not all shells shift 0x80000000 left properly.
|
|
||||||
vlsm=$(($vlsm + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $(( $mask & 2147483647 )) -ne 0 ]; then # 2147483647 = 0x7fffffff
|
|
||||||
echo "Invalid net mask: $1" >&2
|
|
||||||
else
|
|
||||||
echo $vlsm
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set default config path
|
|
||||||
#
|
|
||||||
ensure_config_path() {
|
|
||||||
local F
|
|
||||||
F=${g_sharedir}/configpath
|
|
||||||
if [ -z "$CONFIG_PATH" ]; then
|
|
||||||
[ -f $F ] || { echo " ERROR: $F does not exist"; exit 2; }
|
|
||||||
. $F
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$g_shorewalldir" ]; then
|
|
||||||
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get fully-qualified name of file
|
|
||||||
#
|
|
||||||
resolve_file() # $1 = file name
|
|
||||||
{
|
|
||||||
local pwd
|
|
||||||
pwd=$PWD
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
/*)
|
|
||||||
echo $1
|
|
||||||
;;
|
|
||||||
.)
|
|
||||||
echo $pwd
|
|
||||||
;;
|
|
||||||
./*)
|
|
||||||
echo ${pwd}${1#.}
|
|
||||||
;;
|
|
||||||
..)
|
|
||||||
cd ..
|
|
||||||
echo $PWD
|
|
||||||
cd $pwd
|
|
||||||
;;
|
|
||||||
../*)
|
|
||||||
cd ..
|
|
||||||
resolve_file ${1#../}
|
|
||||||
cd $pwd
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $pwd/$1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Determine how to do "echo -e"
|
|
||||||
#
|
|
||||||
|
|
||||||
find_echo() {
|
|
||||||
local result
|
|
||||||
|
|
||||||
result=$(echo "a\tb")
|
|
||||||
[ ${#result} -eq 3 ] && { echo echo; return; }
|
|
||||||
|
|
||||||
result=$(echo -e "a\tb")
|
|
||||||
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
|
|
||||||
|
|
||||||
result=$(which echo)
|
|
||||||
[ -n "$result" ] && { echo "$result -e"; return; }
|
|
||||||
|
|
||||||
echo echo
|
|
||||||
}
|
|
||||||
|
|
||||||
# Determine which version of mktemp is present (if any) and set MKTEMP accortingly:
|
|
||||||
#
|
|
||||||
# None - No mktemp
|
|
||||||
# BSD - BSD mktemp (Mandrake)
|
|
||||||
# STD - mktemp.org mktemp
|
|
||||||
#
|
|
||||||
find_mktemp() {
|
|
||||||
local mktemp
|
|
||||||
mktemp=`mywhich mktemp 2> /dev/null`
|
|
||||||
|
|
||||||
if [ -n "$mktemp" ]; then
|
|
||||||
if qt mktemp -V ; then
|
|
||||||
MKTEMP=STD
|
|
||||||
else
|
|
||||||
MKTEMP=BSD
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
MKTEMP=None
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# create a temporary file. If a directory name is passed, the file will be created in
|
|
||||||
# that directory. Otherwise, it will be created in a temporary directory.
|
|
||||||
#
|
|
||||||
mktempfile() {
|
|
||||||
|
|
||||||
[ -z "$MKTEMP" ] && find_mktemp
|
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
case "$MKTEMP" in
|
|
||||||
BSD)
|
|
||||||
mktemp $1/shorewall.XXXXXX
|
|
||||||
;;
|
|
||||||
STD)
|
|
||||||
mktemp -p $1 shorewall.XXXXXX
|
|
||||||
;;
|
|
||||||
None)
|
|
||||||
> $1/shorewall-$$ && echo $1/shorewall-$$
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error_message "ERROR:Internal error in mktempfile"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
case "$MKTEMP" in
|
|
||||||
BSD)
|
|
||||||
mktemp ${TMPDIR:-/tmp}/shorewall.XXXXXX
|
|
||||||
;;
|
|
||||||
STD)
|
|
||||||
mktemp -t shorewall.XXXXXX
|
|
||||||
;;
|
|
||||||
None)
|
|
||||||
rm -f ${TMPDIR:-/tmp}/shorewall-$$
|
|
||||||
> ${TMPDIR:-}/shorewall-$$ && echo ${TMPDIR:-/tmp}/shorewall-$$
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error_message "ERROR:Internal error in mktempfile"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
@@ -25,22 +25,18 @@
|
|||||||
# loaded after this one and replaces some of the functions declared here.
|
# loaded after this one and replaces some of the functions declared here.
|
||||||
#
|
#
|
||||||
|
|
||||||
SHOREWALL_CAPVERSION=50004
|
SHOREWALL_CAPVERSION=50100
|
||||||
|
|
||||||
[ -n "${g_program:=shorewall}" ]
|
if [ -z "$g_basedir" ]; then
|
||||||
|
|
||||||
if [ -z "$g_readrc" ]; then
|
|
||||||
#
|
#
|
||||||
# This is modified by the installer when ${SHAREDIR} <> /usr/share
|
# This is modified by the installer when ${SHAREDIR} <> /usr/share
|
||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
g_sharedir="$SHAREDIR"/$g_program
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
g_confdir="$CONFDIR"/$g_program
|
|
||||||
g_readrc=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. ${SHAREDIR}/shorewall/lib.base
|
. ${g_basedir}/lib.core
|
||||||
|
|
||||||
#
|
#
|
||||||
# Issue an error message and die
|
# Issue an error message and die
|
||||||
@@ -82,29 +78,6 @@ showchain() # $1 = name of chain
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# The 'awk' hack that compensates for bugs in iptables-save (or rather in the extension modules).
|
|
||||||
#
|
|
||||||
|
|
||||||
iptablesbug()
|
|
||||||
{
|
|
||||||
if [ $g_family -eq 4 ]; then
|
|
||||||
if qt mywhich awk ; then
|
|
||||||
awk 'BEGIN { sline=""; };\
|
|
||||||
/^-[jg]/ { print sline $0; next };\
|
|
||||||
/-m policy.*-[jg] / { print $0; next };\
|
|
||||||
/-m policy/ { sline=$0; next };\
|
|
||||||
/--mask ff/ { sub( /--mask ff/, "--mask 0xff" ) };\
|
|
||||||
{ print ; sline="" }'
|
|
||||||
else
|
|
||||||
echo " WARNING: You don't have 'awk' on this system so the output of the save command may be unusable" >&2
|
|
||||||
cat
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
cat
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Validate the value of RESTOREFILE
|
# Validate the value of RESTOREFILE
|
||||||
#
|
#
|
||||||
@@ -395,13 +368,13 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
|
|||||||
if [ "$rejects" != "$oldrejects" ]; then
|
if [ "$rejects" != "$oldrejects" ]; then
|
||||||
oldrejects="$rejects"
|
oldrejects="$rejects"
|
||||||
|
|
||||||
$g_ring_bell
|
printf '\a'
|
||||||
|
|
||||||
packet_log 40
|
packet_log 40
|
||||||
|
|
||||||
if [ "$pause" = "Yes" ]; then
|
if [ "$pause" = "Yes" ]; then
|
||||||
echo
|
echo
|
||||||
echo $g_echo_n 'Enter any character to continue: '
|
printf 'Enter any character to continue: '
|
||||||
read foo
|
read foo
|
||||||
else
|
else
|
||||||
timed_read
|
timed_read
|
||||||
@@ -1011,13 +984,6 @@ show_raw() {
|
|||||||
$g_tool -t raw -L $g_ipt_options | $output_filter
|
$g_tool -t raw -L $g_ipt_options | $output_filter
|
||||||
}
|
}
|
||||||
|
|
||||||
show_rawpost() {
|
|
||||||
echo "$g_product $SHOREWALL_VERSION RAWPOST Table at $g_hostname - $(date)"
|
|
||||||
echo
|
|
||||||
show_reset
|
|
||||||
$g_tool -t rawpost -L $g_ipt_options | $output_filter
|
|
||||||
}
|
|
||||||
|
|
||||||
show_mangle() {
|
show_mangle() {
|
||||||
echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)"
|
echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)"
|
||||||
echo
|
echo
|
||||||
@@ -1161,6 +1127,48 @@ show_macros() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_an_action() {
|
||||||
|
echo "Shorewall $SHOREWALL_VERSION Action $1 at $g_hostname - $(date)"
|
||||||
|
cat ${directory}/action.$1
|
||||||
|
}
|
||||||
|
|
||||||
|
show_a_macro() {
|
||||||
|
echo "Shorewall $SHOREWALL_VERSION Macro $1 at $g_hostname - $(date)"
|
||||||
|
cat ${directory}/macro.$1
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# Don't dump empty SPD entries
|
||||||
|
#
|
||||||
|
spd_filter()
|
||||||
|
{
|
||||||
|
awk \
|
||||||
|
'BEGIN { skip=0; }; \
|
||||||
|
/^src/ { skip=0; }; \
|
||||||
|
/^src 0.0.0.0\/0/ { skip=1; }; \
|
||||||
|
/^src ::\/0/ { skip=1; }; \
|
||||||
|
{ if ( skip == 0 ) print; };'
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# Print a heading with leading and trailing black lines
|
||||||
|
#
|
||||||
|
heading() {
|
||||||
|
echo
|
||||||
|
echo "$@"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
show_ipsec() {
|
||||||
|
heading "PFKEY SPD"
|
||||||
|
$IP -s xfrm policy | spd_filter
|
||||||
|
heading "PFKEY SAD"
|
||||||
|
$IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # Don't divulge the keys
|
||||||
|
}
|
||||||
|
|
||||||
|
show_ipsec_command() {
|
||||||
|
echo "$g_product $SHOREWALL_VERSION IPSEC at $g_hostname - $(date)"
|
||||||
|
show_ipsec
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Show Command Executor
|
# Show Command Executor
|
||||||
#
|
#
|
||||||
@@ -1181,10 +1189,10 @@ show_command() {
|
|||||||
if [ -n "$foo" ]; then
|
if [ -n "$foo" ]; then
|
||||||
macro=${macro#*.}
|
macro=${macro#*.}
|
||||||
foo=${foo%.*}
|
foo=${foo%.*}
|
||||||
if [ ${#macro} -gt 10 ]; then
|
if [ ${#macro} -gt 5 ]; then
|
||||||
echo " $macro ${foo#\#}"
|
printf " $macro\t${foo#\#}\n"
|
||||||
else
|
else
|
||||||
$g_echo_e " $macro \t${foo#\#}"
|
printf " $macro\t\t${foo#\#}\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -1231,7 +1239,7 @@ show_command() {
|
|||||||
[ $# -eq 1 ] && missing_option_value -t
|
[ $# -eq 1 ] && missing_option_value -t
|
||||||
|
|
||||||
case $2 in
|
case $2 in
|
||||||
mangle|nat|filter|raw|rawpost)
|
mangle|nat|filter|raw)
|
||||||
table=$2
|
table=$2
|
||||||
table_given=Yes
|
table_given=Yes
|
||||||
;;
|
;;
|
||||||
@@ -1285,10 +1293,6 @@ show_command() {
|
|||||||
[ $# -gt 1 ] && too_many_arguments $2
|
[ $# -gt 1 ] && too_many_arguments $2
|
||||||
eval show_raw $g_pager
|
eval show_raw $g_pager
|
||||||
;;
|
;;
|
||||||
rawpost)
|
|
||||||
[ $# -gt 1 ] && too_many_arguments $2
|
|
||||||
eval show_rawpost $g_pager
|
|
||||||
;;
|
|
||||||
tos|mangle)
|
tos|mangle)
|
||||||
[ $# -gt 1 ] && too_many_arguments $2
|
[ $# -gt 1 ] && too_many_arguments $2
|
||||||
eval show_mangle $g_pager
|
eval show_mangle $g_pager
|
||||||
@@ -1356,14 +1360,14 @@ show_command() {
|
|||||||
echo "LIBEXEC=${LIBEXECDIR}"
|
echo "LIBEXEC=${LIBEXECDIR}"
|
||||||
echo "SBINDIR=${SBINDIR}"
|
echo "SBINDIR=${SBINDIR}"
|
||||||
echo "CONFDIR=${CONFDIR}"
|
echo "CONFDIR=${CONFDIR}"
|
||||||
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$g_program ] && echo "LITEDIR=${VARDIR}"
|
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$PRODUCT ] && echo "LITEDIR=${VARDIR}"
|
||||||
else
|
else
|
||||||
echo "Default CONFIG_PATH is $CONFIG_PATH"
|
echo "Default CONFIG_PATH is $CONFIG_PATH"
|
||||||
echo "Default VARDIR is /var/lib/$g_program"
|
echo "Default VARDIR is /var/lib/$PRODUCT"
|
||||||
echo "LIBEXEC is ${LIBEXECDIR}"
|
echo "LIBEXEC is ${LIBEXECDIR}"
|
||||||
echo "SBINDIR is ${SBINDIR}"
|
echo "SBINDIR is ${SBINDIR}"
|
||||||
echo "CONFDIR is ${CONFDIR}"
|
echo "CONFDIR is ${CONFDIR}"
|
||||||
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$g_program ] && echo "LITEDIR is ${VARDIR}"
|
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$PRODUCT ] && echo "LITEDIR is ${VARDIR}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
chain)
|
chain)
|
||||||
@@ -1426,23 +1430,49 @@ show_command() {
|
|||||||
$g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter
|
$g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
ipsec)
|
||||||
|
[ $# -gt 1 ] && too_many_arguments $2
|
||||||
|
eval show_ipsec_command $g_pager
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
case "$g_program" in
|
case "$PRODUCT" in
|
||||||
*-lite)
|
*-lite)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
case $1 in
|
case $1 in
|
||||||
|
action)
|
||||||
|
[ $# -lt 2 ] && fatal_error 'Missing <action>'
|
||||||
|
[ $# -gt 2 ] && too_many_arguments $2
|
||||||
|
|
||||||
|
for directory in $(split $CONFIG_PATH); do
|
||||||
|
if [ -f ${directory}/action.$2 ]; then
|
||||||
|
eval show_an_action $2 $g_pager
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
case $2 in
|
||||||
|
allowBcast|dropBcast|dropNotSyn|rejNotSyn|allowinUPnp|forwardUPnP|Limit)
|
||||||
|
echo " WARNING: $2 is a built-in action" >&2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo " WARNING: Action $2 not found" >&2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return
|
||||||
|
;;
|
||||||
actions)
|
actions)
|
||||||
[ $# -gt 1 ] && too_many_arguments $2
|
[ $# -gt 1 ] && too_many_arguments $2
|
||||||
eval show_actions_sorted $g_pager
|
eval show_actions_sorted $g_pager
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
macro)
|
macro)
|
||||||
|
[ $# -lt 2 ] && fatal_error 'Missing <macro>'
|
||||||
[ $# -ne 2 ] && too_many_arguments $2
|
[ $# -ne 2 ] && too_many_arguments $2
|
||||||
for directory in $(split $CONFIG_PATH); do
|
for directory in $(split $CONFIG_PATH); do
|
||||||
if [ -f ${directory}/macro.$2 ]; then
|
if [ -f ${directory}/macro.$2 ]; then
|
||||||
echo "Shorewall $SHOREWALL_VERSION Macro $2 at $g_hostname - $(date)"
|
eval show_a_macro $2 $g_pager
|
||||||
cat ${directory}/macro.$2
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -1674,11 +1704,6 @@ do_dump_command() {
|
|||||||
$g_tool -t raw -L $g_ipt_options
|
$g_tool -t raw -L $g_ipt_options
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if qt $g_tool -t rawpost -L -n; then
|
|
||||||
heading "Rawpost Table"
|
|
||||||
$g_tool -t rawpost -L $g_ipt_options
|
|
||||||
fi
|
|
||||||
|
|
||||||
local count
|
local count
|
||||||
local max
|
local max
|
||||||
|
|
||||||
@@ -1729,12 +1754,7 @@ do_dump_command() {
|
|||||||
heading "Events"
|
heading "Events"
|
||||||
show_events
|
show_events
|
||||||
|
|
||||||
if qt mywhich setkey; then
|
show_ipsec
|
||||||
heading "PFKEY SPD"
|
|
||||||
setkey -DP
|
|
||||||
heading "PFKEY SAD"
|
|
||||||
setkey -D | grep -Ev '^[[:space:]](A:|E:)' # Don't divulge the keys
|
|
||||||
fi
|
|
||||||
|
|
||||||
heading "/proc"
|
heading "/proc"
|
||||||
show_proc /proc/version
|
show_proc /proc/version
|
||||||
@@ -1805,6 +1825,7 @@ dump_command() {
|
|||||||
restore_command() {
|
restore_command() {
|
||||||
local finished
|
local finished
|
||||||
finished=0
|
finished=0
|
||||||
|
local result
|
||||||
|
|
||||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||||
option=$1
|
option=$1
|
||||||
@@ -1869,8 +1890,11 @@ restore_command() {
|
|||||||
progress_message3 "Restoring $g_product..."
|
progress_message3 "Restoring $g_product..."
|
||||||
|
|
||||||
run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE"
|
run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE"
|
||||||
|
result=$?
|
||||||
|
|
||||||
[ -n "$g_nolock" ] || mutex_off
|
[ -n "$g_nolock" ] || mutex_off
|
||||||
|
|
||||||
|
exit $result
|
||||||
else
|
else
|
||||||
echo "File $g_restorepath: file not found"
|
echo "File $g_restorepath: file not found"
|
||||||
[ -n "$g_nolock" ] || mutex_off
|
[ -n "$g_nolock" ] || mutex_off
|
||||||
@@ -1930,15 +1954,6 @@ read_yesno_with_timeout() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Print a heading with leading and trailing black lines
|
|
||||||
#
|
|
||||||
heading() {
|
|
||||||
echo
|
|
||||||
echo "$@"
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create the appropriate -q option to pass onward
|
# Create the appropriate -q option to pass onward
|
||||||
#
|
#
|
||||||
@@ -2739,7 +2754,6 @@ determine_capabilities() {
|
|||||||
CONNMARK_MATCH=
|
CONNMARK_MATCH=
|
||||||
XCONNMARK_MATCH=
|
XCONNMARK_MATCH=
|
||||||
RAW_TABLE=
|
RAW_TABLE=
|
||||||
RAWPOST_TABLE=
|
|
||||||
IPP2P_MATCH=
|
IPP2P_MATCH=
|
||||||
OLD_IPP2P_MATCH=
|
OLD_IPP2P_MATCH=
|
||||||
LENGTH_MATCH=
|
LENGTH_MATCH=
|
||||||
@@ -2795,6 +2809,8 @@ determine_capabilities() {
|
|||||||
IFACE_MATCH=
|
IFACE_MATCH=
|
||||||
TCPMSS_TARGET=
|
TCPMSS_TARGET=
|
||||||
WAIT_OPTION=
|
WAIT_OPTION=
|
||||||
|
CPU_FANOUT=
|
||||||
|
NETMAP_TARGET=
|
||||||
|
|
||||||
AMANDA_HELPER=
|
AMANDA_HELPER=
|
||||||
FTP_HELPER=
|
FTP_HELPER=
|
||||||
@@ -2829,8 +2845,10 @@ determine_capabilities() {
|
|||||||
if qt $g_tool -t nat -N $chain; then
|
if qt $g_tool -t nat -N $chain; then
|
||||||
if [ $g_family -eq 4 ]; then
|
if [ $g_family -eq 4 ]; then
|
||||||
qt $g_tool -t nat -A $chain -j SNAT --to-source 1.2.3.4 --persistent && PERSISTENT_SNAT=Yes
|
qt $g_tool -t nat -A $chain -j SNAT --to-source 1.2.3.4 --persistent && PERSISTENT_SNAT=Yes
|
||||||
|
qt $g_tool -t nat -A $chain -j NETMAP --to 1.2.3.0/24 && NETMAP_TARGET=Yes
|
||||||
else
|
else
|
||||||
qt $g_tool -t nat -A $chain -j SNAT --to-source 2001::1 --persistent && PERSISTENT_SNAT=Yes
|
qt $g_tool -t nat -A $chain -j SNAT --to-source 2001::1 --persistent && PERSISTENT_SNAT=Yes
|
||||||
|
qt $g_tool -t nat -A $chain -j NETMAP --to 2001:470:B:227::/64 && NETMAP_TARGET=Yes
|
||||||
fi
|
fi
|
||||||
qt $g_tool -t nat -A $chain -j MASQUERADE && MASQUERADE_TGT=Yes
|
qt $g_tool -t nat -A $chain -j MASQUERADE && MASQUERADE_TGT=Yes
|
||||||
qt $g_tool -t nat -A $chain -p udplite -m multiport --dport 33 -j REDIRECT --to-port 22 && UDPREDIRECT=Yes
|
qt $g_tool -t nat -A $chain -p udplite -m multiport --dport 33 -j REDIRECT --to-port 22 && UDPREDIRECT=Yes
|
||||||
@@ -2990,7 +3008,6 @@ determine_capabilities() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
qt $g_tool -t raw -L -n && RAW_TABLE=Yes
|
qt $g_tool -t raw -L -n && RAW_TABLE=Yes
|
||||||
qt $g_tool -t rawpost -L -n && RAWPOST_TABLE=Yes
|
|
||||||
|
|
||||||
if [ -n "$RAW_TABLE" ]; then
|
if [ -n "$RAW_TABLE" ]; then
|
||||||
qt $g_tool -t raw -F $chain
|
qt $g_tool -t raw -F $chain
|
||||||
@@ -3092,7 +3109,12 @@ determine_capabilities() {
|
|||||||
qt $g_tool -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && OLD_HL_MATCH=Yes
|
qt $g_tool -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && OLD_HL_MATCH=Yes
|
||||||
HASHLIMIT_MATCH=$OLD_HL_MATCH
|
HASHLIMIT_MATCH=$OLD_HL_MATCH
|
||||||
fi
|
fi
|
||||||
qt $g_tool -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes
|
|
||||||
|
if qt $g_tool -A $chain -j NFQUEUE --queue-num 4; then
|
||||||
|
NFQUEUE_TARGET=Yes
|
||||||
|
qt $g_tool -A $chain -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout && CPU_FANOUT=Yes
|
||||||
|
fi
|
||||||
|
|
||||||
qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes
|
qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -3211,7 +3233,6 @@ report_capabilities_unsorted() {
|
|||||||
report_capability "Connmark Match (CONNMARK_MATCH)" $CONNMARK_MATCH
|
report_capability "Connmark Match (CONNMARK_MATCH)" $CONNMARK_MATCH
|
||||||
[ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match (XCONNMARK_MATCH)" $XCONNMARK_MATCH
|
[ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match (XCONNMARK_MATCH)" $XCONNMARK_MATCH
|
||||||
report_capability "Raw Table (RAW_TABLE)" $RAW_TABLE
|
report_capability "Raw Table (RAW_TABLE)" $RAW_TABLE
|
||||||
report_capability "Rawpost Table (RAWPOST_TABLE)" $RAWPOST_TABLE
|
|
||||||
report_capability "IPP2P Match (IPP2P_MATCH)" $IPP2P_MATCH
|
report_capability "IPP2P Match (IPP2P_MATCH)" $IPP2P_MATCH
|
||||||
[ -n "$OLD_IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax (OLD_IPP2P_MATCH)" $OLD_IPP2P_MATCH
|
[ -n "$OLD_IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax (OLD_IPP2P_MATCH)" $OLD_IPP2P_MATCH
|
||||||
report_capability "CLASSIFY Target (CLASSIFY_TARGET)" $CLASSIFY_TARGET
|
report_capability "CLASSIFY Target (CLASSIFY_TARGET)" $CLASSIFY_TARGET
|
||||||
@@ -3290,6 +3311,8 @@ report_capabilities_unsorted() {
|
|||||||
report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER
|
report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER
|
||||||
report_capability "Basic Ematch (BASIC_EMATCH)" $BASIC_EMATCH
|
report_capability "Basic Ematch (BASIC_EMATCH)" $BASIC_EMATCH
|
||||||
report_capability "CT Target (CT_TARGET)" $CT_TARGET
|
report_capability "CT Target (CT_TARGET)" $CT_TARGET
|
||||||
|
report_capability "NFQUEUE CPU Fanout (CPU_FANOUT)" $CPU_FANOUT
|
||||||
|
report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET
|
||||||
|
|
||||||
echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
|
echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
|
||||||
echo " Capabilities Version (CAPVERSION): $CAPVERSION"
|
echo " Capabilities Version (CAPVERSION): $CAPVERSION"
|
||||||
@@ -3339,7 +3362,6 @@ report_capabilities_unsorted1() {
|
|||||||
report_capability1 CONNMARK_MATCH
|
report_capability1 CONNMARK_MATCH
|
||||||
report_capability1 XCONNMARK_MATCH
|
report_capability1 XCONNMARK_MATCH
|
||||||
report_capability1 RAW_TABLE
|
report_capability1 RAW_TABLE
|
||||||
report_capability1 RAWPOST_TABLE
|
|
||||||
report_capability1 IPP2P_MATCH
|
report_capability1 IPP2P_MATCH
|
||||||
report_capability1 OLD_IPP2P_MATCH
|
report_capability1 OLD_IPP2P_MATCH
|
||||||
report_capability1 CLASSIFY_TARGET
|
report_capability1 CLASSIFY_TARGET
|
||||||
@@ -3395,6 +3417,8 @@ report_capabilities_unsorted1() {
|
|||||||
report_capability1 IFACE_MATCH
|
report_capability1 IFACE_MATCH
|
||||||
report_capability1 TCPMSS_TARGET
|
report_capability1 TCPMSS_TARGET
|
||||||
report_capability1 WAIT_OPTION
|
report_capability1 WAIT_OPTION
|
||||||
|
report_capability1 CPU_FANOUT
|
||||||
|
report_capability1 NETMAP_TARGET
|
||||||
|
|
||||||
report_capability1 AMANDA_HELPER
|
report_capability1 AMANDA_HELPER
|
||||||
report_capability1 FTP_HELPER
|
report_capability1 FTP_HELPER
|
||||||
@@ -3866,7 +3890,7 @@ get_config() {
|
|||||||
|
|
||||||
ensure_config_path
|
ensure_config_path
|
||||||
|
|
||||||
config=$(find_file ${g_program}.conf)
|
config=$(find_file ${PRODUCT}.conf)
|
||||||
|
|
||||||
if [ -f $config ]; then
|
if [ -f $config ]; then
|
||||||
if [ -r $config ]; then
|
if [ -r $config ]; then
|
||||||
@@ -3992,24 +4016,26 @@ get_config() {
|
|||||||
|
|
||||||
g_loopback=$(find_loopback_interfaces)
|
g_loopback=$(find_loopback_interfaces)
|
||||||
|
|
||||||
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
if [ -z "$g_nopager" ]; then
|
||||||
|
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
||||||
|
|
||||||
if [ -n "$PAGER" -a -t 1 ]; then
|
if [ -n "$PAGER" -a -t 1 ]; then
|
||||||
case $PAGER in
|
case $PAGER in
|
||||||
/*)
|
/*)
|
||||||
g_pager="$PAGER"
|
g_pager="$PAGER"
|
||||||
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
|
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
g_pager=$(mywhich $PAGER 2> /dev/null)
|
g_pager=$(mywhich $PAGER 2> /dev/null)
|
||||||
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
|
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
|
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
|
||||||
|
|
||||||
g_pager="| $g_pager"
|
g_pager="| $g_pager"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$DYNAMIC_BLACKLIST" ]; then
|
if [ -n "$DYNAMIC_BLACKLIST" ]; then
|
||||||
setup_dbl
|
setup_dbl
|
||||||
@@ -4270,6 +4296,7 @@ usage() # $1 = exit status
|
|||||||
echo " savesets"
|
echo " savesets"
|
||||||
echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
|
echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
|
||||||
ecko " [ show | list | ls ] actions"
|
ecko " [ show | list | ls ] actions"
|
||||||
|
ecko " [ show | list | ls ] action <action>"
|
||||||
echo " [ show | list | ls ] arptables"
|
echo " [ show | list | ls ] arptables"
|
||||||
echo " [ show | list | ls ] [ -f ] capabilities"
|
echo " [ show | list | ls ] [ -f ] capabilities"
|
||||||
echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
|
echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
|
||||||
@@ -4285,8 +4312,9 @@ usage() # $1 = exit status
|
|||||||
echo " [ show | list | ls ] ipa"
|
echo " [ show | list | ls ] ipa"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo " [ show | list | ls ] ipsec"
|
||||||
echo " [ show | list | ls ] [ -m ] log [<regex>]"
|
echo " [ show | list | ls ] [ -m ] log [<regex>]"
|
||||||
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost"
|
echo " [ show | list | ls ] [ -x ] mangle|nat|raw"
|
||||||
ecko " [ show | list | ls ] macro <macro>"
|
ecko " [ show | list | ls ] macro <macro>"
|
||||||
ecko " [ show | list | ls ] macros"
|
ecko " [ show | list | ls ] macros"
|
||||||
echo " [ show | list | ls ] nfacct"
|
echo " [ show | list | ls ] nfacct"
|
||||||
@@ -4315,7 +4343,7 @@ usage() # $1 = exit status
|
|||||||
#
|
#
|
||||||
# This is the main entry point into the CLI. It directly handles all commands supported
|
# This is the main entry point into the CLI. It directly handles all commands supported
|
||||||
# by both the full and lite versions. Note, however, that functions such as start_command()
|
# by both the full and lite versions. Note, however, that functions such as start_command()
|
||||||
# appear in both this library and it lib.cli-std. The ones in cli-std overload the ones
|
# appear in both this library and in lib.cli-std. The ones in cli-std overload the ones
|
||||||
# here if that lib is loaded below.
|
# here if that lib is loaded below.
|
||||||
#
|
#
|
||||||
shorewall_cli() {
|
shorewall_cli() {
|
||||||
@@ -4357,13 +4385,16 @@ shorewall_cli() {
|
|||||||
g_loopback=
|
g_loopback=
|
||||||
g_compiled=
|
g_compiled=
|
||||||
g_pager=
|
g_pager=
|
||||||
|
g_nopager=
|
||||||
g_blacklistipset=
|
g_blacklistipset=
|
||||||
g_disconnect=
|
g_disconnect=
|
||||||
|
|
||||||
VERBOSE=
|
VERBOSE=
|
||||||
VERBOSITY=1
|
VERBOSITY=1
|
||||||
|
#
|
||||||
[ -n "$g_lite" ] || . ${g_basedir}/lib.cli-std
|
# Set the default product based on the Shorewall packages installed
|
||||||
|
#
|
||||||
|
set_default_product
|
||||||
|
|
||||||
finished=0
|
finished=0
|
||||||
|
|
||||||
@@ -4453,6 +4484,34 @@ shorewall_cli() {
|
|||||||
g_timestamp=Yes
|
g_timestamp=Yes
|
||||||
option=${option#t}
|
option=${option#t}
|
||||||
;;
|
;;
|
||||||
|
p*)
|
||||||
|
g_nopager=Yes
|
||||||
|
option=${option#p}
|
||||||
|
;;
|
||||||
|
6*)
|
||||||
|
if [ "$PRODUCT" = shorewall ]; then
|
||||||
|
PRODUCT=shorewall6
|
||||||
|
elif [ "$PRODUCT" = shorewall-lite ]; then
|
||||||
|
PRODUCT=shorewall6-lite
|
||||||
|
fi
|
||||||
|
option=${option#6}
|
||||||
|
;;
|
||||||
|
4*)
|
||||||
|
if [ "$PRODUCT" = shorewall6 ]; then
|
||||||
|
PRODUCT=shorewall
|
||||||
|
elif [ "$PRODUCT" = shorewall6-lite ]; then
|
||||||
|
PRODUCT=shorewall-lite
|
||||||
|
fi
|
||||||
|
option=${option#4}
|
||||||
|
;;
|
||||||
|
l*)
|
||||||
|
if [ "$PRODUCT" = shorewall ]; then
|
||||||
|
PRODUCT=shorewall-lite
|
||||||
|
elif [ "$PRODUCT" = shorewall6 ]; then
|
||||||
|
PRODUCT=shorewall6-lite
|
||||||
|
fi
|
||||||
|
option=${option#l}
|
||||||
|
;;
|
||||||
-)
|
-)
|
||||||
finished=1
|
finished=1
|
||||||
option=
|
option=
|
||||||
@@ -4474,12 +4533,16 @@ shorewall_cli() {
|
|||||||
usage 1
|
usage 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
setup_product_environment 1
|
||||||
|
|
||||||
|
[ -n "$g_lite" ] || . ${SHAREDIR}/shorewall/lib.cli-std
|
||||||
|
|
||||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||||
MUTEX_TIMEOUT=
|
MUTEX_TIMEOUT=
|
||||||
|
|
||||||
[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir
|
[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir
|
||||||
|
|
||||||
[ -n "${VARDIR:=/var/lib/$g_program}" ]
|
[ -n "${VARDIR:=/var/lib/$PRODUCT}" ]
|
||||||
|
|
||||||
g_firewall=${VARDIR}/firewall
|
g_firewall=${VARDIR}/firewall
|
||||||
|
|
||||||
@@ -4494,26 +4557,6 @@ shorewall_cli() {
|
|||||||
|
|
||||||
banner="${g_product}-${SHOREWALL_VERSION} Status at $g_hostname -"
|
banner="${g_product}-${SHOREWALL_VERSION} Status at $g_hostname -"
|
||||||
|
|
||||||
case $(echo -e) in
|
|
||||||
-e*)
|
|
||||||
g_ring_bell="echo \a"
|
|
||||||
g_echo_e="echo"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
g_ring_bell="echo -e \a"
|
|
||||||
g_echo_e="echo -e"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case $(echo -n "Testing") in
|
|
||||||
-n*)
|
|
||||||
g_echo_n=
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
g_echo_n=-n
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
COMMAND=$1
|
COMMAND=$1
|
||||||
|
|
||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
|
440
Shorewall-core/lib.core
Normal file
440
Shorewall-core/lib.core
Normal file
@@ -0,0 +1,440 @@
|
|||||||
|
#
|
||||||
|
# Shorewall 5.0 -- /usr/share/shorewall/lib.core
|
||||||
|
#
|
||||||
|
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||||
|
#
|
||||||
|
# Complete documentation is available at http://shorewall.net
|
||||||
|
#
|
||||||
|
# This program is part of Shorewall.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation, either version 2 of the license or, at your
|
||||||
|
# option, any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# This library contains the code common to all Shorewall components except the
|
||||||
|
# generated scripts.
|
||||||
|
#
|
||||||
|
|
||||||
|
SHOREWALL_LIBVERSION=50100
|
||||||
|
|
||||||
|
#
|
||||||
|
# Fatal Error
|
||||||
|
#
|
||||||
|
fatal_error() # $@ = Message
|
||||||
|
{
|
||||||
|
echo " ERROR: $@" >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_product_environment() { # $1 = if non-empty, source shorewallrc again now that we have the correct product
|
||||||
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
|
|
||||||
|
g_sharedir="$SHAREDIR"/$PRODUCT
|
||||||
|
g_confdir="$CONFDIR"/$PRODUCT
|
||||||
|
|
||||||
|
case $PRODUCT in
|
||||||
|
shorewall)
|
||||||
|
g_product="Shorewall"
|
||||||
|
g_family=4
|
||||||
|
g_tool=iptables
|
||||||
|
g_lite=
|
||||||
|
;;
|
||||||
|
shorewall6)
|
||||||
|
g_product="Shorewall6"
|
||||||
|
g_family=6
|
||||||
|
g_tool=ip6tables
|
||||||
|
g_lite=
|
||||||
|
;;
|
||||||
|
shorewall-lite)
|
||||||
|
g_product="Shorewall Lite"
|
||||||
|
g_family=4
|
||||||
|
g_tool=iptables
|
||||||
|
g_lite=Yes
|
||||||
|
;;
|
||||||
|
shorewall6-lite)
|
||||||
|
g_product="Shorewall6 Lite"
|
||||||
|
g_family=6
|
||||||
|
g_tool=ip6tables
|
||||||
|
g_lite=Yes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fatal_error "Unknown PRODUCT ($PRODUCT)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -f ${SHAREDIR}/${PRODUCT}/version ] || fatal_error "$g_product does not appear to be installed on this system"
|
||||||
|
#
|
||||||
|
# We need to do this again, now that we have the correct product
|
||||||
|
#
|
||||||
|
[ -n "$1" ] && . ${g_basedir}/shorewallrc
|
||||||
|
|
||||||
|
if [ -z "${VARLIB}" ]; then
|
||||||
|
VARLIB=${VARDIR}
|
||||||
|
VARDIR=${VARLIB}/${PRODUCT}
|
||||||
|
elif [ -z "${VARDIR}" ]; then
|
||||||
|
VARDIR="${VARLIB}/${PRODUCT}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_default_product() {
|
||||||
|
case $(basename $0) in
|
||||||
|
shorewall6)
|
||||||
|
PRODUCT=shorewall6
|
||||||
|
;;
|
||||||
|
shorewall4)
|
||||||
|
PRODUCT=shorewall
|
||||||
|
;;
|
||||||
|
shorewall-lite)
|
||||||
|
PRODUCT=shorewall-lite
|
||||||
|
;;
|
||||||
|
shorewall6-lite)
|
||||||
|
PRODUCT=shorewall6-lite
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ -f ${g_basedir}/version ]; then
|
||||||
|
PRODUCT=shorewall
|
||||||
|
elif [ -f ${SHAREDIR}/shorewall-lite/version ]; then
|
||||||
|
PRODUCT=shorewall-lite
|
||||||
|
elif [ -f ${SHAREDIR}/shorewall6-lite/version ]; then
|
||||||
|
PRODUCT=shorewall6-lite
|
||||||
|
else
|
||||||
|
fatal_error "No Shorewall firewall product is installed"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Not configured Error
|
||||||
|
#
|
||||||
|
not_configured_error() # $@ = Message
|
||||||
|
{
|
||||||
|
echo " ERROR: $@" >&2
|
||||||
|
exit 6
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Conditionally produce message
|
||||||
|
#
|
||||||
|
progress_message() # $* = Message
|
||||||
|
{
|
||||||
|
local timestamp
|
||||||
|
timestamp=
|
||||||
|
|
||||||
|
if [ $VERBOSITY -gt 1 ]; then
|
||||||
|
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||||
|
echo "${timestamp}$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
progress_message2() # $* = Message
|
||||||
|
{
|
||||||
|
local timestamp
|
||||||
|
timestamp=
|
||||||
|
|
||||||
|
if [ $VERBOSITY -gt 0 ]; then
|
||||||
|
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||||
|
echo "${timestamp}$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
progress_message3() # $* = Message
|
||||||
|
{
|
||||||
|
local timestamp
|
||||||
|
timestamp=
|
||||||
|
|
||||||
|
if [ $VERBOSITY -ge 0 ]; then
|
||||||
|
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||||
|
echo "${timestamp}$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Undo the effect of 'separate_list()'
|
||||||
|
#
|
||||||
|
combine_list()
|
||||||
|
{
|
||||||
|
local f
|
||||||
|
local o
|
||||||
|
o=
|
||||||
|
|
||||||
|
for f in $* ; do
|
||||||
|
o="${o:+$o,}$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $o
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Validate an IP address
|
||||||
|
#
|
||||||
|
valid_address() {
|
||||||
|
local x
|
||||||
|
local y
|
||||||
|
local ifs
|
||||||
|
ifs=$IFS
|
||||||
|
|
||||||
|
IFS=.
|
||||||
|
|
||||||
|
for x in $1; do
|
||||||
|
case $x in
|
||||||
|
[0-9]|[0-9][0-9]|[1-2][0-9][0-9])
|
||||||
|
[ $x -lt 256 ] || { IFS=$ifs; return 2; }
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
IFS=$ifs
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
IFS=$ifs
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Miserable Hack to work around broken BusyBox ash in OpenWRT
|
||||||
|
#
|
||||||
|
addr_comp() {
|
||||||
|
test $(bc <<EOF
|
||||||
|
$1 > $2
|
||||||
|
EOF
|
||||||
|
) -eq 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Enumerate the members of an IP range -- When using a shell supporting only
|
||||||
|
# 32-bit signed arithmetic, the range cannot span 128.0.0.0.
|
||||||
|
#
|
||||||
|
# Comes in two flavors:
|
||||||
|
#
|
||||||
|
# ip_range() - produces a mimimal list of network/host addresses that spans
|
||||||
|
# the range.
|
||||||
|
#
|
||||||
|
# ip_range_explicit() - explicitly enumerates the range.
|
||||||
|
#
|
||||||
|
ip_range() {
|
||||||
|
local first
|
||||||
|
local last
|
||||||
|
local l
|
||||||
|
local x
|
||||||
|
local y
|
||||||
|
local z
|
||||||
|
local vlsm
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
!*)
|
||||||
|
#
|
||||||
|
# Let iptables complain if it's a range
|
||||||
|
#
|
||||||
|
echo $1
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
[0-9]*.*.*.*-*.*.*.*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $1
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
first=$(decodeaddr ${1%-*})
|
||||||
|
last=$(decodeaddr ${1#*-})
|
||||||
|
|
||||||
|
if addr_comp $first $last; then
|
||||||
|
fatal_error "Invalid IP address range: $1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
l=$(( $last + 1 ))
|
||||||
|
|
||||||
|
while addr_comp $l $first; do
|
||||||
|
vlsm=
|
||||||
|
x=31
|
||||||
|
y=2
|
||||||
|
z=1
|
||||||
|
|
||||||
|
while [ $(( $first % $y )) -eq 0 ] && ! addr_comp $(( $first + $y )) $l; do
|
||||||
|
vlsm=/$x
|
||||||
|
x=$(( $x - 1 ))
|
||||||
|
z=$y
|
||||||
|
y=$(( $y * 2 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $(encodeaddr $first)$vlsm
|
||||||
|
first=$(($first + $z))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
ip_range_explicit() {
|
||||||
|
local first
|
||||||
|
local last
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
[0-9]*.*.*.*-*.*.*.*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $1
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
first=$(decodeaddr ${1%-*})
|
||||||
|
last=$(decodeaddr ${1#*-})
|
||||||
|
|
||||||
|
if addr_comp $first $last; then
|
||||||
|
fatal_error "Invalid IP address range: $1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while ! addr_comp $first $last; do
|
||||||
|
echo $(encodeaddr $first)
|
||||||
|
first=$(($first + 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
|
||||||
|
|
||||||
|
#
|
||||||
|
# Netmask to VLSM
|
||||||
|
#
|
||||||
|
ip_vlsm() {
|
||||||
|
local mask
|
||||||
|
mask=$(decodeaddr $1)
|
||||||
|
local vlsm
|
||||||
|
vlsm=0
|
||||||
|
local x
|
||||||
|
x=$(( 128 << 24 )) # 0x80000000
|
||||||
|
|
||||||
|
while [ $(( $x & $mask )) -ne 0 ]; do
|
||||||
|
[ $mask -eq $x ] && mask=0 || mask=$(( $mask $LEFTSHIFT 1 )) # Not all shells shift 0x80000000 left properly.
|
||||||
|
vlsm=$(($vlsm + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $(( $mask & 2147483647 )) -ne 0 ]; then # 2147483647 = 0x7fffffff
|
||||||
|
echo "Invalid net mask: $1" >&2
|
||||||
|
else
|
||||||
|
echo $vlsm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set default config path
|
||||||
|
#
|
||||||
|
ensure_config_path() {
|
||||||
|
local F
|
||||||
|
F=${g_sharedir}/configpath
|
||||||
|
if [ -z "$CONFIG_PATH" ]; then
|
||||||
|
[ -f $F ] || { echo " ERROR: $F does not exist"; exit 2; }
|
||||||
|
. $F
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$g_shorewalldir" ]; then
|
||||||
|
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get fully-qualified name of file
|
||||||
|
#
|
||||||
|
resolve_file() # $1 = file name
|
||||||
|
{
|
||||||
|
local pwd
|
||||||
|
pwd=$PWD
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
/*)
|
||||||
|
echo $1
|
||||||
|
;;
|
||||||
|
.)
|
||||||
|
echo $pwd
|
||||||
|
;;
|
||||||
|
./*)
|
||||||
|
echo ${pwd}${1#.}
|
||||||
|
;;
|
||||||
|
..)
|
||||||
|
cd ..
|
||||||
|
echo $PWD
|
||||||
|
cd $pwd
|
||||||
|
;;
|
||||||
|
../*)
|
||||||
|
cd ..
|
||||||
|
resolve_file ${1#../}
|
||||||
|
cd $pwd
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $pwd/$1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine which version of mktemp is present (if any) and set MKTEMP accortingly:
|
||||||
|
#
|
||||||
|
# None - No mktemp
|
||||||
|
# BSD - BSD mktemp (Mandrake)
|
||||||
|
# STD - mktemp.org mktemp
|
||||||
|
#
|
||||||
|
find_mktemp() {
|
||||||
|
local mktemp
|
||||||
|
mktemp=`mywhich mktemp 2> /dev/null`
|
||||||
|
|
||||||
|
if [ -n "$mktemp" ]; then
|
||||||
|
if qt mktemp -V ; then
|
||||||
|
MKTEMP=STD
|
||||||
|
else
|
||||||
|
MKTEMP=BSD
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
MKTEMP=None
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# create a temporary file. If a directory name is passed, the file will be created in
|
||||||
|
# that directory. Otherwise, it will be created in a temporary directory.
|
||||||
|
#
|
||||||
|
mktempfile() {
|
||||||
|
|
||||||
|
[ -z "$MKTEMP" ] && find_mktemp
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
case "$MKTEMP" in
|
||||||
|
BSD)
|
||||||
|
mktemp $1/shorewall.XXXXXX
|
||||||
|
;;
|
||||||
|
STD)
|
||||||
|
mktemp -p $1 shorewall.XXXXXX
|
||||||
|
;;
|
||||||
|
None)
|
||||||
|
> $1/shorewall-$$ && echo $1/shorewall-$$
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error_message "ERROR:Internal error in mktempfile"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case "$MKTEMP" in
|
||||||
|
BSD)
|
||||||
|
mktemp ${TMPDIR:-/tmp}/shorewall.XXXXXX
|
||||||
|
;;
|
||||||
|
STD)
|
||||||
|
mktemp -t shorewall.XXXXXX
|
||||||
|
;;
|
||||||
|
None)
|
||||||
|
rm -f ${TMPDIR:-/tmp}/shorewall-$$
|
||||||
|
> ${TMPDIR:-}/shorewall-$$ && echo ${TMPDIR:-/tmp}/shorewall-$$
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error_message "ERROR:Internal error in mktempfile"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@@ -32,11 +32,8 @@ PRODUCT=shorewall
|
|||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
g_program=$PRODUCT
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
g_sharedir="$SHAREDIR"/shorewall
|
|
||||||
g_confdir="$CONFDIR"/shorewall
|
|
||||||
g_readrc=1
|
|
||||||
|
|
||||||
. $g_sharedir/lib.cli
|
. ${g_basedir}/lib.cli
|
||||||
|
|
||||||
shorewall_cli $@
|
shorewall_cli $@
|
@@ -81,7 +81,6 @@ if [ $# -eq 0 ]; then
|
|||||||
. ./shorewallrc
|
. ./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
|
||||||
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
|
@@ -31,8 +31,10 @@ setstatedir() {
|
|||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ ! -x $STATEDIR/firewall ]; then
|
if [ ! -x $STATEDIR/firewall ]; then
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT compile
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -128,7 +130,7 @@ for PRODUCT in $PRODUCTS; do
|
|||||||
setstatedir
|
setstatedir
|
||||||
|
|
||||||
if [ -x $VARLIB/$PRODUCT/firewall ]; then
|
if [ -x $VARLIB/$PRODUCT/firewall ]; then
|
||||||
( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
|
( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@@ -33,9 +33,11 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ ! -x "$STATEDIR/firewall" ]; then
|
if [ ! -x $STATEDIR/firewall ]; then
|
||||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT $OPTIONS compile
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@@ -31,8 +31,10 @@ setstatedir() {
|
|||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ ! -x $STATEDIR/firewall ]; then
|
if [ ! -x $STATEDIR/firewall ]; then
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT compile
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@@ -73,8 +73,10 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -102,7 +104,7 @@ shorewall_start () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
|
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
@@ -123,7 +125,7 @@ shorewall_start () {
|
|||||||
|
|
||||||
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
||||||
|
|
||||||
echo -n "Restoring ipsets: "
|
printf "Restoring ipsets: "
|
||||||
|
|
||||||
if ! ipset -R < "$SAVE_IPSETS"; then
|
if ! ipset -R < "$SAVE_IPSETS"; then
|
||||||
echo_notdone
|
echo_notdone
|
||||||
@@ -140,7 +142,7 @@ shorewall_stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
|
@@ -44,8 +44,10 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT $OPTIONS compile -c
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -62,7 +64,7 @@ start () {
|
|||||||
return 6 #Not configured
|
return 6 #Not configured
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
|
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
setstatedir
|
setstatedir
|
||||||
@@ -97,7 +99,7 @@ stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
|
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
setstatedir
|
setstatedir
|
||||||
|
@@ -75,8 +75,10 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -87,7 +89,7 @@ start () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
@@ -112,7 +114,7 @@ stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
|
@@ -81,7 +81,7 @@ shorewall_start () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
@@ -104,7 +104,7 @@ shorewall_stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
|
@@ -79,8 +79,10 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -91,7 +93,7 @@ shorewall_start () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x $STATEDIR/firewall ]; then
|
if [ -x $STATEDIR/firewall ]; then
|
||||||
@@ -112,7 +114,7 @@ shorewall_stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
|
@@ -164,10 +164,10 @@ if [ $# -eq 0 ]; then
|
|||||||
#
|
#
|
||||||
if [ -f ./shorewallrc ]; then
|
if [ -f ./shorewallrc ]; then
|
||||||
. ./shorewallrc || exit 1
|
. ./shorewallrc || exit 1
|
||||||
file=~/.shorewallrc
|
file=./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
file=~/.shorewallrc
|
||||||
else
|
else
|
||||||
fatal_error "No configuration file specified and ~/.shorewallrc not found"
|
fatal_error "No configuration file specified and ~/.shorewallrc not found"
|
||||||
fi
|
fi
|
||||||
|
@@ -33,8 +33,10 @@ setstatedir() {
|
|||||||
|
|
||||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||||
|
|
||||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
if [ $PRODUCT = shorewall ]; then
|
||||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
${SBINDIR}/shorewall compile
|
||||||
|
elif [ $PRODUCT = shorewall6 ]; then
|
||||||
|
${SBINDIR}/shorewall -6 compile
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -62,7 +64,7 @@ shorewall_start () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
printf "Initializing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
@@ -90,7 +92,7 @@ shorewall_stop () {
|
|||||||
local PRODUCT
|
local PRODUCT
|
||||||
local STATEDIR
|
local STATEDIR
|
||||||
|
|
||||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
printf "Clearing \"Shorewall-based firewalls\": "
|
||||||
for PRODUCT in $PRODUCTS; do
|
for PRODUCT in $PRODUCTS; do
|
||||||
if setstatedir; then
|
if setstatedir; then
|
||||||
if [ -x ${STATEDIR}/firewall ]; then
|
if [ -x ${STATEDIR}/firewall ]; then
|
||||||
|
@@ -126,7 +126,6 @@ if [ $# -eq 0 ]; then
|
|||||||
. ./shorewallrc
|
. ./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
|
||||||
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
# Shorewall Lite Makefile to restart if firewall script is newer than last restart
|
|
||||||
VARDIR=$(shell /sbin/shorewall-lite show vardir)
|
|
||||||
SHAREDIR=/usr/share/shorewall-lite
|
|
||||||
RESTOREFILE?=.restore
|
|
||||||
|
|
||||||
all: $(VARDIR)/$(RESTOREFILE)
|
|
||||||
|
|
||||||
$(VARDIR)/$(RESTOREFILE): $(VARDIR)/firewall
|
|
||||||
@/sbin/shorewall-lite -q save >/dev/null; \
|
|
||||||
if \
|
|
||||||
/sbin/shorewall-lite -q restart >/dev/null 2>&1; \
|
|
||||||
then \
|
|
||||||
/sbin/shorewall-lite -q save >/dev/null; \
|
|
||||||
else \
|
|
||||||
/sbin/shorewall-lite -q restart 2>&1 | tail >&2; exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# EOF
|
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
SRWL=/sbin/shorewall-lite
|
SRWL='/sbin/shorewall -l'
|
||||||
SRWL_OPTS="-tvv"
|
SRWL_OPTS="-tvv"
|
||||||
test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
|
test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ fi
|
|||||||
|
|
||||||
# start the firewall
|
# start the firewall
|
||||||
shorewall_start () {
|
shorewall_start () {
|
||||||
echo -n "Starting \"Shorewall firewall\": "
|
printf "Starting \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -93,10 +93,10 @@ shorewall_start () {
|
|||||||
# stop the firewall
|
# stop the firewall
|
||||||
shorewall_stop () {
|
shorewall_stop () {
|
||||||
if [ "$SAFESTOP" = 1 ]; then
|
if [ "$SAFESTOP" = 1 ]; then
|
||||||
echo -n "Stopping \"Shorewall Lite firewall\": "
|
printf "Stopping \"Shorewall Lite firewall\": "
|
||||||
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
else
|
else
|
||||||
echo -n "Clearing all \"Shorewall Lite firewall\" rules: "
|
printf "Clearing all \"Shorewall Lite firewall\" rules: "
|
||||||
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -104,14 +104,14 @@ shorewall_stop () {
|
|||||||
|
|
||||||
# restart the firewall
|
# restart the firewall
|
||||||
shorewall_restart () {
|
shorewall_restart () {
|
||||||
echo -n "Restarting \"Shorewall firewall\": "
|
printf "Restarting \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# refresh the firewall
|
# refresh the firewall
|
||||||
shorewall_refresh () {
|
shorewall_refresh () {
|
||||||
echo -n "Refreshing \"Shorewall firewall\": "
|
printf "Refreshing \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
prog="shorewall-lite"
|
prog="shorewall -l"
|
||||||
shorewall="${SBINDIR}/$prog"
|
shorewall="${SBINDIR}/$prog"
|
||||||
logger="logger -i -t $prog"
|
logger="logger -i -t $prog"
|
||||||
lockfile="/var/lock/subsys/$prog"
|
lockfile="/var/lock/subsys/$prog"
|
||||||
@@ -38,7 +38,7 @@ if [ -f ${SYSCONFDIR}/$prog ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo -n $"Starting Shorewall: "
|
printf $"Starting Shorewall: "
|
||||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -52,7 +52,7 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo -n $"Stopping Shorewall: "
|
printf $"Stopping Shorewall: "
|
||||||
$shorewall $OPTIONS stop 2>&1 | $logger
|
$shorewall $OPTIONS stop 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -68,7 +68,7 @@ stop() {
|
|||||||
restart() {
|
restart() {
|
||||||
# Note that we don't simply stop and start since shorewall has a built in
|
# Note that we don't simply stop and start since shorewall has a built in
|
||||||
# restart which stops the firewall if running and then starts it.
|
# restart which stops the firewall if running and then starts it.
|
||||||
echo -n $"Restarting Shorewall: "
|
printf $"Restarting Shorewall: "
|
||||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
|
@@ -69,7 +69,7 @@ SHOREWALL_INIT_SCRIPT=1
|
|||||||
command="$action"
|
command="$action"
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $STARTOPTIONS
|
exec ${SBINDIR}/shorewall -l $OPTIONS $command $STARTOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
boot() {
|
boot() {
|
||||||
@@ -78,17 +78,17 @@ boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $RESTARTOPTIONS
|
exec ${SBINDIR}/shorewall -l $OPTIONS $command $RESTARTOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $RELOADOPTION
|
exec ${SBINDIR}/shorewall -l $OPTIONS $command $RELOADOPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $STOPOPTIONS
|
exec ${SBINDIR}/shorewall -l $OPTIONS $command $STOPOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
status() {
|
status() {
|
||||||
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $@
|
exec ${SBINDIR}/shorewall -l $OPTIONS $command $@
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@ require()
|
|||||||
#
|
#
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
if [ -f shorewall-lite ]; then
|
if [ -f shorewall-lite.service ]; then
|
||||||
PRODUCT=shorewall-lite
|
PRODUCT=shorewall-lite
|
||||||
Product="Shorewall Lite"
|
Product="Shorewall Lite"
|
||||||
else
|
else
|
||||||
@@ -331,7 +331,6 @@ if [ -n "$DESTDIR" ]; then
|
|||||||
OWNERSHIP=""
|
OWNERSHIP=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make_directory ${DESTDIR}${SBINDIR} 755
|
|
||||||
make_directory ${DESTDIR}${INITDIR} 755
|
make_directory ${DESTDIR}${INITDIR} 755
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -362,9 +361,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for ${SBINDIR}/$PRODUCT
|
# Check for ${SHAREDIR}/$PRODUCT/version
|
||||||
#
|
#
|
||||||
if [ -f ${DESTDIR}${SBINDIR}/$PRODUCT ]; then
|
if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
|
||||||
first_install=""
|
first_install=""
|
||||||
else
|
else
|
||||||
first_install="Yes"
|
first_install="Yes"
|
||||||
@@ -372,17 +371,15 @@ fi
|
|||||||
|
|
||||||
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
|
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
|
||||||
|
|
||||||
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544
|
|
||||||
[ -n "${INITFILE}" ] && make_directory ${DESTDIR}${INITDIR} 755
|
[ -n "${INITFILE}" ] && make_directory ${DESTDIR}${INITDIR} 755
|
||||||
|
|
||||||
echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed
|
# Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed
|
||||||
#
|
#
|
||||||
mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
|
mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
|
||||||
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT
|
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT
|
||||||
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
|
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
|
||||||
|
mkdir -p ${DESTDIR}${SBINDIR}
|
||||||
mkdir -p ${DESTDIR}${VARDIR}
|
mkdir -p ${DESTDIR}${VARDIR}
|
||||||
|
|
||||||
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
|
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
|
||||||
@@ -433,15 +430,6 @@ elif [ $HOST = gentoo ]; then
|
|||||||
# Adjust SUBSYSLOCK path (see https://bugs.gentoo.org/show_bug.cgi?id=459316)
|
# Adjust SUBSYSLOCK path (see https://bugs.gentoo.org/show_bug.cgi?id=459316)
|
||||||
perl -p -w -i -e "s|^SUBSYSLOCK=.*|SUBSYSLOCK=/run/lock/$PRODUCT|;" ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
perl -p -w -i -e "s|^SUBSYSLOCK=.*|SUBSYSLOCK=/run/lock/$PRODUCT|;" ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
|
||||||
# Install the Makefile
|
|
||||||
#
|
|
||||||
install_file Makefile ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile 0600
|
|
||||||
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile
|
|
||||||
[ $SBINDIR = /sbin ] || eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile
|
|
||||||
echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install the default config path file
|
# Install the default config path file
|
||||||
#
|
#
|
||||||
@@ -498,7 +486,7 @@ done
|
|||||||
if [ -d manpages -a -n "$MANDIR" ]; then
|
if [ -d manpages -a -n "$MANDIR" ]; then
|
||||||
cd manpages
|
cd manpages
|
||||||
|
|
||||||
mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
|
mkdir -p ${DESTDIR}${MANDIR}/man5/
|
||||||
|
|
||||||
for f in *.5; do
|
for f in *.5; do
|
||||||
gzip -c $f > $f.gz
|
gzip -c $f > $f.gz
|
||||||
@@ -506,6 +494,8 @@ if [ -d manpages -a -n "$MANDIR" ]; then
|
|||||||
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
mkdir -p ${DESTDIR}${MANDIR}/man8/
|
||||||
|
|
||||||
for f in *.8; do
|
for f in *.8; do
|
||||||
gzip -c $f > $f.gz
|
gzip -c $f > $f.gz
|
||||||
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
|
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
|
||||||
@@ -540,6 +530,11 @@ delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.common
|
|||||||
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.cli
|
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.cli
|
||||||
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/wait4ifup
|
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/wait4ifup
|
||||||
|
|
||||||
|
#
|
||||||
|
# Creatae the symbolic link for the CLI
|
||||||
|
#
|
||||||
|
ln -sf shorewall ${DESTDIR}${SBINDIR}/${PRODUCT}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Note -- not all packages will have the SYSCONFFILE so we need to check for its existance here
|
# Note -- not all packages will have the SYSCONFFILE so we need to check for its existance here
|
||||||
#
|
#
|
||||||
@@ -555,7 +550,6 @@ fi
|
|||||||
|
|
||||||
if [ ${SHAREDIR} != /usr/share ]; then
|
if [ ${SHAREDIR} != /usr/share ]; then
|
||||||
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
|
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
|
||||||
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/$PRODUCT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -45,19 +45,20 @@
|
|||||||
# require Shorewall to be installed.
|
# require Shorewall to be installed.
|
||||||
|
|
||||||
|
|
||||||
g_program=shorewall-lite
|
PRODUCT=shorewall-lite
|
||||||
|
|
||||||
#
|
#
|
||||||
# This is modified by the installer when ${SHAREDIR} != /usr/share
|
# This is modified by the installer when ${SHAREDIR} != /usr/share
|
||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
g_sharedir="$SHAREDIR"/shorewall-lite
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
g_confdir="$CONFDIR"/shorewall-lite
|
|
||||||
g_readrc=1
|
|
||||||
|
|
||||||
. ${SHAREDIR}/shorewall/lib.cli
|
. ${SHAREDIR}/shorewall/lib.cli
|
||||||
. /usr/share/shorewall-lite/configpath
|
|
||||||
|
setup_product_environment
|
||||||
|
|
||||||
|
. ${SHAREDIR}/shorewall-lite/configpath
|
||||||
|
|
||||||
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||||
|
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Shorewall Lite Packet Filtering Firewall Control Program - V4.5
|
|
||||||
#
|
|
||||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014 -
|
|
||||||
# Tom Eastep (teastep@shorewall.net)
|
|
||||||
#
|
|
||||||
# Shorewall documentation is available at http://www.shorewall.net
|
|
||||||
#
|
|
||||||
# This program is part of Shorewall.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by the
|
|
||||||
# Free Software Foundation, either version 2 of the license or, at your
|
|
||||||
# option, any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# For a list of supported commands, type 'shorewall help' or 'shorewall6 help'
|
|
||||||
#
|
|
||||||
################################################################################################
|
|
||||||
PRODUCT=shorewall-lite
|
|
||||||
|
|
||||||
#
|
|
||||||
# This is modified by the installer when ${SHAREDIR} != /usr/share
|
|
||||||
#
|
|
||||||
. /usr/share/shorewall/shorewallrc
|
|
||||||
|
|
||||||
g_program=$PRODUCT
|
|
||||||
g_sharedir="$SHAREDIR"/shorewall-lite
|
|
||||||
g_confdir="$CONFDIR"/shorewall-lite
|
|
||||||
g_readrc=1
|
|
||||||
|
|
||||||
. ${SHAREDIR}/shorewall/lib.cli
|
|
||||||
|
|
||||||
shorewall_cli $@
|
|
@@ -125,7 +125,6 @@ if [ $# -eq 0 ]; then
|
|||||||
. ./shorewallrc
|
. ./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
|
||||||
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#
|
#
|
||||||
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
|
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
|
||||||
#
|
#
|
||||||
|
?require AUDIT_TARGET
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#ACTION SOURCE DEST PROTO DPORT SPORT
|
#ACTION SOURCE DEST PROTO DPORT SPORT
|
||||||
#
|
#
|
@@ -22,8 +22,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
# A_REJECTWITH[([<option>])] where <option> is a valid REJECT option.#
|
# A_REJECT[([<option>])] where <option> is a valid REJECT option.#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
?require AUDIT_TARGET
|
||||||
|
|
||||||
DEFAULTS -
|
DEFAULTS -
|
||||||
|
|
@@ -22,8 +22,9 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
# A_REJECTWITH[([<option>])] where <option> is a valid REJECT option.#
|
# A_REJECT[([<option>])] where <option> is a valid REJECT option.#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
?require AUDIT_TARGET
|
||||||
|
|
||||||
DEFAULTS -
|
DEFAULTS -
|
||||||
|
|
50
Shorewall/Actions/action.BLACKLIST
Normal file
50
Shorewall/Actions/action.BLACKLIST
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#
|
||||||
|
# Shorewall - /usr/share/shorewall/action.BLACKLIST
|
||||||
|
#
|
||||||
|
# This action:
|
||||||
|
#
|
||||||
|
# - Adds the sender to the dynamic blacklist ipset
|
||||||
|
# - Optionally acts on the packet (default is DROP)
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
#
|
||||||
|
# 1 - Action to take after adding the packet. Default is DROP.
|
||||||
|
# Pass -- if you don't want to take any action.
|
||||||
|
# 2 - Timeout for ipset entry. Default is the timeout specified in
|
||||||
|
# DYNAMIC_BLACKLIST or the one specified when the ipset was created.
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
# Note -- This action is defined with the 'section' option, so the first
|
||||||
|
# parameter is always the section name. That means that in the
|
||||||
|
# following text, the first parameter passed in the rule is actually
|
||||||
|
# @2.
|
||||||
|
###############################################################################
|
||||||
|
?if $1 eq 'BLACKLIST'
|
||||||
|
?if $BLACKLIST_LOGLEVEL
|
||||||
|
blacklog
|
||||||
|
?else
|
||||||
|
$BLACKLIST_DISPOSITION
|
||||||
|
?endif
|
||||||
|
?else
|
||||||
|
?if ! "$SW_DBL_IPSET"
|
||||||
|
? error The BLACKLIST action may only be used with ipset-based dynamic blacklisting
|
||||||
|
?endif
|
||||||
|
|
||||||
|
DEFAULTS -,DROP,-
|
||||||
|
#
|
||||||
|
# Add to the blacklist
|
||||||
|
#
|
||||||
|
?if passed(@3)
|
||||||
|
ADD($SW_DBL_IPSET:src:@3)
|
||||||
|
?elsif $SW_DBL_TIMEOUT
|
||||||
|
ADD($SW_DBL_IPSET:src:$SW_DBL_TIMEOUT)
|
||||||
|
?else
|
||||||
|
ADD($SW_DBL_IPSET:src)
|
||||||
|
?endif
|
||||||
|
#
|
||||||
|
# Dispose of the packet if asked
|
||||||
|
#
|
||||||
|
?if passed(@2)
|
||||||
|
@2
|
||||||
|
?endif
|
||||||
|
?endif
|
@@ -20,7 +20,7 @@
|
|||||||
# depending on the setting of the first parameter.
|
# depending on the setting of the first parameter.
|
||||||
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
|
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
|
||||||
# A_ACCEPT depending on the first parameter.
|
# A_ACCEPT depending on the first parameter.
|
||||||
# 5 - Action to take with late UDP replies (UDP source port 53). Default
|
# 5 - Action to take with late DNS replies (UDP source port 53). Default
|
||||||
# is DROP or A_DROP depending on the first parameter.
|
# is DROP or A_DROP depending on the first parameter.
|
||||||
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
|
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
|
||||||
# depending on the first parameter.
|
# depending on the first parameter.
|
@@ -20,7 +20,7 @@
|
|||||||
# depending on the setting of the first parameter.
|
# depending on the setting of the first parameter.
|
||||||
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
|
# 4 - Action to take with required ICMP packets. Default is ACCEPT or
|
||||||
# A_ACCEPT depending on the first parameter.
|
# A_ACCEPT depending on the first parameter.
|
||||||
# 5 - Action to take with late UDP replies (UDP source port 53). Default
|
# 5 - Action to take with late DNS replies (UDP source port 53). Default
|
||||||
# is DROP or A_DROP depending on the first parameter.
|
# is DROP or A_DROP depending on the first parameter.
|
||||||
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
|
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP
|
||||||
# depending on the first parameter.
|
# depending on the first parameter.
|
@@ -1,13 +0,0 @@
|
|||||||
#
|
|
||||||
# Shorewall -- /usr/share/shorewall/macro.blacklist
|
|
||||||
#
|
|
||||||
# This macro handles blacklisting using BLACKLIST_DISPOSITION and BLACKLIST_LOGLEVEL.
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
|
||||||
|
|
||||||
?if $BLACKLIST_LOGLEVEL
|
|
||||||
blacklog
|
|
||||||
?else
|
|
||||||
$BLACKLIST_DISPOSITION
|
|
||||||
?endif
|
|
@@ -1,49 +0,0 @@
|
|||||||
#
|
|
||||||
# Shorewall -- /usr/share/shorewall/macro.Drop
|
|
||||||
#
|
|
||||||
# This macro generates the same rules as the Drop default action
|
|
||||||
# It is used in place of action.Drop when USE_ACTIONS=No.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# Drop net all
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
|
||||||
#
|
|
||||||
# Don't log 'auth' DROP
|
|
||||||
#
|
|
||||||
DROP - - tcp 113
|
|
||||||
#
|
|
||||||
# Drop Broadcasts so they don't clutter up the log
|
|
||||||
# (broadcasts must *not* be rejected).
|
|
||||||
#
|
|
||||||
dropBcast
|
|
||||||
#
|
|
||||||
# ACCEPT critical ICMP types
|
|
||||||
#
|
|
||||||
ACCEPT - - icmp fragmentation-needed
|
|
||||||
ACCEPT - - icmp time-exceeded
|
|
||||||
#
|
|
||||||
# Drop packets that are in the INVALID state -- these are usually ICMP packets
|
|
||||||
# and just confuse people when they appear in the log (these ICMPs cannot be
|
|
||||||
# rejected).
|
|
||||||
#
|
|
||||||
dropInvalid
|
|
||||||
#
|
|
||||||
# Drop Microsoft noise so that it doesn't clutter up the log.
|
|
||||||
#
|
|
||||||
DROP - - udp 135,445
|
|
||||||
DROP - - udp 137:139
|
|
||||||
DROP - - udp 1024: 137
|
|
||||||
DROP - - tcp 135,139,445
|
|
||||||
DROP - - udp 1900
|
|
||||||
#
|
|
||||||
# Drop 'newnotsyn' traffic so that it doesn't get logged.
|
|
||||||
#
|
|
||||||
dropNotSyn
|
|
||||||
#
|
|
||||||
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
|
|
||||||
# the log.
|
|
||||||
#
|
|
||||||
DROP - - udp - 53
|
|
@@ -1,49 +0,0 @@
|
|||||||
#
|
|
||||||
# Shorewall -- /usr/share/shorewall/macro.Reject
|
|
||||||
#
|
|
||||||
# This macro generates the same rules as the Reject default action
|
|
||||||
# It is used in place of action.Reject when USE_ACTIONS=No.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# Reject loc fw
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
|
||||||
#
|
|
||||||
# Don't log 'auth' REJECT
|
|
||||||
#
|
|
||||||
REJECT - - tcp 113
|
|
||||||
#
|
|
||||||
# Drop Broadcasts so they don't clutter up the log
|
|
||||||
# (broadcasts must *not* be rejected).
|
|
||||||
#
|
|
||||||
dropBcast
|
|
||||||
#
|
|
||||||
# ACCEPT critical ICMP types
|
|
||||||
#
|
|
||||||
ACCEPT - - icmp fragmentation-needed
|
|
||||||
ACCEPT - - icmp time-exceeded
|
|
||||||
#
|
|
||||||
# Drop packets that are in the INVALID state -- these are usually ICMP packets
|
|
||||||
# and just confuse people when they appear in the log (these ICMPs cannot be
|
|
||||||
# rejected).
|
|
||||||
#
|
|
||||||
dropInvalid
|
|
||||||
#
|
|
||||||
# Reject Microsoft noise so that it doesn't clutter up the log.
|
|
||||||
#
|
|
||||||
REJECT - - udp 135,445
|
|
||||||
REJECT - - udp 137:139
|
|
||||||
REJECT - - udp 1024: 137
|
|
||||||
REJECT - - tcp 135,139,445
|
|
||||||
DROP - - udp 1900
|
|
||||||
#
|
|
||||||
# Drop 'newnotsyn' traffic so that it doesn't get logged.
|
|
||||||
#
|
|
||||||
dropNotSyn
|
|
||||||
#
|
|
||||||
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
|
|
||||||
# the log.
|
|
||||||
#
|
|
||||||
DROP - - udp - 53
|
|
@@ -1,23 +0,0 @@
|
|||||||
#
|
|
||||||
# Shorewall -- /etc/shorewall/Makefile
|
|
||||||
#
|
|
||||||
# Reload Shorewall if config files are updated.
|
|
||||||
|
|
||||||
SWBIN ?= /sbin/shorewall -q
|
|
||||||
CONFDIR ?= /etc/shorewall
|
|
||||||
SWSTATE ?= $(shell $(SWBIN) show vardir)/firewall
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
$(SWSTATE): $(CONFDIR)/*
|
|
||||||
@$(SWBIN) save >/dev/null; \
|
|
||||||
RESULT=$$($(SWBIN) reload 2>&1); \
|
|
||||||
if [ $$? -eq 0 ]; then \
|
|
||||||
$(SWBIN) save >/dev/null; \
|
|
||||||
else \
|
|
||||||
echo "$${RESULT}" >&2; \
|
|
||||||
false; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -f $(CONFDIR)/*~ $(CONFDIR)/.*~
|
|
@@ -120,7 +120,6 @@ our @EXPORT = ( qw(
|
|||||||
%chain_table
|
%chain_table
|
||||||
%targets
|
%targets
|
||||||
$raw_table
|
$raw_table
|
||||||
$rawpost_table
|
|
||||||
$nat_table
|
$nat_table
|
||||||
$mangle_table
|
$mangle_table
|
||||||
$filter_table
|
$filter_table
|
||||||
@@ -197,7 +196,6 @@ our %EXPORT_TAGS = (
|
|||||||
ensure_mangle_chain
|
ensure_mangle_chain
|
||||||
ensure_nat_chain
|
ensure_nat_chain
|
||||||
ensure_raw_chain
|
ensure_raw_chain
|
||||||
ensure_rawpost_chain
|
|
||||||
new_standard_chain
|
new_standard_chain
|
||||||
new_action_chain
|
new_action_chain
|
||||||
new_builtin_chain
|
new_builtin_chain
|
||||||
@@ -418,7 +416,6 @@ our $VERSION = 'MODULEVERSION';
|
|||||||
#
|
#
|
||||||
our %chain_table;
|
our %chain_table;
|
||||||
our $raw_table;
|
our $raw_table;
|
||||||
our $rawpost_table;
|
|
||||||
our $nat_table;
|
our $nat_table;
|
||||||
our $mangle_table;
|
our $mangle_table;
|
||||||
our $filter_table;
|
our $filter_table;
|
||||||
@@ -759,13 +756,11 @@ sub initialize( $$$ ) {
|
|||||||
( $family, my $hard, $export ) = @_;
|
( $family, my $hard, $export ) = @_;
|
||||||
|
|
||||||
%chain_table = ( raw => {},
|
%chain_table = ( raw => {},
|
||||||
rawpost => {},
|
|
||||||
mangle => {},
|
mangle => {},
|
||||||
nat => {},
|
nat => {},
|
||||||
filter => {} );
|
filter => {} );
|
||||||
|
|
||||||
$raw_table = $chain_table{raw};
|
$raw_table = $chain_table{raw};
|
||||||
$rawpost_table = $chain_table{rawpost};
|
|
||||||
$nat_table = $chain_table{nat};
|
$nat_table = $chain_table{nat};
|
||||||
$mangle_table = $chain_table{mangle};
|
$mangle_table = $chain_table{mangle};
|
||||||
$filter_table = $chain_table{filter};
|
$filter_table = $chain_table{filter};
|
||||||
@@ -810,7 +805,6 @@ sub initialize( $$$ ) {
|
|||||||
DNAT => 1,
|
DNAT => 1,
|
||||||
MASQUERADE => 1,
|
MASQUERADE => 1,
|
||||||
NETMAP => 1,
|
NETMAP => 1,
|
||||||
NFQUEUE => 1,
|
|
||||||
NOTRACK => 1,
|
NOTRACK => 1,
|
||||||
RAWDNAT => 1,
|
RAWDNAT => 1,
|
||||||
REDIRECT => 1,
|
REDIRECT => 1,
|
||||||
@@ -1196,9 +1190,16 @@ sub compatible( $$ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
# Don't combine chains where each specifies '-m policy'
|
# Don't combine chains where each specifies
|
||||||
|
# -m policy
|
||||||
|
# or when one specifies
|
||||||
|
# -m multiport
|
||||||
|
# and the other specifies
|
||||||
|
# --dport or --sport or -m multiport
|
||||||
#
|
#
|
||||||
return ! ( $ref1->{policy} && $ref2->{policy} );
|
return ! ( $ref1->{policy} && $ref2->{policy} ||
|
||||||
|
( ( $ref1->{multiport} && ( $ref2->{dport} || $ref2->{sport} || $ref2->{multiport} ) ) ||
|
||||||
|
( $ref2->{multiport} && ( $ref1->{dport} || $ref1->{sport} ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1218,6 +1219,7 @@ sub merge_rules( $$$ ) {
|
|||||||
if ( exists $fromref->{$option} ) {
|
if ( exists $fromref->{$option} ) {
|
||||||
push( @{$toref->{matches}}, $option ) unless exists $toref->{$option};
|
push( @{$toref->{matches}}, $option ) unless exists $toref->{$option};
|
||||||
$toref->{$option} = $fromref->{$option};
|
$toref->{$option} = $fromref->{$option};
|
||||||
|
$toref->{simple} = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2719,24 +2721,6 @@ sub ensure_accounting_chain( $$$ )
|
|||||||
$chainref->{restricted} = NO_RESTRICT;
|
$chainref->{restricted} = NO_RESTRICT;
|
||||||
$chainref->{ipsec} = $ipsec;
|
$chainref->{ipsec} = $ipsec;
|
||||||
$chainref->{optflags} |= ( DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE ) unless $config{OPTIMIZE_ACCOUNTING};
|
$chainref->{optflags} |= ( DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE ) unless $config{OPTIMIZE_ACCOUNTING};
|
||||||
|
|
||||||
if ( $config{CHAIN_SCRIPTS} ) {
|
|
||||||
unless ( $chain eq 'accounting' ) {
|
|
||||||
my $file = find_file $chain;
|
|
||||||
|
|
||||||
if ( -f $file ) {
|
|
||||||
progress_message "Running $file...";
|
|
||||||
|
|
||||||
my ( $level, $tag ) = ( '', '' );
|
|
||||||
|
|
||||||
unless ( my $return = eval `cat $file` ) {
|
|
||||||
fatal_error "Couldn't parse $file: $@" if $@;
|
|
||||||
fatal_error "Couldn't do $file: $!" unless defined $return;
|
|
||||||
fatal_error "Couldn't run $file" unless $return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$chainref;
|
$chainref;
|
||||||
@@ -2775,14 +2759,6 @@ sub ensure_raw_chain($) {
|
|||||||
$chainref;
|
$chainref;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ensure_rawpost_chain($) {
|
|
||||||
my $chain = $_[0];
|
|
||||||
|
|
||||||
my $chainref = ensure_chain 'rawpost', $chain;
|
|
||||||
$chainref->{referenced} = 1;
|
|
||||||
$chainref;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add a builtin chain
|
# Add a builtin chain
|
||||||
#
|
#
|
||||||
@@ -2981,8 +2957,6 @@ sub initialize_chain_table($) {
|
|||||||
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
|
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_builtin_chain 'rawpost', 'POSTROUTING', 'ACCEPT';
|
|
||||||
|
|
||||||
for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
|
for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
|
||||||
new_builtin_chain 'filter', $chain, 'DROP';
|
new_builtin_chain 'filter', $chain, 'DROP';
|
||||||
}
|
}
|
||||||
@@ -3045,8 +3019,6 @@ sub initialize_chain_table($) {
|
|||||||
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
|
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_builtin_chain 'rawpost', 'POSTROUTING', 'ACCEPT';
|
|
||||||
|
|
||||||
for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
|
for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
|
||||||
new_builtin_chain 'filter', $chain, 'DROP';
|
new_builtin_chain 'filter', $chain, 'DROP';
|
||||||
}
|
}
|
||||||
@@ -3350,7 +3322,7 @@ sub check_optimization( $ ) {
|
|||||||
# When an unreferenced chain is found, it is deleted unless its 'dont_delete' flag is set.
|
# When an unreferenced chain is found, it is deleted unless its 'dont_delete' flag is set.
|
||||||
#
|
#
|
||||||
sub optimize_level0() {
|
sub optimize_level0() {
|
||||||
for my $table ( qw/raw rawpost mangle nat filter/ ) {
|
for my $table ( qw/raw mangle nat filter/ ) {
|
||||||
my $tableref = $chain_table{$table};
|
my $tableref = $chain_table{$table};
|
||||||
next unless $tableref;
|
next unless $tableref;
|
||||||
|
|
||||||
@@ -3600,7 +3572,7 @@ sub optimize_level4( $$ ) {
|
|||||||
if ( my $chains = @chains ) {
|
if ( my $chains = @chains ) {
|
||||||
$passes++;
|
$passes++;
|
||||||
|
|
||||||
progress_message "\n Table $table pass $passes, $chains short chains, level 4b...";
|
progress_message "\n Table $table pass $passes, $chains short chains, level 4c...";
|
||||||
|
|
||||||
for my $chainref ( @chains ) {
|
for my $chainref ( @chains ) {
|
||||||
my $name = $chainref->{name};
|
my $name = $chainref->{name};
|
||||||
@@ -4269,7 +4241,6 @@ sub valid_tables() {
|
|||||||
my @table_list;
|
my @table_list;
|
||||||
|
|
||||||
push @table_list, 'raw' if have_capability( 'RAW_TABLE' );
|
push @table_list, 'raw' if have_capability( 'RAW_TABLE' );
|
||||||
push @table_list, 'rawpost' if have_capability( 'RAWPOST_TABLE' );
|
|
||||||
push @table_list, 'nat' if have_capability( 'NAT_ENABLED' );
|
push @table_list, 'nat' if have_capability( 'NAT_ENABLED' );
|
||||||
push @table_list, 'mangle' if have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
|
push @table_list, 'mangle' if have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
|
||||||
push @table_list, 'filter'; #MUST BE LAST!!!
|
push @table_list, 'filter'; #MUST BE LAST!!!
|
||||||
@@ -7619,7 +7590,7 @@ sub handle_exclusion( $$$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
#
|
#
|
||||||
# Returns the destination interface specified in the rule, if any.
|
# Returns the destination interface specified in the rule, if any.
|
||||||
#
|
#
|
||||||
sub expand_rule( $$$$$$$$$$$$;$ )
|
sub expand_rule1( $$$$$$$$$$$$;$ )
|
||||||
{
|
{
|
||||||
my ($chainref , # Chain
|
my ($chainref , # Chain
|
||||||
$restriction, # Determines what to do with interface names in the SOURCE or DEST
|
$restriction, # Determines what to do with interface names in the SOURCE or DEST
|
||||||
@@ -7636,8 +7607,6 @@ sub expand_rule( $$$$$$$$$$$$;$ )
|
|||||||
$logname, # Name of chain to name in log messages
|
$logname, # Name of chain to name in log messages
|
||||||
) = @_;
|
) = @_;
|
||||||
|
|
||||||
return if $chainref->{complete};
|
|
||||||
|
|
||||||
my ( $iiface, $diface, $inets, $dnets, $iexcl, $dexcl, $onets , $oexcl, $trivialiexcl, $trivialdexcl ) =
|
my ( $iiface, $diface, $inets, $dnets, $iexcl, $dexcl, $onets , $oexcl, $trivialiexcl, $trivialdexcl ) =
|
||||||
( '', '', '', '', '', '', '', '', '', '' );
|
( '', '', '', '', '', '', '', '', '', '' );
|
||||||
my $chain = $actparams{chain} || $chainref->{name};
|
my $chain = $actparams{chain} || $chainref->{name};
|
||||||
@@ -7872,6 +7841,78 @@ sub expand_rule( $$$$$$$$$$$$;$ )
|
|||||||
$diface;
|
$diface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub expand_rule( $$$$$$$$$$$$;$$$ )
|
||||||
|
{
|
||||||
|
my ($chainref , # Chain
|
||||||
|
$restriction, # Determines what to do with interface names in the SOURCE or DEST
|
||||||
|
$prerule, # Matches that go at the front of the rule
|
||||||
|
$rule, # Caller's matches that don't depend on the SOURCE, DEST and ORIGINAL DEST
|
||||||
|
$source, # SOURCE
|
||||||
|
$dest, # DEST
|
||||||
|
$origdest, # ORIGINAL DEST
|
||||||
|
$target, # Target ('-j' part of the rule - may be empty)
|
||||||
|
$loglevel , # Log level (and tag)
|
||||||
|
$disposition, # Primtive part of the target (RETURN, ACCEPT, ...)
|
||||||
|
$exceptionrule,# Caller's matches used in exclusion case
|
||||||
|
$usergenerated,# Rule came from the IP[6]TABLES target
|
||||||
|
$logname, # Name of chain to name in log messages
|
||||||
|
$device, # TC Device Name
|
||||||
|
$classid, # TC Class Id
|
||||||
|
) = @_;
|
||||||
|
|
||||||
|
return if $chainref->{complete};
|
||||||
|
|
||||||
|
my ( @source, @dest );
|
||||||
|
|
||||||
|
$source = '' unless defined $source;
|
||||||
|
$dest = '' unless defined $dest;
|
||||||
|
|
||||||
|
if ( $source =~ /\(.+\)/ ) {
|
||||||
|
@source = split_list3( $source, 'SOURCE' );
|
||||||
|
} else {
|
||||||
|
@source = ( $source );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $dest =~ /\(.+\)/ ) {
|
||||||
|
@dest = split_list3( $dest, 'DEST' );
|
||||||
|
} else {
|
||||||
|
@dest = ( $dest );
|
||||||
|
}
|
||||||
|
|
||||||
|
for $source ( @source ) {
|
||||||
|
if ( $source =~ /^(.+?):\((.+)\)$/ ) {
|
||||||
|
$source = join( ':', $1, $2 );
|
||||||
|
} elsif ( $source =~ /^\((.+)\)$/ ) {
|
||||||
|
$source = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for $dest ( @dest ) {
|
||||||
|
if ( $dest =~ /^(.+?):\((.+)\)$/ ) {
|
||||||
|
$dest = join( ':', $1, $2 );
|
||||||
|
} elsif ( $dest =~ /^\((.+)\)$/ ) {
|
||||||
|
$dest = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( my $result = expand_rule1( $chainref ,
|
||||||
|
$restriction ,
|
||||||
|
$prerule ,
|
||||||
|
$rule ,
|
||||||
|
$source ,
|
||||||
|
$dest ,
|
||||||
|
$origdest ,
|
||||||
|
$target ,
|
||||||
|
$loglevel ,
|
||||||
|
$disposition ,
|
||||||
|
$exceptionrule ,
|
||||||
|
$usergenerated ,
|
||||||
|
$logname ,
|
||||||
|
) ) && $device ) {
|
||||||
|
fatal_error "Class Id $classid is not associated with device $result" if $device ne $result &&( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns true if the passed interface is associated with exactly one zone
|
# Returns true if the passed interface is associated with exactly one zone
|
||||||
#
|
#
|
||||||
@@ -8880,7 +8921,7 @@ sub create_chainlist_reload($) {
|
|||||||
for my $chain ( @chains ) {
|
for my $chain ( @chains ) {
|
||||||
( $table , $chain ) = split ':', $chain if $chain =~ /:/;
|
( $table , $chain ) = split ':', $chain if $chain =~ /:/;
|
||||||
|
|
||||||
fatal_error "Invalid table ( $table )" unless $table =~ /^(nat|mangle|filter|raw|rawpost)$/;
|
fatal_error "Invalid table ( $table )" unless $table =~ /^(nat|mangle|filter|raw)$/;
|
||||||
|
|
||||||
$chains{$table} = {} unless $chains{$table};
|
$chains{$table} = {} unless $chains{$table};
|
||||||
|
|
||||||
@@ -8909,7 +8950,7 @@ sub create_chainlist_reload($) {
|
|||||||
|
|
||||||
enter_cat_mode;
|
enter_cat_mode;
|
||||||
|
|
||||||
for $table ( qw(raw rawpost nat mangle filter) ) {
|
for $table ( qw(raw nat mangle filter) ) {
|
||||||
my $tableref=$chains{$table};
|
my $tableref=$chains{$table};
|
||||||
|
|
||||||
next unless $tableref;
|
next unless $tableref;
|
||||||
|
@@ -701,7 +701,7 @@ sub compiler {
|
|||||||
#
|
#
|
||||||
# Allow user to load Perl modules
|
# Allow user to load Perl modules
|
||||||
#
|
#
|
||||||
run_user_exit1 'compile';
|
run_user_exit 'compile';
|
||||||
#
|
#
|
||||||
# Create a temp file to hold the script
|
# Create a temp file to hold the script
|
||||||
#
|
#
|
||||||
|
@@ -130,9 +130,11 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
|||||||
split_list
|
split_list
|
||||||
split_list1
|
split_list1
|
||||||
split_list2
|
split_list2
|
||||||
|
split_list3
|
||||||
split_line
|
split_line
|
||||||
split_line1
|
split_line1
|
||||||
split_line2
|
split_line2
|
||||||
|
split_rawline2
|
||||||
first_entry
|
first_entry
|
||||||
open_file
|
open_file
|
||||||
close_file
|
close_file
|
||||||
@@ -153,8 +155,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
|||||||
propagateconfig
|
propagateconfig
|
||||||
append_file
|
append_file
|
||||||
run_user_exit
|
run_user_exit
|
||||||
run_user_exit1
|
|
||||||
run_user_exit2
|
|
||||||
generate_aux_config
|
generate_aux_config
|
||||||
format_warning
|
format_warning
|
||||||
no_comment
|
no_comment
|
||||||
@@ -174,6 +174,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
|||||||
$doing
|
$doing
|
||||||
$done
|
$done
|
||||||
$currentline
|
$currentline
|
||||||
|
$rawcurrentline
|
||||||
$currentfilename
|
$currentfilename
|
||||||
$debug
|
$debug
|
||||||
$file_format
|
$file_format
|
||||||
@@ -388,7 +389,6 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
|||||||
HEADER_MATCH => 'Header Match',
|
HEADER_MATCH => 'Header Match',
|
||||||
ACCOUNT_TARGET => 'ACCOUNT Target',
|
ACCOUNT_TARGET => 'ACCOUNT Target',
|
||||||
AUDIT_TARGET => 'AUDIT Target',
|
AUDIT_TARGET => 'AUDIT Target',
|
||||||
RAWPOST_TABLE => 'Rawpost Table',
|
|
||||||
CONDITION_MATCH => 'Condition Match',
|
CONDITION_MATCH => 'Condition Match',
|
||||||
IPTABLES_S => 'iptables -S',
|
IPTABLES_S => 'iptables -S',
|
||||||
BASIC_FILTER => 'Basic Filter',
|
BASIC_FILTER => 'Basic Filter',
|
||||||
@@ -411,6 +411,8 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
|||||||
IFACE_MATCH => 'Iface Match',
|
IFACE_MATCH => 'Iface Match',
|
||||||
TCPMSS_TARGET => 'TCPMSS Target',
|
TCPMSS_TARGET => 'TCPMSS Target',
|
||||||
WAIT_OPTION => 'iptables --wait option',
|
WAIT_OPTION => 'iptables --wait option',
|
||||||
|
CPU_FANOUT => 'NFQUEUE CPU Fanout',
|
||||||
|
NETMAP_TARGET => 'NETMAP Target',
|
||||||
|
|
||||||
AMANDA_HELPER => 'Amanda Helper',
|
AMANDA_HELPER => 'Amanda Helper',
|
||||||
FTP_HELPER => 'FTP Helper',
|
FTP_HELPER => 'FTP Helper',
|
||||||
@@ -564,6 +566,7 @@ our $usedcaller;
|
|||||||
our $inline_matches;
|
our $inline_matches;
|
||||||
|
|
||||||
our $currentline; # Current config file line image
|
our $currentline; # Current config file line image
|
||||||
|
our $rawcurrentline; # Current config file line with no variable expansion
|
||||||
our $currentfile; # File handle reference
|
our $currentfile; # File handle reference
|
||||||
our $currentfilename; # File NAME
|
our $currentfilename; # File NAME
|
||||||
our $currentlinenumber; # Line number
|
our $currentlinenumber; # Line number
|
||||||
@@ -640,6 +643,7 @@ our %eliminated = ( LOGRATE => 1,
|
|||||||
WIDE_TC_MARKS => 1,
|
WIDE_TC_MARKS => 1,
|
||||||
HIGH_ROUTE_MARKS => 1,
|
HIGH_ROUTE_MARKS => 1,
|
||||||
BLACKLISTNEWONLY => 1,
|
BLACKLISTNEWONLY => 1,
|
||||||
|
CHAIN_SCRIPTS => 1,
|
||||||
);
|
);
|
||||||
#
|
#
|
||||||
# Variables involved in ?IF, ?ELSE ?ENDIF processing
|
# Variables involved in ?IF, ?ELSE ?ENDIF processing
|
||||||
@@ -744,8 +748,8 @@ sub initialize( $;$$) {
|
|||||||
TC_SCRIPT => '',
|
TC_SCRIPT => '',
|
||||||
EXPORT => 0,
|
EXPORT => 0,
|
||||||
KLUDGEFREE => '',
|
KLUDGEFREE => '',
|
||||||
VERSION => "5.0.9-Beta2",
|
VERSION => "5.1.1-RC1",
|
||||||
CAPVERSION => 50004 ,
|
CAPVERSION => 50100 ,
|
||||||
BLACKLIST_LOG_TAG => '',
|
BLACKLIST_LOG_TAG => '',
|
||||||
RELATED_LOG_TAG => '',
|
RELATED_LOG_TAG => '',
|
||||||
MACLIST_LOG_TAG => '',
|
MACLIST_LOG_TAG => '',
|
||||||
@@ -812,6 +816,7 @@ sub initialize( $;$$) {
|
|||||||
ACCEPT_DEFAULT => undef,
|
ACCEPT_DEFAULT => undef,
|
||||||
QUEUE_DEFAULT => undef,
|
QUEUE_DEFAULT => undef,
|
||||||
NFQUEUE_DEFAULT => undef,
|
NFQUEUE_DEFAULT => undef,
|
||||||
|
BLACKLIST_DEFAULT => undef,
|
||||||
#
|
#
|
||||||
# RSH/RCP Commands
|
# RSH/RCP Commands
|
||||||
#
|
#
|
||||||
@@ -887,7 +892,6 @@ sub initialize( $;$$) {
|
|||||||
WARNOLDCAPVERSION => undef,
|
WARNOLDCAPVERSION => undef,
|
||||||
DEFER_DNS_RESOLUTION => undef,
|
DEFER_DNS_RESOLUTION => undef,
|
||||||
USE_RT_NAMES => undef,
|
USE_RT_NAMES => undef,
|
||||||
CHAIN_SCRIPTS => undef,
|
|
||||||
TRACK_RULES => undef,
|
TRACK_RULES => undef,
|
||||||
REJECT_ACTION => undef,
|
REJECT_ACTION => undef,
|
||||||
INLINE_MATCHES => undef,
|
INLINE_MATCHES => undef,
|
||||||
@@ -901,6 +905,7 @@ sub initialize( $;$$) {
|
|||||||
VERBOSE_MESSAGES => undef ,
|
VERBOSE_MESSAGES => undef ,
|
||||||
ZERO_MARKS => undef ,
|
ZERO_MARKS => undef ,
|
||||||
FIREWALL => undef ,
|
FIREWALL => undef ,
|
||||||
|
BALANCE_PROVIDERS => undef ,
|
||||||
#
|
#
|
||||||
# Packet Disposition
|
# Packet Disposition
|
||||||
#
|
#
|
||||||
@@ -977,7 +982,6 @@ sub initialize( $;$$) {
|
|||||||
CONNMARK_MATCH => undef,
|
CONNMARK_MATCH => undef,
|
||||||
XCONNMARK_MATCH => undef,
|
XCONNMARK_MATCH => undef,
|
||||||
RAW_TABLE => undef,
|
RAW_TABLE => undef,
|
||||||
RAWPOST_TABLE => undef,
|
|
||||||
IPP2P_MATCH => undef,
|
IPP2P_MATCH => undef,
|
||||||
OLD_IPP2P_MATCH => undef,
|
OLD_IPP2P_MATCH => undef,
|
||||||
CLASSIFY_TARGET => undef,
|
CLASSIFY_TARGET => undef,
|
||||||
@@ -1033,6 +1037,8 @@ sub initialize( $;$$) {
|
|||||||
IFACE_MATCH => undef,
|
IFACE_MATCH => undef,
|
||||||
TCPMSS_TARGET => undef,
|
TCPMSS_TARGET => undef,
|
||||||
WAIT_OPTION => undef,
|
WAIT_OPTION => undef,
|
||||||
|
CPU_FANOUT => undef,
|
||||||
|
NETMAP_TARGET => undef,
|
||||||
|
|
||||||
AMANDA_HELPER => undef,
|
AMANDA_HELPER => undef,
|
||||||
FTP_HELPER => undef,
|
FTP_HELPER => undef,
|
||||||
@@ -1997,6 +2003,21 @@ sub find_writable_file($) {
|
|||||||
"$config_path[0]$filename";
|
"$config_path[0]$filename";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Determine if a value has been supplied
|
||||||
|
#
|
||||||
|
sub supplied( $ ) {
|
||||||
|
my $val = shift;
|
||||||
|
|
||||||
|
defined $val && $val ne '';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub passed( $ ) {
|
||||||
|
my $val = shift;
|
||||||
|
|
||||||
|
defined $val && $val ne '' && $val ne '-';
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Split a comma-separated list into a Perl array
|
# Split a comma-separated list into a Perl array
|
||||||
#
|
#
|
||||||
@@ -2055,7 +2076,7 @@ sub split_list1( $$;$ ) {
|
|||||||
sub split_list2( $$ ) {
|
sub split_list2( $$ ) {
|
||||||
my ($list, $type ) = @_;
|
my ($list, $type ) = @_;
|
||||||
|
|
||||||
fatal_error "Invalid $type ($list)" if $list =~ /^:|::/;
|
fatal_error "Invalid $type ($list)" if $list =~ /^:/;
|
||||||
|
|
||||||
my @list1 = split /:/, $list;
|
my @list1 = split /:/, $list;
|
||||||
my @list2;
|
my @list2;
|
||||||
@@ -2092,6 +2113,7 @@ sub split_list2( $$ ) {
|
|||||||
fatal_error "Invalid $type ($list)" if $opencount < 0;
|
fatal_error "Invalid $type ($list)" if $opencount < 0;
|
||||||
}
|
}
|
||||||
} elsif ( $element eq '' ) {
|
} elsif ( $element eq '' ) {
|
||||||
|
fatal_error "Invalid $type ($list)" unless supplied $_;
|
||||||
push @list2 , $_;
|
push @list2 , $_;
|
||||||
} else {
|
} else {
|
||||||
$element = join ':', $element , $_;
|
$element = join ':', $element , $_;
|
||||||
@@ -2257,21 +2279,6 @@ sub split_columns( $ ) {
|
|||||||
@list2;
|
@list2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Determine if a value has been supplied
|
|
||||||
#
|
|
||||||
sub supplied( $ ) {
|
|
||||||
my $val = shift;
|
|
||||||
|
|
||||||
defined $val && $val ne '';
|
|
||||||
}
|
|
||||||
|
|
||||||
sub passed( $ ) {
|
|
||||||
my $val = shift;
|
|
||||||
|
|
||||||
defined $val && $val ne '' && $val ne '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
sub clear_comment();
|
sub clear_comment();
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -2442,6 +2449,25 @@ sub split_line2( $$;$$$ ) {
|
|||||||
@line;
|
@line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Same as above, only it splits the raw current line
|
||||||
|
#
|
||||||
|
sub split_rawline2( $$;$$$ ) {
|
||||||
|
my $savecurrentline = $currentline;
|
||||||
|
|
||||||
|
$currentline = $rawcurrentline;
|
||||||
|
#
|
||||||
|
# Delete trailing comment
|
||||||
|
#
|
||||||
|
$currentline =~ s/\s*#.*//;
|
||||||
|
|
||||||
|
my @result = &split_line2( @_ );
|
||||||
|
|
||||||
|
$currentline = $savecurrentline;
|
||||||
|
|
||||||
|
@result;
|
||||||
|
}
|
||||||
|
|
||||||
sub split_line1( $$;$$ ) {
|
sub split_line1( $$;$$ ) {
|
||||||
&split_line2( @_, undef );
|
&split_line2( @_, undef );
|
||||||
}
|
}
|
||||||
@@ -2686,13 +2712,13 @@ sub directive_info( $$$$ ) {
|
|||||||
# Add quotes to the passed value if the passed 'first part' has an odd number of quotes
|
# Add quotes to the passed value if the passed 'first part' has an odd number of quotes
|
||||||
# Return an expression that concatenates $first, $val and $rest
|
# Return an expression that concatenates $first, $val and $rest
|
||||||
#
|
#
|
||||||
sub join_parts( $$$ ) {
|
sub join_parts( $$$$ ) {
|
||||||
my ( $first, $val, $rest ) = @_;
|
my ( $first, $val, $rest, $just_expand ) = @_;
|
||||||
|
|
||||||
$val = '' unless defined $val;
|
$val = '' unless defined $val;
|
||||||
$val = "'$val'" unless ( $val =~ /^-?\d+$/ || # Value is numeric
|
$val = "'$val'" unless $just_expand || ( $val =~ /^-?\d+$/ || # Value is numeric
|
||||||
( ( ( $first =~ tr/"/"/ ) & 1 ) || # There are an odd number of double quotes preceding the value
|
( ( ( $first =~ tr/"/"/ ) & 1 ) || # There are an odd number of double quotes preceding the value
|
||||||
( ( $first =~ tr/'/'/ ) & 1 ) ) ); # There are an odd number of single quotes preceding the value
|
( ( $first =~ tr/'/'/ ) & 1 ) ) ); # There are an odd number of single quotes preceding the value
|
||||||
join( '', $first, $val, $rest );
|
join( '', $first, $val, $rest );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2745,7 +2771,7 @@ sub evaluate_expression( $$$$ ) {
|
|||||||
exists $capdesc{$var} ? have_capability( $var ) : '' );
|
exists $capdesc{$var} ? have_capability( $var ) : '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$expression = join_parts( $first, $val, $rest );
|
$expression = join_parts( $first, $val, $rest, $just_expand );
|
||||||
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
|
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2756,7 +2782,7 @@ sub evaluate_expression( $$$$ ) {
|
|||||||
$var = numeric_value( $var ) if $var =~ /^\d/;
|
$var = numeric_value( $var ) if $var =~ /^\d/;
|
||||||
$val = $var ? $actparams{$var} : $chain;
|
$val = $var ? $actparams{$var} : $chain;
|
||||||
$usedcaller = USEDCALLER if $var eq 'caller';
|
$usedcaller = USEDCALLER if $var eq 'caller';
|
||||||
$expression = join_parts( $first, $val, $rest );
|
$expression = join_parts( $first, $val, $rest , $just_expand );
|
||||||
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
|
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2828,7 +2854,7 @@ sub process_compiler_directive( $$$$ ) {
|
|||||||
|
|
||||||
print "CD===> $line\n" if $debug;
|
print "CD===> $line\n" if $debug;
|
||||||
|
|
||||||
directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+|WARNING\s+|INFO\s+|WARNING!\s+|INFO!\s+)(.*)$/i;
|
directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+|WARNING\s+|INFO\s+|WARNING!\s+|INFO!\s+|REQUIRE\s+)(.*)$/i;
|
||||||
|
|
||||||
my ($keyword, $expression) = ( uc $1, $2 );
|
my ($keyword, $expression) = ( uc $1, $2 );
|
||||||
|
|
||||||
@@ -3016,6 +3042,12 @@ sub process_compiler_directive( $$$$ ) {
|
|||||||
$linenumber ) unless $omitting;
|
$linenumber ) unless $omitting;
|
||||||
} ,
|
} ,
|
||||||
|
|
||||||
|
REQUIRE => sub() {
|
||||||
|
fatal_error "?REQUIRE may only be used within action files" unless $actparams{0};
|
||||||
|
fatal_error "Unknown capability ($expression}" unless $capabilities{$expression};
|
||||||
|
require_capability( $expression, "The $actparams{action} action", 's' );
|
||||||
|
} ,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( my $function = $directives{$keyword} ) {
|
if ( my $function = $directives{$keyword} ) {
|
||||||
@@ -3026,9 +3058,9 @@ sub process_compiler_directive( $$$$ ) {
|
|||||||
|
|
||||||
if ( $directive_callback ) {
|
if ( $directive_callback ) {
|
||||||
$directive_callback->( $keyword, $line )
|
$directive_callback->( $keyword, $line )
|
||||||
} else {
|
|
||||||
$omitting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$omitting;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -3729,13 +3761,14 @@ sub read_a_line($) {
|
|||||||
#
|
#
|
||||||
# Handle directives
|
# Handle directives
|
||||||
#
|
#
|
||||||
if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR|WARNING|INFO)/i ) {
|
if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR|WARNING|INFO|REQUIRE)/i ) {
|
||||||
$omitting = process_compiler_directive( $omitting, $_, $currentfilename, $. );
|
$omitting = process_compiler_directive( $omitting, $_, $currentfilename, $. );
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $omitting ) {
|
if ( $omitting ) {
|
||||||
print "OMIT=> $_\n" if $debug;
|
print "OMIT=> $_\n" if $debug;
|
||||||
|
$directive_callback->( 'OMITTED', $_ ) if ( $directive_callback );
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3790,6 +3823,10 @@ sub read_a_line($) {
|
|||||||
#
|
#
|
||||||
handle_first_entry if $first_entry;
|
handle_first_entry if $first_entry;
|
||||||
#
|
#
|
||||||
|
# Save Raw Image
|
||||||
|
#
|
||||||
|
$rawcurrentline = $currentline;
|
||||||
|
#
|
||||||
# Expand Shell Variables using %params and %actparams
|
# Expand Shell Variables using %params and %actparams
|
||||||
#
|
#
|
||||||
expand_variables( $currentline ) if $options & EXPAND_VARIABLES;
|
expand_variables( $currentline ) if $options & EXPAND_VARIABLES;
|
||||||
@@ -3818,7 +3855,7 @@ sub read_a_line($) {
|
|||||||
fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/;
|
fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/;
|
||||||
fatal_error "This file does not allow ?SECTION" unless $section_function;
|
fatal_error "This file does not allow ?SECTION" unless $section_function;
|
||||||
$section_function->($sectionname);
|
$section_function->($sectionname);
|
||||||
$directive_callback->( 'SECTION', $currentline ) if $directive_callback;
|
$directive_callback->( 'SECTION', $rawcurrentline ) if $directive_callback;
|
||||||
next LINE;
|
next LINE;
|
||||||
} else {
|
} else {
|
||||||
fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/;
|
fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/;
|
||||||
@@ -4290,6 +4327,22 @@ sub Masquerade_Tgt() {
|
|||||||
$result;
|
$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub Netmap_Target() {
|
||||||
|
have_capability( 'NAT_ENABLED' ) || return '';
|
||||||
|
|
||||||
|
my $result = '';
|
||||||
|
my $address = $family == F_IPV4 ? '1.2.3.0/24' : '2001::/64';
|
||||||
|
|
||||||
|
if ( qt1( "$iptables $iptablesw -t nat -N $sillyname" ) ) {
|
||||||
|
$result = qt1( "$iptables $iptablesw -t nat -A $sillyname -j NETMAP --to $address" );
|
||||||
|
qt1( "$iptables $iptablesw -t nat -F $sillyname" );
|
||||||
|
qt1( "$iptables $iptablesw -t nat -X $sillyname" );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$result;
|
||||||
|
}
|
||||||
|
|
||||||
sub Udpliteredirect() {
|
sub Udpliteredirect() {
|
||||||
have_capability( 'NAT_ENABLED' ) || return '';
|
have_capability( 'NAT_ENABLED' ) || return '';
|
||||||
|
|
||||||
@@ -4488,10 +4541,6 @@ sub Raw_Table() {
|
|||||||
qt1( "$iptables $iptablesw -t raw -L -n" );
|
qt1( "$iptables $iptablesw -t raw -L -n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub Rawpost_Table() {
|
|
||||||
qt1( "$iptables $iptablesw -t rawpost -L -n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
sub Old_IPSet_Match() {
|
sub Old_IPSet_Match() {
|
||||||
my $ipset = $config{IPSET} || 'ipset';
|
my $ipset = $config{IPSET} || 'ipset';
|
||||||
my $result = 0;
|
my $result = 0;
|
||||||
@@ -4819,6 +4868,10 @@ sub Tcpmss_Target() {
|
|||||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
|
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub Cpu_Fanout() {
|
||||||
|
have_capability( 'NFQUEUE_TARGET' ) && qt1( "$iptables -A $sillyname -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout" );
|
||||||
|
}
|
||||||
|
|
||||||
our %detect_capability =
|
our %detect_capability =
|
||||||
( ACCOUNT_TARGET =>\&Account_Target,
|
( ACCOUNT_TARGET =>\&Account_Target,
|
||||||
AMANDA_HELPER => \&Amanda_Helper,
|
AMANDA_HELPER => \&Amanda_Helper,
|
||||||
@@ -4835,6 +4888,7 @@ our %detect_capability =
|
|||||||
CONNMARK => \&Connmark,
|
CONNMARK => \&Connmark,
|
||||||
CONNMARK_MATCH => \&Connmark_Match,
|
CONNMARK_MATCH => \&Connmark_Match,
|
||||||
CONNTRACK_MATCH => \&Conntrack_Match,
|
CONNTRACK_MATCH => \&Conntrack_Match,
|
||||||
|
CPU_FANOUT => \&Cpu_Fanout,
|
||||||
CT_TARGET => \&Ct_Target,
|
CT_TARGET => \&Ct_Target,
|
||||||
DSCP_MATCH => \&Dscp_Match,
|
DSCP_MATCH => \&Dscp_Match,
|
||||||
DSCP_TARGET => \&Dscp_Target,
|
DSCP_TARGET => \&Dscp_Target,
|
||||||
@@ -4878,6 +4932,7 @@ our %detect_capability =
|
|||||||
MULTIPORT => \&Multiport,
|
MULTIPORT => \&Multiport,
|
||||||
NAT_ENABLED => \&Nat_Enabled,
|
NAT_ENABLED => \&Nat_Enabled,
|
||||||
NETBIOS_NS_HELPER => \&Netbios_ns_Helper,
|
NETBIOS_NS_HELPER => \&Netbios_ns_Helper,
|
||||||
|
NETMAP_TARGET => \&Netmap_Target,
|
||||||
NEW_CONNTRACK_MATCH => \&New_Conntrack_Match,
|
NEW_CONNTRACK_MATCH => \&New_Conntrack_Match,
|
||||||
NFACCT_MATCH => \&NFAcct_Match,
|
NFACCT_MATCH => \&NFAcct_Match,
|
||||||
NFQUEUE_TARGET => \&Nfqueue_Target,
|
NFQUEUE_TARGET => \&Nfqueue_Target,
|
||||||
@@ -4893,7 +4948,6 @@ our %detect_capability =
|
|||||||
POLICY_MATCH => \&Policy_Match,
|
POLICY_MATCH => \&Policy_Match,
|
||||||
PPTP_HELPER => \&PPTP_Helper,
|
PPTP_HELPER => \&PPTP_Helper,
|
||||||
RAW_TABLE => \&Raw_Table,
|
RAW_TABLE => \&Raw_Table,
|
||||||
RAWPOST_TABLE => \&Rawpost_Table,
|
|
||||||
REALM_MATCH => \&Realm_Match,
|
REALM_MATCH => \&Realm_Match,
|
||||||
REAP_OPTION => \&Reap_Option,
|
REAP_OPTION => \&Reap_Option,
|
||||||
RECENT_MATCH => \&Recent_Match,
|
RECENT_MATCH => \&Recent_Match,
|
||||||
@@ -5021,7 +5075,6 @@ sub determine_capabilities() {
|
|||||||
$capabilities{TPROXY_TARGET} = detect_capability( 'TPROXY_TARGET' );
|
$capabilities{TPROXY_TARGET} = detect_capability( 'TPROXY_TARGET' );
|
||||||
$capabilities{MANGLE_FORWARD} = detect_capability( 'MANGLE_FORWARD' );
|
$capabilities{MANGLE_FORWARD} = detect_capability( 'MANGLE_FORWARD' );
|
||||||
$capabilities{RAW_TABLE} = detect_capability( 'RAW_TABLE' );
|
$capabilities{RAW_TABLE} = detect_capability( 'RAW_TABLE' );
|
||||||
$capabilities{RAWPOST_TABLE} = detect_capability( 'RAWPOST_TABLE' );
|
|
||||||
$capabilities{IPSET_MATCH} = detect_capability( 'IPSET_MATCH' );
|
$capabilities{IPSET_MATCH} = detect_capability( 'IPSET_MATCH' );
|
||||||
$capabilities{USEPKTTYPE} = detect_capability( 'USEPKTTYPE' );
|
$capabilities{USEPKTTYPE} = detect_capability( 'USEPKTTYPE' );
|
||||||
$capabilities{ADDRTYPE} = detect_capability( 'ADDRTYPE' );
|
$capabilities{ADDRTYPE} = detect_capability( 'ADDRTYPE' );
|
||||||
@@ -5062,6 +5115,8 @@ sub determine_capabilities() {
|
|||||||
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
|
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
|
||||||
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
|
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
|
||||||
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
|
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
|
||||||
|
$capabilities{CPU_FANOUT} = detect_capability( 'CPU_FANOUT' );
|
||||||
|
$capabilities{NETMAP_TARGET} = detect_capability( 'NETMAP_TARGET' );
|
||||||
|
|
||||||
unless ( have_capability 'CT_TARGET' ) {
|
unless ( have_capability 'CT_TARGET' ) {
|
||||||
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
|
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
|
||||||
@@ -5232,9 +5287,18 @@ sub update_config_file( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_default( 'USE_DEFAULT_RT', 'No' );
|
update_default( 'USE_DEFAULT_RT', 'No' );
|
||||||
|
|
||||||
|
if ( $config{USE_DEFAULT_RT} eq '' || $config{USE_DEFAULT_RT} =~ /^no$/i ) {
|
||||||
|
update_default( 'BALANCE_PROVIDERS', 'No' );
|
||||||
|
} else {
|
||||||
|
update_default( 'BALANCE_PROVIDERS', 'Yes' );
|
||||||
|
}
|
||||||
|
|
||||||
update_default( 'EXPORTMODULES', 'No' );
|
update_default( 'EXPORTMODULES', 'No' );
|
||||||
update_default( 'RESTART', 'reload' );
|
update_default( 'RESTART', 'reload' );
|
||||||
update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} );
|
update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} );
|
||||||
|
update_default( 'LOGFORMAT', 'Shorewall:%s:%s:' );
|
||||||
|
update_default( 'LOGLIMIT', '' );
|
||||||
|
|
||||||
my $fn;
|
my $fn;
|
||||||
|
|
||||||
@@ -6183,7 +6247,6 @@ sub get_configuration( $$$$ ) {
|
|||||||
default_yes_no 'AUTOCOMMENT' , 'Yes';
|
default_yes_no 'AUTOCOMMENT' , 'Yes';
|
||||||
default_yes_no 'MULTICAST' , '';
|
default_yes_no 'MULTICAST' , '';
|
||||||
default_yes_no 'MARK_IN_FORWARD_CHAIN' , '';
|
default_yes_no 'MARK_IN_FORWARD_CHAIN' , '';
|
||||||
default_yes_no 'CHAIN_SCRIPTS' , 'Yes';
|
|
||||||
|
|
||||||
if ( supplied ( $val = $config{TRACK_RULES} ) ) {
|
if ( supplied ( $val = $config{TRACK_RULES} ) ) {
|
||||||
if ( lc( $val ) eq 'file' ) {
|
if ( lc( $val ) eq 'file' ) {
|
||||||
@@ -6238,6 +6301,7 @@ sub get_configuration( $$$$ ) {
|
|||||||
default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes';
|
default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes';
|
||||||
default_yes_no 'AUTOMAKE' , '';
|
default_yes_no 'AUTOMAKE' , '';
|
||||||
default_yes_no 'TRACK_PROVIDERS' , '';
|
default_yes_no 'TRACK_PROVIDERS' , '';
|
||||||
|
default_yes_no 'BALANCE_PROVIDERS' , $config{USE_DEFAULT_RT} ? 'Yes' : '';
|
||||||
|
|
||||||
unless ( ( $config{NULL_ROUTE_RFC1918} || '' ) =~ /^(?:blackhole|unreachable|prohibit)$/ ) {
|
unless ( ( $config{NULL_ROUTE_RFC1918} || '' ) =~ /^(?:blackhole|unreachable|prohibit)$/ ) {
|
||||||
default_yes_no( 'NULL_ROUTE_RFC1918', '' );
|
default_yes_no( 'NULL_ROUTE_RFC1918', '' );
|
||||||
@@ -6254,6 +6318,8 @@ sub get_configuration( $$$$ ) {
|
|||||||
$config{ACCOUNTING_TABLE} = 'filter';
|
$config{ACCOUNTING_TABLE} = 'filter';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my %variables = ( SW_DBL_IPSET => '', SW_DBL_TIMEOUT => 0 );
|
||||||
|
|
||||||
if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) {
|
if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) {
|
||||||
if ( $val =~ /^ipset/ ) {
|
if ( $val =~ /^ipset/ ) {
|
||||||
my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 );
|
my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 );
|
||||||
@@ -6294,6 +6360,9 @@ sub get_configuration( $$$$ ) {
|
|||||||
|
|
||||||
require_capability( 'IPSET_V5', 'DYNAMIC_BLACKLIST=ipset...', 's' );
|
require_capability( 'IPSET_V5', 'DYNAMIC_BLACKLIST=ipset...', 's' );
|
||||||
|
|
||||||
|
$variables{SW_DBL_IPSET} = $set;
|
||||||
|
$variables{SW_DBL_TIMEOUT} = $globals{DBL_TIMEOUT};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
|
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
|
||||||
}
|
}
|
||||||
@@ -6301,6 +6370,8 @@ sub get_configuration( $$$$ ) {
|
|||||||
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
|
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_variables( %variables );
|
||||||
|
|
||||||
default_yes_no 'REQUIRE_INTERFACE' , '';
|
default_yes_no 'REQUIRE_INTERFACE' , '';
|
||||||
default_yes_no 'FORWARD_CLEAR_MARK' , have_capability( 'MARK' ) ? 'Yes' : '';
|
default_yes_no 'FORWARD_CLEAR_MARK' , have_capability( 'MARK' ) ? 'Yes' : '';
|
||||||
default_yes_no 'COMPLETE' , '';
|
default_yes_no 'COMPLETE' , '';
|
||||||
@@ -6568,11 +6639,12 @@ sub get_configuration( $$$$ ) {
|
|||||||
default 'RESTOREFILE' , 'restore';
|
default 'RESTOREFILE' , 'restore';
|
||||||
default 'DROP_DEFAULT' , 'Drop';
|
default 'DROP_DEFAULT' , 'Drop';
|
||||||
default 'REJECT_DEFAULT' , 'Reject';
|
default 'REJECT_DEFAULT' , 'Reject';
|
||||||
|
default 'BLACKLIST_DEFAULT' , 'Drop';
|
||||||
default 'QUEUE_DEFAULT' , 'none';
|
default 'QUEUE_DEFAULT' , 'none';
|
||||||
default 'NFQUEUE_DEFAULT' , 'none';
|
default 'NFQUEUE_DEFAULT' , 'none';
|
||||||
default 'ACCEPT_DEFAULT' , 'none';
|
default 'ACCEPT_DEFAULT' , 'none';
|
||||||
|
|
||||||
for my $default ( qw/DROP_DEFAULT REJECT_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT ACCEPT_DEFAULT/ ) {
|
for my $default ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT ACCEPT_DEFAULT/ ) {
|
||||||
$config{$default} = 'none' if "\L$config{$default}" eq 'none';
|
$config{$default} = 'none' if "\L$config{$default}" eq 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6700,32 +6772,7 @@ sub append_file( $;$$ ) {
|
|||||||
$result;
|
$result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Run a Perl extension script
|
|
||||||
#
|
|
||||||
sub run_user_exit( $ ) {
|
sub run_user_exit( $ ) {
|
||||||
my $chainref = $_[0];
|
|
||||||
my $file = find_file $chainref->{name};
|
|
||||||
|
|
||||||
if ( $config{CHAIN_SCRIPTS} && -f $file ) {
|
|
||||||
progress_message2 "Running $file...";
|
|
||||||
|
|
||||||
my $command = qq(package Shorewall::User;\nno strict;\n# line 1 "$file"\n) . `cat $file`;
|
|
||||||
|
|
||||||
unless (my $return = eval $command ) {
|
|
||||||
fatal_error "Couldn't parse $file: $@" if $@;
|
|
||||||
|
|
||||||
unless ( defined $return ) {
|
|
||||||
fatal_error "Couldn't do $file: $!" if $!;
|
|
||||||
fatal_error "Couldn't do $file";
|
|
||||||
}
|
|
||||||
|
|
||||||
fatal_error "$file returned a false value";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run_user_exit1( $ ) {
|
|
||||||
my $file = find_file $_[0];
|
my $file = find_file $_[0];
|
||||||
|
|
||||||
if ( -f $file ) {
|
if ( -f $file ) {
|
||||||
@@ -6757,37 +6804,6 @@ sub run_user_exit1( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_user_exit2( $$ ) {
|
|
||||||
my ($file, $chainref) = ( find_file $_[0], $_[1] );
|
|
||||||
|
|
||||||
if ( $config{CHAIN_SCRIPTS} && -f $file ) {
|
|
||||||
progress_message2 "Running $file...";
|
|
||||||
#
|
|
||||||
# File may be empty -- in which case eval would fail
|
|
||||||
#
|
|
||||||
push_open $file;
|
|
||||||
|
|
||||||
if ( read_a_line( STRIP_COMMENTS | SUPPRESS_WHITESPACE | CHECK_GUNK ) ) {
|
|
||||||
close_file;
|
|
||||||
pop_open;
|
|
||||||
|
|
||||||
unless (my $return = eval `cat $file` ) {
|
|
||||||
fatal_error "Couldn't parse $file: $@" if $@;
|
|
||||||
|
|
||||||
unless ( defined $return ) {
|
|
||||||
fatal_error "Couldn't do $file: $!" if $!;
|
|
||||||
fatal_error "Couldn't do $file";
|
|
||||||
}
|
|
||||||
|
|
||||||
fatal_error "$file returned a false value";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pop_open;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Generate the aux config file for Shorewall Lite
|
# Generate the aux config file for Shorewall Lite
|
||||||
#
|
#
|
||||||
@@ -6814,7 +6830,7 @@ sub generate_aux_config() {
|
|||||||
|
|
||||||
emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#";
|
emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#";
|
||||||
|
|
||||||
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST) ) {
|
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST PAGER) ) {
|
||||||
conditionally_add_option $option;
|
conditionally_add_option $option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -216,6 +216,7 @@ sub convert_blacklist() {
|
|||||||
my $audit = $disposition =~ /^A_/;
|
my $audit = $disposition =~ /^A_/;
|
||||||
my $target = $disposition;
|
my $target = $disposition;
|
||||||
my $orig_target = $target;
|
my $orig_target = $target;
|
||||||
|
my $warnings = 0;
|
||||||
my @rules;
|
my @rules;
|
||||||
|
|
||||||
if ( @$zones || @$zones1 ) {
|
if ( @$zones || @$zones1 ) {
|
||||||
@@ -237,12 +238,22 @@ sub convert_blacklist() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directive_callback(
|
||||||
|
sub ()
|
||||||
|
{
|
||||||
|
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
first_entry "Converting $fn...";
|
first_entry "Converting $fn...";
|
||||||
|
|
||||||
while ( read_a_line( NORMAL_READ ) ) {
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
my ( $networks, $protocol, $ports, $options ) =
|
my ( $networks, $protocol, $ports, $options ) =
|
||||||
split_line( 'blacklist file',
|
split_rawline2( 'blacklist file',
|
||||||
{ networks => 0, proto => 1, port => 2, options => 3 } );
|
{ networks => 0, proto => 1, port => 2, options => 3 },
|
||||||
|
{},
|
||||||
|
4,
|
||||||
|
);
|
||||||
|
|
||||||
if ( $options eq '-' ) {
|
if ( $options eq '-' ) {
|
||||||
$options = 'src';
|
$options = 'src';
|
||||||
@@ -300,6 +311,8 @@ sub convert_blacklist() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directive_callback(0);
|
||||||
|
|
||||||
if ( @rules ) {
|
if ( @rules ) {
|
||||||
my $fn1 = find_writable_file( 'blrules' );
|
my $fn1 = find_writable_file( 'blrules' );
|
||||||
my $blrules;
|
my $blrules;
|
||||||
@@ -312,7 +325,7 @@ sub convert_blacklist() {
|
|||||||
transfer_permissions( $fn, $fn1 );
|
transfer_permissions( $fn, $fn1 );
|
||||||
print $blrules <<'EOF';
|
print $blrules <<'EOF';
|
||||||
#
|
#
|
||||||
# Shorewall version 5.0 - Blacklist Rules File
|
# Shorewall - Blacklist Rules File
|
||||||
#
|
#
|
||||||
# For information about entries in this file, type "man shorewall-blrules"
|
# For information about entries in this file, type "man shorewall-blrules"
|
||||||
#
|
#
|
||||||
@@ -394,7 +407,8 @@ sub convert_routestopped() {
|
|||||||
if ( my $fn = open_file 'routestopped' ) {
|
if ( my $fn = open_file 'routestopped' ) {
|
||||||
my ( @allhosts, %source, %dest , %notrack, @rule );
|
my ( @allhosts, %source, %dest , %notrack, @rule );
|
||||||
|
|
||||||
my $seq = 0;
|
my $seq = 0;
|
||||||
|
my $warnings = 0;
|
||||||
my $date = compiletime;
|
my $date = compiletime;
|
||||||
|
|
||||||
my ( $stoppedrules, $fn1 );
|
my ( $stoppedrules, $fn1 );
|
||||||
@@ -406,7 +420,7 @@ sub convert_routestopped() {
|
|||||||
transfer_permissions( $fn, $fn1 );
|
transfer_permissions( $fn, $fn1 );
|
||||||
print $stoppedrules <<'EOF';
|
print $stoppedrules <<'EOF';
|
||||||
#
|
#
|
||||||
# Shorewall version 5 - Stopped Rules File
|
# Shorewall - Stopped Rules File
|
||||||
#
|
#
|
||||||
# For information about entries in this file, type "man shorewall-stoppedrules"
|
# For information about entries in this file, type "man shorewall-stoppedrules"
|
||||||
#
|
#
|
||||||
@@ -422,6 +436,13 @@ sub convert_routestopped() {
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directive_callback(
|
||||||
|
sub ()
|
||||||
|
{
|
||||||
|
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
first_entry(
|
first_entry(
|
||||||
sub {
|
sub {
|
||||||
my $date = compiletime;
|
my $date = compiletime;
|
||||||
@@ -436,13 +457,16 @@ EOF
|
|||||||
while ( read_a_line ( NORMAL_READ ) ) {
|
while ( read_a_line ( NORMAL_READ ) ) {
|
||||||
|
|
||||||
my ($interface, $hosts, $options , $proto, $ports, $sports ) =
|
my ($interface, $hosts, $options , $proto, $ports, $sports ) =
|
||||||
split_line( 'routestopped file',
|
split_rawline2( 'routestopped file',
|
||||||
{ interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 } );
|
{ interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 },
|
||||||
|
{},
|
||||||
|
6,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
my $interfaceref;
|
my $interfaceref;
|
||||||
|
|
||||||
fatal_error 'INTERFACE must be specified' if $interface eq '-';
|
fatal_error 'INTERFACE must be specified' if $interface eq '-';
|
||||||
fatal_error "Unknown interface ($interface)" unless $interfaceref = known_interface $interface;
|
|
||||||
$hosts = ALLIP unless $hosts && $hosts ne '-';
|
$hosts = ALLIP unless $hosts && $hosts ne '-';
|
||||||
|
|
||||||
my $routeback = 0;
|
my $routeback = 0;
|
||||||
@@ -456,8 +480,6 @@ EOF
|
|||||||
$hosts = ALLIP if $hosts eq '-';
|
$hosts = ALLIP if $hosts eq '-';
|
||||||
|
|
||||||
for my $host ( split /,/, $hosts ) {
|
for my $host ( split /,/, $hosts ) {
|
||||||
fatal_error "Ipsets not allowed with SAVE_IPSETS=Yes" if $host =~ /^!?\+/ && $config{SAVE_IPSETS};
|
|
||||||
validate_host $host, 1;
|
|
||||||
push @hosts, "$interface|$host|$seq";
|
push @hosts, "$interface|$host|$seq";
|
||||||
push @rule, $rule;
|
push @rule, $rule;
|
||||||
}
|
}
|
||||||
@@ -501,6 +523,8 @@ EOF
|
|||||||
push @allhosts, @hosts;
|
push @allhosts, @hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directive_callback(0);
|
||||||
|
|
||||||
for my $host ( @allhosts ) {
|
for my $host ( @allhosts ) {
|
||||||
my ( $interface, $h, $seq ) = split /\|/, $host;
|
my ( $interface, $h, $seq ) = split /\|/, $host;
|
||||||
my $rule = shift @rule;
|
my $rule = shift @rule;
|
||||||
@@ -1004,7 +1028,7 @@ sub add_common_rules ( $ ) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
run_user_exit1 'initdone';
|
run_user_exit 'initdone';
|
||||||
|
|
||||||
if ( $upgrade ) {
|
if ( $upgrade ) {
|
||||||
convert_blacklist;
|
convert_blacklist;
|
||||||
@@ -1430,8 +1454,6 @@ sub setup_mac_lists( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run_user_exit2( 'maclog', $chainref );
|
|
||||||
|
|
||||||
log_irule_limit $level, $chainref , $chain , $disposition, [], $tag, 'add', '' if $level ne '';
|
log_irule_limit $level, $chainref , $chain , $disposition, [], $tag, 'add', '' if $level ne '';
|
||||||
add_ijump $chainref, j => $target;
|
add_ijump $chainref, j => $target;
|
||||||
}
|
}
|
||||||
@@ -1657,12 +1679,6 @@ sub add_interface_jumps {
|
|||||||
addnatjump $globals{POSTROUTING} , output_chain( $interface ) , imatch_dest_dev( $interface );
|
addnatjump $globals{POSTROUTING} , output_chain( $interface ) , imatch_dest_dev( $interface );
|
||||||
addnatjump $globals{POSTROUTING} , masq_chain( $interface ) , imatch_dest_dev( $interface );
|
addnatjump $globals{POSTROUTING} , masq_chain( $interface ) , imatch_dest_dev( $interface );
|
||||||
|
|
||||||
if ( have_capability 'RAWPOST_TABLE' ) {
|
|
||||||
insert_ijump ( $rawpost_table->{POSTROUTING}, j => postrouting_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $rawpost_table->{postrouting_chain $interface};
|
|
||||||
insert_ijump ( $raw_table->{PREROUTING}, j => prerouting_chain( $interface ), 0, imatch_source_dev( $interface) ) if $raw_table->{prerouting_chain $interface};
|
|
||||||
insert_ijump ( $raw_table->{OUTPUT}, j => output_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $raw_table->{output_chain $interface};
|
|
||||||
}
|
|
||||||
|
|
||||||
add_ijump( $mangle_table->{PREROUTING}, j => 'rpfilter' , imatch_source_dev( $interface ) ) if interface_has_option( $interface, 'rpfilter', $dummy );
|
add_ijump( $mangle_table->{PREROUTING}, j => 'rpfilter' , imatch_source_dev( $interface ) ) if interface_has_option( $interface, 'rpfilter', $dummy );
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
|
@@ -60,12 +60,12 @@ sub initialize($) {
|
|||||||
#
|
#
|
||||||
# Process a single rule from the the masq file
|
# Process a single rule from the the masq file
|
||||||
#
|
#
|
||||||
sub process_one_masq1( $$$$$$$$$$$$ )
|
sub process_one_masq1( $$$$$$$$$$$ )
|
||||||
{
|
{
|
||||||
my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
|
my ( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
|
||||||
|
|
||||||
my $pre_nat;
|
my $pre_nat;
|
||||||
my $add_snat_aliases = ! $snat && $family == F_IPV4 && $config{ADD_SNAT_ALIASES};
|
my $add_snat_aliases = $family == F_IPV4 && $config{ADD_SNAT_ALIASES};
|
||||||
my $destnets = '';
|
my $destnets = '';
|
||||||
my $baserule = '';
|
my $baserule = '';
|
||||||
my $inlinematches = '';
|
my $inlinematches = '';
|
||||||
@@ -226,7 +226,7 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
} elsif ( $addresses eq 'NONAT' ) {
|
} elsif ( $addresses eq 'NONAT' ) {
|
||||||
fatal_error "'persistent' may not be specified with 'NONAT'" if $persistent;
|
fatal_error "'persistent' may not be specified with 'NONAT'" if $persistent;
|
||||||
fatal_error "'random' may not be specified with 'NONAT'" if $randomize;
|
fatal_error "'random' may not be specified with 'NONAT'" if $randomize;
|
||||||
$target = $snat ? 'CONTINUE' : 'RETURN';
|
$target = 'RETURN';
|
||||||
$add_snat_aliases = 0;
|
$add_snat_aliases = 0;
|
||||||
} elsif ( $addresses ) {
|
} elsif ( $addresses ) {
|
||||||
my $addrlist = '';
|
my $addrlist = '';
|
||||||
@@ -249,33 +249,31 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
#
|
#
|
||||||
$target = 'SNAT ';
|
$target = 'SNAT ';
|
||||||
|
|
||||||
unless ( $snat ) {
|
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
|
||||||
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
|
#
|
||||||
|
# User-defined address variable
|
||||||
|
#
|
||||||
|
$conditional = conditional_rule( $chainref, $addr );
|
||||||
|
$addrlist .= '--to-source ' . "\$${1}${ports} ";
|
||||||
|
} else {
|
||||||
|
if ( $conditional = conditional_rule( $chainref, $addr ) ) {
|
||||||
#
|
#
|
||||||
# User-defined address variable
|
# Optional Interface -- rule is conditional
|
||||||
#
|
#
|
||||||
$conditional = conditional_rule( $chainref, $addr );
|
$addr = get_interface_address $interface;
|
||||||
$addrlist .= '--to-source ' . "\$${1}${ports} ";
|
|
||||||
} else {
|
} else {
|
||||||
if ( $conditional = conditional_rule( $chainref, $addr ) ) {
|
#
|
||||||
#
|
# Interface is not optional
|
||||||
# Optional Interface -- rule is conditional
|
#
|
||||||
#
|
$addr = record_runtime_address( $type, $interface );
|
||||||
$addr = get_interface_address $interface;
|
|
||||||
} else {
|
|
||||||
#
|
|
||||||
# Interface is not optional
|
|
||||||
#
|
|
||||||
$addr = record_runtime_address( $type, $interface );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $ports ) {
|
|
||||||
$addr =~ s/ $//;
|
|
||||||
$addr = $family == F_IPV4 ? "${addr}${ports} " : "[$addr]$ports ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$addrlist .= '--to-source ' . $addr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $ports ) {
|
||||||
|
$addr =~ s/ $//;
|
||||||
|
$addr = $family == F_IPV4 ? "${addr}${ports} " : "[$addr]$ports ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$addrlist .= '--to-source ' . $addr;
|
||||||
}
|
}
|
||||||
} elsif ( $family == F_IPV4 ) {
|
} elsif ( $family == F_IPV4 ) {
|
||||||
if ( $addr =~ /^.*\..*\..*\./ ) {
|
if ( $addr =~ /^.*\..*\..*\./ ) {
|
||||||
@@ -362,39 +360,37 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
#
|
#
|
||||||
# And Generate the Rule(s)
|
# And Generate the Rule(s)
|
||||||
#
|
#
|
||||||
unless ( $snat ) {
|
expand_rule( $chainref ,
|
||||||
expand_rule( $chainref ,
|
POSTROUTE_RESTRICT ,
|
||||||
POSTROUTE_RESTRICT ,
|
$prerule ,
|
||||||
$prerule ,
|
$baserule . $inlinematches . $rule ,
|
||||||
$baserule . $inlinematches . $rule ,
|
$networks ,
|
||||||
$networks ,
|
$destnets ,
|
||||||
$destnets ,
|
$origdest ,
|
||||||
$origdest ,
|
$target ,
|
||||||
$target ,
|
'' ,
|
||||||
'' ,
|
'' ,
|
||||||
'' ,
|
$exceptionrule ,
|
||||||
$exceptionrule ,
|
'' )
|
||||||
'' )
|
unless unreachable_warning( 0, $chainref );
|
||||||
unless unreachable_warning( 0, $chainref );
|
|
||||||
|
|
||||||
conditional_rule_end( $chainref ) if $detectaddress || $conditional;
|
conditional_rule_end( $chainref ) if $detectaddress || $conditional;
|
||||||
|
|
||||||
if ( $add_snat_aliases ) {
|
if ( $add_snat_aliases ) {
|
||||||
my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 );
|
my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 );
|
||||||
fatal_error "Invalid alias ($alias:$remainder)" if defined $remainder;
|
fatal_error "Invalid alias ($alias:$remainder)" if defined $remainder;
|
||||||
for my $address ( split_list $addresses, 'address' ) {
|
for my $address ( split_list $addresses, 'address' ) {
|
||||||
my ( $addrs, $port ) = split /:/, $address;
|
my ( $addrs, $port ) = split /:/, $address;
|
||||||
next unless $addrs;
|
next unless $addrs;
|
||||||
next if $addrs eq 'detect';
|
next if $addrs eq 'detect';
|
||||||
for my $addr ( ip_range_explicit $addrs ) {
|
for my $addr ( ip_range_explicit $addrs ) {
|
||||||
unless ( $addresses_to_add{$addr} ) {
|
unless ( $addresses_to_add{$addr} ) {
|
||||||
$addresses_to_add{$addr} = 1;
|
$addresses_to_add{$addr} = 1;
|
||||||
if ( defined $alias ) {
|
if ( defined $alias ) {
|
||||||
push @addresses_to_add, $addr, "$interface:$alias";
|
push @addresses_to_add, $addr, "$interface:$alias";
|
||||||
$alias++;
|
$alias++;
|
||||||
} else {
|
} else {
|
||||||
push @addresses_to_add, $addr, $interface;
|
push @addresses_to_add, $addr, $interface;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,8 +398,87 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress_message " Masq record \"$currentline\" $done";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub convert_one_masq1( $$$$$$$$$$$$ )
|
||||||
|
{
|
||||||
|
my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
|
||||||
|
|
||||||
|
my $pre_nat;
|
||||||
|
my $destnets = '';
|
||||||
|
my $savelist;
|
||||||
|
#
|
||||||
|
# Leading '+'
|
||||||
|
#
|
||||||
|
$pre_nat = ( $interfacelist =~ s/^\+// );
|
||||||
|
#
|
||||||
|
# Check for INLINE
|
||||||
|
#
|
||||||
|
if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) {
|
||||||
|
$interfacelist = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$savelist = $interfacelist;
|
||||||
|
#
|
||||||
|
# Parse the remaining part of the INTERFACE column
|
||||||
|
#
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
|
if ( $interfacelist =~ /^([^:]+)::([^:]*)$/ ) {
|
||||||
|
$destnets = $2;
|
||||||
|
$interfacelist = $1;
|
||||||
|
} elsif ( $interfacelist =~ /^([^:]+:[^:]+):([^:]+)$/ ) {
|
||||||
|
$destnets = $2;
|
||||||
|
$interfacelist = $1;
|
||||||
|
} elsif ( $interfacelist =~ /^([^:]+):$/ ) {
|
||||||
|
$interfacelist = $1;
|
||||||
|
} elsif ( $interfacelist =~ /^([^:]+):([^:]*)$/ ) {
|
||||||
|
my ( $one, $two ) = ( $1, $2 );
|
||||||
|
if ( $2 =~ /\./ || $2 =~ /^%/ ) {
|
||||||
|
$interfacelist = $one;
|
||||||
|
$destnets = $two;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elsif ( $interfacelist =~ /^(.+?):(.+)$/ ) {
|
||||||
|
$interfacelist = $1;
|
||||||
|
$destnets = $2;
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# If there is no source or destination then allow all addresses
|
||||||
|
#
|
||||||
|
$networks = ALLIP if $networks eq '-';
|
||||||
|
$destnets = ALLIP if $destnets eq '-';
|
||||||
|
|
||||||
|
my $target;
|
||||||
|
#
|
||||||
|
# Parse the ADDRESSES column
|
||||||
|
#
|
||||||
|
if ( $addresses ne '-' ) {
|
||||||
|
my $saveaddresses = $addresses;
|
||||||
|
if ( $addresses ne 'random' ) {
|
||||||
|
$addresses =~ s/:persistent$//;
|
||||||
|
$addresses =~ s/:random$//;
|
||||||
|
|
||||||
|
if ( $addresses eq 'detect' ) {
|
||||||
|
$target = 'SNAT';
|
||||||
|
} elsif ( $addresses eq 'NONAT' ) {
|
||||||
|
$target = 'CONTINUE';
|
||||||
|
} elsif ( $addresses ) {
|
||||||
|
if ( $addresses =~ /^:/ ) {
|
||||||
|
$target = 'MASQUERADE';
|
||||||
|
} else {
|
||||||
|
$target = 'SNAT';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$addresses = $saveaddresses;
|
||||||
|
} else {
|
||||||
|
$target = 'MASQUERADE';
|
||||||
|
}
|
||||||
|
|
||||||
if ( $snat ) {
|
if ( $snat ) {
|
||||||
$target =~ s/ .*//;
|
|
||||||
$target .= '+' if $pre_nat;
|
$target .= '+' if $pre_nat;
|
||||||
|
|
||||||
if ( $addresses ne '-' && $addresses ne 'NONAT' ) {
|
if ( $addresses ne '-' && $addresses ne 'NONAT' ) {
|
||||||
@@ -424,7 +499,7 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
|||||||
print $snat "$line\n";
|
print $snat "$line\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_message " Masq record \"$currentline\" $done";
|
progress_message " Masq record \"$rawcurrentline\" Converted";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,17 +507,37 @@ sub process_one_masq( $ )
|
|||||||
{
|
{
|
||||||
my ( $snat ) = @_;
|
my ( $snat ) = @_;
|
||||||
|
|
||||||
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
|
if ( $snat ) {
|
||||||
split_line2( 'masq file',
|
unless ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
|
||||||
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
|
#
|
||||||
{}, #Nopad
|
# Line was not blank or all comment
|
||||||
undef, #Columns
|
#
|
||||||
1 ); #Allow inline matches
|
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
|
||||||
|
split_rawline2( 'masq file',
|
||||||
|
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
|
||||||
|
{}, #Nopad
|
||||||
|
undef, #Columns
|
||||||
|
1 ); #Allow inline matches
|
||||||
|
|
||||||
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
|
if ( $interfacelist ne '-' ) {
|
||||||
|
for my $proto ( split_list $protos, 'Protocol' ) {
|
||||||
|
convert_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
|
||||||
|
split_line2( 'masq file',
|
||||||
|
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
|
||||||
|
{}, #Nopad
|
||||||
|
undef, #Columns
|
||||||
|
1 ); #Allow inline matches
|
||||||
|
|
||||||
for my $proto ( split_list $protos, 'Protocol' ) {
|
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
|
||||||
process_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
|
|
||||||
|
for my $proto ( split_list $protos, 'Protocol' ) {
|
||||||
|
process_one_masq1( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +592,19 @@ sub convert_masq() {
|
|||||||
|
|
||||||
my $have_masq_rules;
|
my $have_masq_rules;
|
||||||
|
|
||||||
directive_callback( sub () { print $snat "$_[1]\n"; 0; } );
|
directive_callback(
|
||||||
|
sub ()
|
||||||
|
{
|
||||||
|
if ( $_[0] eq 'OMITTED' ) {
|
||||||
|
#
|
||||||
|
# Convert the raw rule
|
||||||
|
#
|
||||||
|
process_one_masq( $snat) if $snat;
|
||||||
|
} else {
|
||||||
|
print $snat "$_[1]\n"; 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
first_entry(
|
first_entry(
|
||||||
sub {
|
sub {
|
||||||
@@ -510,7 +617,18 @@ sub convert_masq() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
process_one_masq($snat), $have_masq_rules++ while read_a_line( NORMAL_READ );
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
|
#
|
||||||
|
# Process the file normally
|
||||||
|
#
|
||||||
|
process_one_masq(0);
|
||||||
|
#
|
||||||
|
# Now Convert it
|
||||||
|
#
|
||||||
|
process_one_masq($snat);
|
||||||
|
|
||||||
|
$have_masq_rules++;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $have_masq_rules ) {
|
if ( $have_masq_rules ) {
|
||||||
progress_message2 "Converted $fn to $fn1";
|
progress_message2 "Converted $fn to $fn1";
|
||||||
@@ -672,88 +790,39 @@ sub setup_netmap() {
|
|||||||
|
|
||||||
my @rule = do_iproto( $proto, $dport, $sport );
|
my @rule = do_iproto( $proto, $dport, $sport );
|
||||||
|
|
||||||
unless ( $type =~ /:/ ) {
|
my @rulein;
|
||||||
my @rulein;
|
my @ruleout;
|
||||||
my @ruleout;
|
|
||||||
|
|
||||||
$net1 = validate_net $net1, 0;
|
$net1 = validate_net $net1, 0;
|
||||||
$net2 = validate_net $net2, 0;
|
$net2 = validate_net $net2, 0;
|
||||||
|
|
||||||
if ( $interfaceref->{root} ) {
|
if ( $interfaceref->{root} ) {
|
||||||
$interface = $interfaceref->{name} if $interface eq $interfaceref->{physical};
|
$interface = $interfaceref->{name} if $interface eq $interfaceref->{physical};
|
||||||
} else {
|
} else {
|
||||||
@rulein = imatch_source_dev( $interface );
|
@rulein = imatch_source_dev( $interface );
|
||||||
@ruleout = imatch_dest_dev( $interface );
|
@ruleout = imatch_dest_dev( $interface );
|
||||||
$interface = $interfaceref->{name};
|
$interface = $interfaceref->{name};
|
||||||
}
|
}
|
||||||
|
|
||||||
require_capability 'NAT_ENABLED', 'Stateful NAT Entries', '';
|
require_capability 'NETMAP_TARGET', 'Stateful Netmap Entries', '';
|
||||||
|
|
||||||
if ( $type eq 'DNAT' ) {
|
if ( $type eq 'DNAT' ) {
|
||||||
dest_iexclusion( ensure_chain( 'nat' , input_chain $interface ) ,
|
dest_iexclusion( ensure_chain( 'nat' , input_chain $interface ) ,
|
||||||
j => 'NETMAP' ,
|
j => 'NETMAP' ,
|
||||||
"--to $net2",
|
"--to $net2",
|
||||||
$net1 ,
|
$net1 ,
|
||||||
@rulein ,
|
@rulein ,
|
||||||
imatch_source_net( $net3 ) );
|
imatch_source_net( $net3 ) );
|
||||||
} elsif ( $type eq 'SNAT' ) {
|
} elsif ( $type eq 'SNAT' ) {
|
||||||
source_iexclusion( ensure_chain( 'nat' , output_chain $interface ) ,
|
source_iexclusion( ensure_chain( 'nat' , output_chain $interface ) ,
|
||||||
j => 'NETMAP' ,
|
j => 'NETMAP' ,
|
||||||
"--to $net2" ,
|
"--to $net2" ,
|
||||||
$net1 ,
|
$net1 ,
|
||||||
@ruleout ,
|
@ruleout ,
|
||||||
imatch_dest_net( $net3 ) );
|
imatch_dest_net( $net3 ) );
|
||||||
} else {
|
|
||||||
fatal_error "Invalid type ($type)";
|
|
||||||
}
|
|
||||||
} elsif ( $type =~ /^(DNAT|SNAT):([POT])$/ ) {
|
|
||||||
my ( $target , $chain ) = ( $1, $2 );
|
|
||||||
my $table = 'raw';
|
|
||||||
my @match;
|
|
||||||
|
|
||||||
require_capability 'RAWPOST_TABLE', 'Stateless NAT Entries', '';
|
|
||||||
|
|
||||||
$net2 = validate_net $net2, 0;
|
|
||||||
|
|
||||||
unless ( $interfaceref->{root} ) {
|
|
||||||
@match = imatch_dest_dev( $interface );
|
|
||||||
$interface = $interfaceref->{name};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $chain eq 'P' ) {
|
|
||||||
$chain = prerouting_chain $interface;
|
|
||||||
@match = imatch_source_dev( $iface ) unless $iface eq $interface;
|
|
||||||
} elsif ( $chain eq 'O' ) {
|
|
||||||
$chain = output_chain $interface;
|
|
||||||
} else {
|
|
||||||
$chain = postrouting_chain $interface;
|
|
||||||
$table = 'rawpost';
|
|
||||||
}
|
|
||||||
|
|
||||||
my $chainref = ensure_chain( $table, $chain );
|
|
||||||
|
|
||||||
|
|
||||||
if ( $target eq 'DNAT' ) {
|
|
||||||
dest_iexclusion( $chainref ,
|
|
||||||
j => 'RAWDNAT' ,
|
|
||||||
"--to-dest $net2" ,
|
|
||||||
$net1 ,
|
|
||||||
imatch_source_net( $net3 ) ,
|
|
||||||
@rule ,
|
|
||||||
@match
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
source_iexclusion( $chainref ,
|
|
||||||
j => 'RAWSNAT' ,
|
|
||||||
"--to-source $net2" ,
|
|
||||||
$net1 ,
|
|
||||||
imatch_dest_net( $net3 ) ,
|
|
||||||
@rule ,
|
|
||||||
@match );
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fatal_error 'TYPE must be specified' if $type eq '-';
|
fatal_error 'TYPE must be specified' if $type eq '-';
|
||||||
fatal_error "Invalid TYPE ($type)";
|
fatal_error "Invalid type ($type)";
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_message " Network $net1 on $iface mapped to $net2 ($type)";
|
progress_message " Network $net1 on $iface mapped to $net2 ($type)";
|
||||||
|
@@ -220,7 +220,14 @@ sub copy_table( $$$ ) {
|
|||||||
' esac',
|
' esac',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
emit ( " run_ip route add table $number \$net \$route $realm" );
|
emit ( ' case $net in',
|
||||||
|
' fe80:*)',
|
||||||
|
' ;;',
|
||||||
|
' *)',
|
||||||
|
" run_ip route add table $number \$net \$route $realm",
|
||||||
|
' ;;',
|
||||||
|
' esac',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit ( ' ;;',
|
emit ( ' ;;',
|
||||||
@@ -291,7 +298,14 @@ sub copy_and_edit_table( $$$$$ ) {
|
|||||||
' esac',
|
' esac',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
emit ( " run_ip route add table $id \$net \$route $realm" );
|
emit ( ' case $net in',
|
||||||
|
' fe80:*)',
|
||||||
|
' ;;',
|
||||||
|
' *)',
|
||||||
|
" run_ip route add table $id \$net \$route $realm",
|
||||||
|
' ;;',
|
||||||
|
' esac',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit ( ' ;;',
|
emit ( ' ;;',
|
||||||
@@ -505,11 +519,11 @@ sub process_a_provider( $ ) {
|
|||||||
my ( $loose, $track, $balance, $default, $default_balance, $optional, $mtu, $tproxy, $local, $load, $what, $hostroute, $persistent );
|
my ( $loose, $track, $balance, $default, $default_balance, $optional, $mtu, $tproxy, $local, $load, $what, $hostroute, $persistent );
|
||||||
|
|
||||||
if ( $pseudo ) {
|
if ( $pseudo ) {
|
||||||
( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent ) =
|
( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent ) =
|
||||||
( 0, 0 , 0 , 0, 0, 1 , '' , 0 , 0, 0, 'interface', 0, 0);
|
( 0, 0 , 0 , 0, 0, 1 , '' , 0 , 0, 0, 'interface', 0, 0);
|
||||||
} else {
|
} else {
|
||||||
( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent )=
|
( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent )=
|
||||||
( 0, $config{TRACK_PROVIDERS}, 0 , 0, $config{USE_DEFAULT_RT} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0, 0, 'provider', 1, 0);
|
( 0, $config{TRACK_PROVIDERS}, 0 , 0, $config{BALANCE_PROVIDERS} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0, 0, 'provider', 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ( $options eq '-' ) {
|
unless ( $options eq '-' ) {
|
||||||
@@ -589,19 +603,37 @@ sub process_a_provider( $ ) {
|
|||||||
|
|
||||||
fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)};
|
fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)};
|
||||||
|
|
||||||
if ( $local ) {
|
unless ( $pseudo ) {
|
||||||
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted';
|
if ( $local ) {
|
||||||
fatal_error "'track' not valid with 'local'" if $track;
|
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted';
|
||||||
fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-';
|
fatal_error "'track' not valid with 'local'" if $track;
|
||||||
fatal_error "'persistent' is not valid with 'local" if $persistent;
|
fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-';
|
||||||
} elsif ( $tproxy ) {
|
fatal_error "'persistent' is not valid with 'local" if $persistent;
|
||||||
fatal_error "Only one 'tproxy' provider is allowed" if $tproxies++;
|
} elsif ( $tproxy ) {
|
||||||
fatal_error "GATEWAY not valid with 'tproxy' provider" unless $gatewaycase eq 'omitted';
|
fatal_error "Only one 'tproxy' provider is allowed" if $tproxies++;
|
||||||
fatal_error "'track' not valid with 'tproxy'" if $track;
|
fatal_error "GATEWAY not valid with 'tproxy' provider" unless $gatewaycase eq 'omitted';
|
||||||
fatal_error "DUPLICATE not valid with 'tproxy'" if $duplicate ne '-';
|
fatal_error "'track' not valid with 'tproxy'" if $track;
|
||||||
fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-';
|
fatal_error "DUPLICATE not valid with 'tproxy'" if $duplicate ne '-';
|
||||||
fatal_error "'persistent' is not valid with 'tproxy" if $persistent;
|
fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-';
|
||||||
$mark = $globals{TPROXY_MARK};
|
fatal_error "'persistent' is not valid with 'tproxy" if $persistent;
|
||||||
|
$mark = $globals{TPROXY_MARK};
|
||||||
|
} elsif ( ( my $rf = ( $config{ROUTE_FILTER} eq 'on' ) ) || $interfaceref->{options}{routefilter} ) {
|
||||||
|
if ( $config{USE_DEFAULT_RT} ) {
|
||||||
|
if ( $rf ) {
|
||||||
|
fatal_error "There may be no providers when ROUTE_FILTER=Yes and USE_DEFAULT_RT=Yes";
|
||||||
|
} else {
|
||||||
|
fatal_error "Providers interfaces may not specify 'routefilter' when USE_DEFAULT_RT=Yes";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unless ( $balance ) {
|
||||||
|
if ( $rf ) {
|
||||||
|
fatal_error "The 'balance' option is required when ROUTE_FILTER=Yes";
|
||||||
|
} else {
|
||||||
|
fatal_error "Provider interfaces may not specify 'routefilter' without 'balance' or 'primary'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $val = 0;
|
my $val = 0;
|
||||||
@@ -1496,7 +1528,18 @@ sub finish_providers() {
|
|||||||
|
|
||||||
if ( $balancing ) {
|
if ( $balancing ) {
|
||||||
emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' );
|
emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' );
|
||||||
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
|
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
|
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
|
||||||
|
} else {
|
||||||
|
emit ( " if echo \$DEFAULT_ROUTE | grep -q 'nexthop.+nexthop'; then",
|
||||||
|
" qt \$IP -6 route delete default scope global table $table \$DEFAULT_ROUTE",
|
||||||
|
" run_ip -6 route add default scope global table $table \$DEFAULT_ROUTE",
|
||||||
|
' else',
|
||||||
|
" run_ip -6 route replace default scope global table $table \$DEFAULT_ROUTE",
|
||||||
|
' fi',
|
||||||
|
'' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $config{USE_DEFAULT_RT} ) {
|
if ( $config{USE_DEFAULT_RT} ) {
|
||||||
emit ( " while qt \$IP -$family route del default table $main; do",
|
emit ( " while qt \$IP -$family route del default table $main; do",
|
||||||
@@ -1549,7 +1592,13 @@ sub finish_providers() {
|
|||||||
|
|
||||||
if ( $fallback ) {
|
if ( $fallback ) {
|
||||||
emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' );
|
emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' );
|
||||||
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
|
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
|
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
|
||||||
|
} else {
|
||||||
|
emit( " run_ip route delete default scope global table $default \$FALLBACK_ROUTE" );
|
||||||
|
emit( " run_ip route add default scope global table $default \$FALLBACK_ROUTE" );
|
||||||
|
}
|
||||||
|
|
||||||
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
|
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
|
||||||
'else',
|
'else',
|
||||||
|
@@ -122,7 +122,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
|||||||
fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1;
|
fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my ( $tgt, $options ) = split( ' ', $2 );
|
my ( $tgt, $options ) = split( ' ', $2, 2 );
|
||||||
my $target_type = $builtin_target{$tgt};
|
my $target_type = $builtin_target{$tgt};
|
||||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||||
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;
|
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;
|
||||||
|
@@ -233,6 +233,7 @@ use constant { INLINE_OPT => 1 ,
|
|||||||
TERMINATING_OPT => 256 ,
|
TERMINATING_OPT => 256 ,
|
||||||
AUDIT_OPT => 512 ,
|
AUDIT_OPT => 512 ,
|
||||||
LOGJUMP_OPT => 1024 ,
|
LOGJUMP_OPT => 1024 ,
|
||||||
|
SECTION_OPT => 2048 ,
|
||||||
};
|
};
|
||||||
|
|
||||||
our %options = ( inline => INLINE_OPT ,
|
our %options = ( inline => INLINE_OPT ,
|
||||||
@@ -246,6 +247,7 @@ our %options = ( inline => INLINE_OPT ,
|
|||||||
terminating => TERMINATING_OPT ,
|
terminating => TERMINATING_OPT ,
|
||||||
audit => AUDIT_OPT ,
|
audit => AUDIT_OPT ,
|
||||||
logjump => LOGJUMP_OPT ,
|
logjump => LOGJUMP_OPT ,
|
||||||
|
section => SECTION_OPT ,
|
||||||
);
|
);
|
||||||
|
|
||||||
our %reject_options;
|
our %reject_options;
|
||||||
@@ -309,11 +311,12 @@ sub initialize( $ ) {
|
|||||||
# This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored
|
# This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored
|
||||||
# in the %config hash when shorewall[6].conf was processed.
|
# in the %config hash when shorewall[6].conf was processed.
|
||||||
#
|
#
|
||||||
%default_actions = ( DROP => 'none' ,
|
%default_actions = ( DROP => 'none' ,
|
||||||
REJECT => 'none' ,
|
REJECT => 'none' ,
|
||||||
ACCEPT => 'none' ,
|
BLACKLIST => 'none' ,
|
||||||
QUEUE => 'none' ,
|
ACCEPT => 'none' ,
|
||||||
NFQUEUE => 'none' ,
|
QUEUE => 'none' ,
|
||||||
|
NFQUEUE => 'none' ,
|
||||||
);
|
);
|
||||||
#
|
#
|
||||||
# These are set to 1 as sections are encountered.
|
# These are set to 1 as sections are encountered.
|
||||||
@@ -574,7 +577,7 @@ sub process_default_action( $$$$ ) {
|
|||||||
#
|
#
|
||||||
sub handle_nfqueue( $$ ) {
|
sub handle_nfqueue( $$ ) {
|
||||||
my ($params, $allow_bypass ) = @_;
|
my ($params, $allow_bypass ) = @_;
|
||||||
my ( $action, $bypass );
|
my ( $action, $bypass, $fanout );
|
||||||
my ( $queue1, $queue2, $queuenum1, $queuenum2 );
|
my ( $queue1, $queue2, $queuenum1, $queuenum2 );
|
||||||
|
|
||||||
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules and Policies', '' );
|
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules and Policies', '' );
|
||||||
@@ -600,6 +603,7 @@ sub handle_nfqueue( $$ ) {
|
|||||||
fatal_error "Invalid NFQUEUE queue number ($queue1)" unless defined( $queuenum1) && $queuenum1 >= 0 && $queuenum1 <= 65535;
|
fatal_error "Invalid NFQUEUE queue number ($queue1)" unless defined( $queuenum1) && $queuenum1 >= 0 && $queuenum1 <= 65535;
|
||||||
|
|
||||||
if ( supplied $queue2 ) {
|
if ( supplied $queue2 ) {
|
||||||
|
$fanout = ' --queue-cpu-fanout' if $queue2 =~ s/c$//;
|
||||||
$queuenum2 = numeric_value( $queue2 );
|
$queuenum2 = numeric_value( $queue2 );
|
||||||
|
|
||||||
fatal_error "Invalid NFQUEUE queue number ($queue2)" unless defined( $queuenum2) && $queuenum2 >= 0 && $queuenum2 <= 65535 && $queuenum1 < $queuenum2;
|
fatal_error "Invalid NFQUEUE queue number ($queue2)" unless defined( $queuenum2) && $queuenum2 >= 0 && $queuenum2 <= 65535 && $queuenum1 < $queuenum2;
|
||||||
@@ -621,7 +625,8 @@ sub handle_nfqueue( $$ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( supplied $queue2 ) {
|
if ( supplied $queue2 ) {
|
||||||
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}";
|
require_capability 'CPU_FANOUT', '"c"', 's' if $fanout;
|
||||||
|
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${fanout}${bypass}";
|
||||||
} else {
|
} else {
|
||||||
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
|
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
|
||||||
}
|
}
|
||||||
@@ -638,7 +643,8 @@ sub process_a_policy1($$$$$$$) {
|
|||||||
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
|
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
|
||||||
|
|
||||||
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ );
|
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ );
|
||||||
$intrazone = $clientwild && $1;
|
|
||||||
|
$intrazone ||= $clientwild && $1;
|
||||||
|
|
||||||
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
|
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
|
||||||
|
|
||||||
@@ -676,6 +682,8 @@ sub process_a_policy1($$$$$$$) {
|
|||||||
if $clientwild || $serverwild;
|
if $clientwild || $serverwild;
|
||||||
fatal_error "NONE policy not allowed to/from firewall zone"
|
fatal_error "NONE policy not allowed to/from firewall zone"
|
||||||
if ( zone_type( $client ) == FIREWALL ) || ( zone_type( $server ) == FIREWALL );
|
if ( zone_type( $client ) == FIREWALL ) || ( zone_type( $server ) == FIREWALL );
|
||||||
|
} elsif ( $policy eq 'BLACKLIST' ) {
|
||||||
|
fatal_error 'BLACKLIST policies require ipset-based dynamic blacklisting' unless $config{DYNAMIC_BLACKLIST} =~ /^ipset/;
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ( $clientwild || $serverwild ) {
|
unless ( $clientwild || $serverwild ) {
|
||||||
@@ -763,25 +771,28 @@ sub process_a_policy() {
|
|||||||
$synparams = '' if $synparams eq '-';
|
$synparams = '' if $synparams eq '-';
|
||||||
$connlimit = '' if $connlimit eq '-';
|
$connlimit = '' if $connlimit eq '-';
|
||||||
|
|
||||||
my $intrazone;
|
my ( $intrazone, $clientlist, $serverlist );
|
||||||
|
|
||||||
if ( $intrazone = $clients =~ /.*,.*\+$/) {
|
if ( $clientlist = ( $clients =~ /,/ ) ) {
|
||||||
$clients =~ s/\+$//;
|
$intrazone = ( $clients =~ s/\+$// );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $servers =~ /.*,.*\+$/ ) {
|
if ( $serverlist = ( $servers =~ /,/ ) ) {
|
||||||
$servers =~ s/\+$//;
|
$intrazone ||= ( $servers =~ s/\+$// );
|
||||||
$intrazone = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_error 'SOURCE must be specified' if $clients eq '-';
|
fatal_error 'SOURCE must be specified' if $clients eq '-';
|
||||||
fatal_error 'DEST must be specified' if $servers eq '-';
|
fatal_error 'DEST must be specified' if $servers eq '-';
|
||||||
fatal_error 'POLICY must be specified' if $policy eq '-';
|
fatal_error 'POLICY must be specified' if $policy eq '-';
|
||||||
|
|
||||||
for my $client ( split_list( $clients, 'zone' ) ) {
|
if ( $clientlist || $serverlist ) {
|
||||||
for my $server ( split_list( $servers, 'zone' ) ) {
|
for my $client ( split_list( $clients, 'zone' ) ) {
|
||||||
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone );
|
for my $server ( split_list( $servers, 'zone' ) ) {
|
||||||
|
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone ) if $intrazone || $client ne $server;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
process_a_policy1( $clients, $servers, $policy, $loglevel, $synparams, $connlimit, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -811,24 +822,26 @@ sub process_policies()
|
|||||||
our %validpolicies = (
|
our %validpolicies = (
|
||||||
ACCEPT => undef,
|
ACCEPT => undef,
|
||||||
REJECT => undef,
|
REJECT => undef,
|
||||||
DROP => undef,
|
DROP => undef,
|
||||||
CONTINUE => undef,
|
CONTINUE => undef,
|
||||||
|
BLACKLIST => undef,
|
||||||
QUEUE => undef,
|
QUEUE => undef,
|
||||||
NFQUEUE => undef,
|
NFQUEUE => undef,
|
||||||
NONE => undef
|
NONE => undef
|
||||||
);
|
);
|
||||||
|
|
||||||
our %map = ( DROP_DEFAULT => 'DROP' ,
|
our %map = ( DROP_DEFAULT => 'DROP' ,
|
||||||
REJECT_DEFAULT => 'REJECT' ,
|
REJECT_DEFAULT => 'REJECT' ,
|
||||||
ACCEPT_DEFAULT => 'ACCEPT' ,
|
BLACKLIST_DEFAULT => 'BLACKLIST' ,
|
||||||
QUEUE_DEFAULT => 'QUEUE' ,
|
ACCEPT_DEFAULT => 'ACCEPT' ,
|
||||||
NFQUEUE_DEFAULT => 'NFQUEUE' );
|
QUEUE_DEFAULT => 'QUEUE' ,
|
||||||
|
NFQUEUE_DEFAULT => 'NFQUEUE' );
|
||||||
|
|
||||||
my $zone;
|
my $zone;
|
||||||
my $firewall = firewall_zone;
|
my $firewall = firewall_zone;
|
||||||
our @zonelist = $config{EXPAND_POLICIES} ? all_zones : ( all_zones, 'all' );
|
our @zonelist = $config{EXPAND_POLICIES} ? all_zones : ( all_zones, 'all' );
|
||||||
|
|
||||||
for my $option ( qw( DROP_DEFAULT REJECT_DEFAULT ACCEPT_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT) ) {
|
for my $option ( qw( DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT ACCEPT_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT) ) {
|
||||||
my $action = $config{$option};
|
my $action = $config{$option};
|
||||||
|
|
||||||
unless ( $action eq 'none' ) {
|
unless ( $action eq 'none' ) {
|
||||||
@@ -945,7 +958,20 @@ sub add_policy_rules( $$$$$ ) {
|
|||||||
log_rule $loglevel , $chainref , $target , '' if $loglevel ne '';
|
log_rule $loglevel , $chainref , $target , '' if $loglevel ne '';
|
||||||
fatal_error "Null target in policy_rules()" unless $target;
|
fatal_error "Null target in policy_rules()" unless $target;
|
||||||
|
|
||||||
add_ijump( $chainref , j => 'AUDIT', targetopts => '--type ' . lc $target ) if $chainref->{audit};
|
if ( $target eq 'BLACKLIST' ) {
|
||||||
|
my ( $dbl_type, $dbl_ipset, $dbl_level, $dbl_tag ) = split( ':', $config{DYNAMIC_BLACKLIST} );
|
||||||
|
|
||||||
|
if ( my $timeout = $globals{DBL_TIMEOUT} ) {
|
||||||
|
add_ijump( $chainref, j => "SET --add-set $dbl_ipset src --exist --timeout $timeout" );
|
||||||
|
} else {
|
||||||
|
add_ijump( $chainref, j => "SET --add-set $dbl_ipset src --exist" );
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = 'DROP';
|
||||||
|
} else {
|
||||||
|
add_ijump( $chainref , j => 'AUDIT', targetopts => '--type ' . lc $target ) if $chainref->{audit};
|
||||||
|
}
|
||||||
|
|
||||||
add_ijump( $chainref , g => $target eq 'REJECT' ? 'reject' : $target ) unless $target eq 'CONTINUE';
|
add_ijump( $chainref , g => $target eq 'REJECT' ? 'reject' : $target ) unless $target eq 'CONTINUE';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1027,7 +1053,6 @@ sub complete_policy_chains() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $name =~ /^all[-2]|[-2]all$/ ) {
|
if ( $name =~ /^all[-2]|[-2]all$/ ) {
|
||||||
run_user_exit $chainref;
|
|
||||||
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1038,7 +1063,6 @@ sub complete_policy_chains() {
|
|||||||
my $chainref = $filter_table->{rules_chain( ${zone}, ${zone1} )};
|
my $chainref = $filter_table->{rules_chain( ${zone}, ${zone1} )};
|
||||||
|
|
||||||
if ( $chainref->{referenced} ) {
|
if ( $chainref->{referenced} ) {
|
||||||
run_user_exit $chainref;
|
|
||||||
complete_policy_chain $chainref, $zone, $zone1;
|
complete_policy_chain $chainref, $zone, $zone1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1057,8 +1081,6 @@ sub complete_policy_chains() {
|
|||||||
sub complete_standard_chain ( $$$$ ) {
|
sub complete_standard_chain ( $$$$ ) {
|
||||||
my ( $stdchainref, $zone, $zone2, $default ) = @_;
|
my ( $stdchainref, $zone, $zone2, $default ) = @_;
|
||||||
|
|
||||||
run_user_exit $stdchainref;
|
|
||||||
|
|
||||||
my $ruleschainref = $filter_table->{rules_chain( ${zone}, ${zone2} ) } || $filter_table->{rules_chain( 'all', 'all' ) };
|
my $ruleschainref = $filter_table->{rules_chain( ${zone}, ${zone2} ) } || $filter_table->{rules_chain( 'all', 'all' ) };
|
||||||
my ( $policy, $loglevel, $defaultaction ) = ( $default , 6, $config{$default . '_DEFAULT'} );
|
my ( $policy, $loglevel, $defaultaction ) = ( $default , 6, $config{$default . '_DEFAULT'} );
|
||||||
my $policychainref;
|
my $policychainref;
|
||||||
@@ -1316,8 +1338,18 @@ sub normalize_action( $$$ ) {
|
|||||||
# Note: SNAT actions store the current interface's name in the tag
|
# Note: SNAT actions store the current interface's name in the tag
|
||||||
#
|
#
|
||||||
$tag = '' unless defined $tag;
|
$tag = '' unless defined $tag;
|
||||||
$param = '' unless defined $param;
|
|
||||||
$param = '' if $param eq '-';
|
if ( defined( $param ) ) {
|
||||||
|
#
|
||||||
|
# Normalize the parameters by removing trailing omitted
|
||||||
|
# parameters
|
||||||
|
#
|
||||||
|
1 while $param =~ s/,-$//;
|
||||||
|
|
||||||
|
$param = '' if $param eq '-';
|
||||||
|
} else {
|
||||||
|
$param = '';
|
||||||
|
}
|
||||||
|
|
||||||
join( ':', $action, $level, $tag, $caller, $param );
|
join( ':', $action, $level, $tag, $caller, $param );
|
||||||
}
|
}
|
||||||
@@ -1419,27 +1451,6 @@ sub createlogactionchain( $$$$$$ ) {
|
|||||||
|
|
||||||
$chainref->{action} = $normalized;
|
$chainref->{action} = $normalized;
|
||||||
|
|
||||||
if ( $config{CHAIN_SCRIPTS} ) {
|
|
||||||
unless ( $targets{$action} & BUILTIN ) {
|
|
||||||
|
|
||||||
set_optflags( $chainref, DONT_OPTIMIZE );
|
|
||||||
|
|
||||||
my $file = find_file $chain;
|
|
||||||
|
|
||||||
if ( -f $file ) {
|
|
||||||
progress_message "Running $file...";
|
|
||||||
|
|
||||||
my @params = split /,/, $param;
|
|
||||||
|
|
||||||
unless ( my $return = eval `cat $file` ) {
|
|
||||||
fatal_error "Couldn't parse $file: $@" if $@;
|
|
||||||
fatal_error "Couldn't do $file: $!" unless defined $return;
|
|
||||||
fatal_error "Couldn't run $file";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$chainref;
|
$chainref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1455,27 +1466,6 @@ sub createsimpleactionchain( $$ ) {
|
|||||||
|
|
||||||
$chainref->{action} = $normalized;
|
$chainref->{action} = $normalized;
|
||||||
|
|
||||||
if ( $config{CHAIN_SCRIPTS} ) {
|
|
||||||
unless ( $targets{$action} & BUILTIN ) {
|
|
||||||
|
|
||||||
set_optflags( $chainref, DONT_OPTIMIZE );
|
|
||||||
|
|
||||||
my $file = find_file $action;
|
|
||||||
|
|
||||||
if ( -f $file ) {
|
|
||||||
progress_message "Running $file...";
|
|
||||||
|
|
||||||
my ( $level, $tag ) = ( '', '' );
|
|
||||||
|
|
||||||
unless ( my $return = eval `cat $file` ) {
|
|
||||||
fatal_error "Couldn't parse $file: $@" if $@;
|
|
||||||
fatal_error "Couldn't do $file: $!" unless defined $return;
|
|
||||||
fatal_error "Couldn't run $file";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$chainref;
|
$chainref;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1873,7 +1863,7 @@ my %builtinops = ( 'dropBcast' => \&dropBcast,
|
|||||||
|
|
||||||
|
|
||||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
|
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
|
||||||
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ );
|
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ );
|
||||||
sub process_snat1( $$$$$$$$$$$$ );
|
sub process_snat1( $$$$$$$$$$$$ );
|
||||||
sub perl_action_helper( $$;$$ );
|
sub perl_action_helper( $$;$$ );
|
||||||
|
|
||||||
@@ -1980,10 +1970,10 @@ sub process_action(\$\$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elsif ( $type & MANGLE_TABLE ) {
|
} elsif ( $type & MANGLE_TABLE ) {
|
||||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time, $conditional );
|
||||||
|
|
||||||
if ( $family == F_IPV4 ) {
|
if ( $family == F_IPV4 ) {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time, $conditional ) =
|
||||||
split_line2( 'mangle file',
|
split_line2( 'mangle file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -2002,13 +1992,14 @@ sub process_action(\$\$$) {
|
|||||||
scp => 13,
|
scp => 13,
|
||||||
state => 14,
|
state => 14,
|
||||||
time => 15,
|
time => 15,
|
||||||
|
switch => 16,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
16,
|
17,
|
||||||
1 );
|
1 );
|
||||||
$headers = '-';
|
$headers = '-';
|
||||||
} else {
|
} else {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time, $conditional ) =
|
||||||
split_line2( 'action file',
|
split_line2( 'action file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -2028,9 +2019,10 @@ sub process_action(\$\$$) {
|
|||||||
dscp => 14,
|
dscp => 14,
|
||||||
state => 15,
|
state => 15,
|
||||||
time => 16,
|
time => 16,
|
||||||
|
switch => 17,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
17,
|
18,
|
||||||
1 );
|
1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2059,7 +2051,8 @@ sub process_action(\$\$$) {
|
|||||||
$probability ,
|
$probability ,
|
||||||
$dscp ,
|
$dscp ,
|
||||||
$state,
|
$state,
|
||||||
$time );
|
$time,
|
||||||
|
$conditional );
|
||||||
set_inline_matches( $matches );
|
set_inline_matches( $matches );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2090,17 +2083,17 @@ sub process_action(\$\$$) {
|
|||||||
|
|
||||||
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
||||||
process_snat1( $chainref,
|
process_snat1( $chainref,
|
||||||
$action,
|
$action,
|
||||||
$source,
|
$source,
|
||||||
$dest,
|
$dest,
|
||||||
$proto,
|
$proto,
|
||||||
$port,
|
$port,
|
||||||
$ipsec,
|
$ipsec,
|
||||||
$mark,
|
$mark,
|
||||||
$user,
|
$user,
|
||||||
$condition,
|
$condition,
|
||||||
$origdest,
|
$origdest,
|
||||||
$probability,
|
$probability,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2113,6 +2106,12 @@ sub process_action(\$\$$) {
|
|||||||
|
|
||||||
pop_open;
|
pop_open;
|
||||||
|
|
||||||
|
unless ( @{$chainref->{rules}} ) {
|
||||||
|
my $file = find_file( $action );
|
||||||
|
|
||||||
|
fatal_error "File action.${action} is empty and file $action exists - the two must be combined as described in the Migration Considerations section of the Shorewall release notes" if -f $file;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Pop the action parameters
|
# Pop the action parameters
|
||||||
#
|
#
|
||||||
@@ -2739,7 +2738,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
#
|
#
|
||||||
# Determine the validity of the action
|
# Determine the validity of the action
|
||||||
#
|
#
|
||||||
$actiontype = ( $targets{$basictarget} || find_macro ( $basictarget ) );
|
$actiontype = $targets{$basictarget} || find_macro( $basictarget );
|
||||||
|
|
||||||
if ( $config{ MAPOLDACTIONS } ) {
|
if ( $config{ MAPOLDACTIONS } ) {
|
||||||
( $basictarget, $actiontype , $param ) = map_old_actions( $basictarget ) unless $actiontype || supplied $param;
|
( $basictarget, $actiontype , $param ) = map_old_actions( $basictarget ) unless $actiontype || supplied $param;
|
||||||
@@ -2748,6 +2747,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
fatal_error "Unknown ACTION ($action)" unless $actiontype;
|
fatal_error "Unknown ACTION ($action)" unless $actiontype;
|
||||||
|
|
||||||
$usergenerated = $actiontype & IPTABLES;
|
$usergenerated = $actiontype & IPTABLES;
|
||||||
|
#
|
||||||
|
# For now, we'll just strip the parens from the SOURCE and DEST. In a later release, we might be able to do something more with them
|
||||||
|
#
|
||||||
|
|
||||||
if ( $actiontype == MACRO ) {
|
if ( $actiontype == MACRO ) {
|
||||||
#
|
#
|
||||||
@@ -2911,7 +2913,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
IPTABLES => sub {
|
IPTABLES => sub {
|
||||||
if ( $param ) {
|
if ( $param ) {
|
||||||
fatal_error "Unknown ACTION (IPTABLES)" unless $family == F_IPV4;
|
fatal_error "Unknown ACTION (IPTABLES)" unless $family == F_IPV4;
|
||||||
my ( $tgt, $options ) = split / /, $param;
|
my ( $tgt, $options ) = split / /, $param, 2;
|
||||||
my $target_type = $builtin_target{$tgt};
|
my $target_type = $builtin_target{$tgt};
|
||||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||||
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||||
@@ -2924,7 +2926,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
IP6TABLES => sub {
|
IP6TABLES => sub {
|
||||||
if ( $param ) {
|
if ( $param ) {
|
||||||
fatal_error "Unknown ACTION (IP6TABLES)" unless $family == F_IPV6;
|
fatal_error "Unknown ACTION (IP6TABLES)" unless $family == F_IPV6;
|
||||||
my ( $tgt, $options ) = split / /, $param;
|
my ( $tgt, $options ) = split / /, $param, 2;
|
||||||
my $target_type = $builtin_target{$tgt};
|
my $target_type = $builtin_target{$tgt};
|
||||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||||
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||||
@@ -3144,6 +3146,10 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
my $actionchain; # Name of the action chain
|
my $actionchain; # Name of the action chain
|
||||||
|
|
||||||
if ( $actiontype & ACTION ) {
|
if ( $actiontype & ACTION ) {
|
||||||
|
#
|
||||||
|
# Handle 'section' option
|
||||||
|
#
|
||||||
|
$param = supplied $param ? join( ',' , $section_rmap{$section}, $param ) : $section_rmap{$section} if $actions{$basictarget}{options} & SECTION_OPT;
|
||||||
#
|
#
|
||||||
# Create the action:level:tag:param tuple.
|
# Create the action:level:tag:param tuple.
|
||||||
#
|
#
|
||||||
@@ -3777,22 +3783,8 @@ sub build_zone_list( $$$\$\$ ) {
|
|||||||
#
|
#
|
||||||
# Process a Record in the rules file
|
# Process a Record in the rules file
|
||||||
#
|
#
|
||||||
sub process_raw_rule ( ) {
|
sub process_raw_rule1( $$$$$$$$$$$$$$$ ) {
|
||||||
my ( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $users, $mark, $connlimit, $time, $headers, $condition, $helper )
|
my ( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $users, $mark, $connlimit, $time, $headers, $condition, $helper ) = @_;
|
||||||
= split_line2( 'rules file',
|
|
||||||
\%rulecolumns,
|
|
||||||
$rule_commands,
|
|
||||||
undef, #Columns
|
|
||||||
1 ); #Allow inline matches
|
|
||||||
|
|
||||||
|
|
||||||
fatal_error 'ACTION must be specified' if $target eq '-';
|
|
||||||
#
|
|
||||||
# Section Names are optional so once we get to an actual rule, we need to be sure that
|
|
||||||
# we close off any missing sections.
|
|
||||||
#
|
|
||||||
next_section if $section != $next_section;
|
|
||||||
|
|
||||||
if ( $source =~ /^none(:.*)?$/i || $dest =~ /^none(:.*)?$/i ) {
|
if ( $source =~ /^none(:.*)?$/i || $dest =~ /^none(:.*)?$/i ) {
|
||||||
progress_message "Rule \"$currentline\" ignored.";
|
progress_message "Rule \"$currentline\" ignored.";
|
||||||
return 1;
|
return 1;
|
||||||
@@ -3858,6 +3850,48 @@ sub process_raw_rule ( ) {
|
|||||||
progress_message qq( Rule "$thisline" $done);
|
progress_message qq( Rule "$thisline" $done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub process_raw_rule ( ) {
|
||||||
|
my ( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $users, $mark, $connlimit, $time, $headers, $condition, $helper )
|
||||||
|
= split_line2( 'rules file',
|
||||||
|
\%rulecolumns,
|
||||||
|
$rule_commands,
|
||||||
|
undef, #Columns
|
||||||
|
1 ); #Allow inline matches
|
||||||
|
|
||||||
|
|
||||||
|
fatal_error 'ACTION must be specified' if $target eq '-';
|
||||||
|
#
|
||||||
|
# Section Names are optional so once we get to an actual rule, we need to be sure that
|
||||||
|
# we close off any missing sections.
|
||||||
|
#
|
||||||
|
next_section if $section != $next_section;
|
||||||
|
|
||||||
|
my ( @source, @dest );
|
||||||
|
|
||||||
|
if ( $source =~ /:\(.+\)/ ) {
|
||||||
|
@source = split_list3( $source, 'SOURCE' );
|
||||||
|
} else {
|
||||||
|
@source = ( $source );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $dest =~ /:\(.+\)/ ) {
|
||||||
|
@dest = split_list3( $dest, 'DEST' );
|
||||||
|
} else {
|
||||||
|
@dest = ( $dest );
|
||||||
|
}
|
||||||
|
|
||||||
|
for $source ( @source ) {
|
||||||
|
$source = join(':', $1, $2 ) if $source =~ /^(.+?):\((.+)\)$/;
|
||||||
|
|
||||||
|
for $dest ( @dest ) {
|
||||||
|
$dest = join( ':', $1, $2 ) if $dest =~ /^(.+?):\((.+)\)$/;
|
||||||
|
|
||||||
|
process_raw_rule1( $target, $source, $dest, $protos, $ports, $sports, $origdest, $ratelimit, $users, $mark, $connlimit, $time, $headers, $condition, $helper );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub intrazone_allowed( $$ ) {
|
sub intrazone_allowed( $$ ) {
|
||||||
my ( $zone, $zoneref ) = @_;
|
my ( $zone, $zoneref ) = @_;
|
||||||
|
|
||||||
@@ -3962,8 +3996,8 @@ sub process_rules() {
|
|||||||
$section = $next_section = DEFAULTACTION_SECTION;
|
$section = $next_section = DEFAULTACTION_SECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||||
my ($inline, $chainref, $params, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time ) = @_;
|
my ($inline, $chainref, $params, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time, $conditional ) = @_;
|
||||||
|
|
||||||
my $oldparms = push_action_params( $inline,
|
my $oldparms = push_action_params( $inline,
|
||||||
$chainref,
|
$chainref,
|
||||||
@@ -3982,9 +4016,9 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
my $save_comment = push_comment;
|
my $save_comment = push_comment;
|
||||||
|
|
||||||
while ( read_a_line( NORMAL_READ ) ) {
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
my ( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mheaders, $mprobability , $mdscp , $mstate, $mtime );
|
my ( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mheaders, $mprobability , $mdscp , $mstate, $mtime, $mconditional );
|
||||||
if ( $family == F_IPV4 ) {
|
if ( $family == F_IPV4 ) {
|
||||||
( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mprobability, $mdscp, $mstate, $mtime ) =
|
( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mprobability, $mdscp, $mstate, $mtime, $mconditional ) =
|
||||||
split_line2( 'mangle file',
|
split_line2( 'mangle file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -4003,13 +4037,14 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
scp => 13,
|
scp => 13,
|
||||||
state => 14,
|
state => 14,
|
||||||
time => 15,
|
time => 15,
|
||||||
|
switch => 16,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
16,
|
17,
|
||||||
1 );
|
1 );
|
||||||
$headers = $mheaders = '-';
|
$headers = $mheaders = '-';
|
||||||
} else {
|
} else {
|
||||||
( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mheaders, $mprobability, $mdscp, $mstate, $mtime ) =
|
( $moriginalmark, $msource, $mdest, $mprotos, $mports, $msports, $muser, $mtestval, $mlength, $mtos , $mconnbytes, $mhelper, $mheaders, $mprobability, $mdscp, $mstate, $mtime, $mconditional ) =
|
||||||
split_line2( 'mangle file',
|
split_line2( 'mangle file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -4029,9 +4064,10 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
dscp => 14,
|
dscp => 14,
|
||||||
state => 15,
|
state => 15,
|
||||||
time => 16,
|
time => 16,
|
||||||
|
switch => 17,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
17,
|
18,
|
||||||
1 );
|
1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4064,7 +4100,9 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
merge_macro_column( $mprobability , $probability ),
|
merge_macro_column( $mprobability , $probability ),
|
||||||
merge_macro_column( $mdscp , $dscp ),
|
merge_macro_column( $mdscp , $dscp ),
|
||||||
merge_macro_column( $mstate, $state ),
|
merge_macro_column( $mstate, $state ),
|
||||||
merge_macro_column( $mtime, $time ) );
|
merge_macro_column( $mtime, $time ),
|
||||||
|
merge_macro_column( $mconditional, $conditional ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_message " Rule \"$currentline\" $done";
|
progress_message " Rule \"$currentline\" $done";
|
||||||
@@ -4091,8 +4129,8 @@ sub process_mangle_inline( $$$$$$$$$$$$$$$$$$$ ) {
|
|||||||
# appended to that chain. The chain with be the action's chain unless the action
|
# appended to that chain. The chain with be the action's chain unless the action
|
||||||
# is inlined, in which case it will be the chain which invoked the action.
|
# is inlined, in which case it will be the chain which invoked the action.
|
||||||
#
|
#
|
||||||
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
|
||||||
my ( $chainref, $action, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time) = @_;
|
my ( $chainref, $action, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time, $condition) = @_;
|
||||||
|
|
||||||
my %designators = (
|
my %designators = (
|
||||||
P => PREROUTING,
|
P => PREROUTING,
|
||||||
@@ -4202,6 +4240,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
|||||||
do_headers( $headers ) .
|
do_headers( $headers ) .
|
||||||
do_probability( $probability ) .
|
do_probability( $probability ) .
|
||||||
do_dscp( $dscp ) .
|
do_dscp( $dscp ) .
|
||||||
|
do_condition( $condition, $chainref->{name} ) .
|
||||||
state_match( $state ) .
|
state_match( $state ) .
|
||||||
$raw_matches ,
|
$raw_matches ,
|
||||||
$source ,
|
$source ,
|
||||||
@@ -4495,7 +4534,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
|||||||
maxparams => 1,
|
maxparams => 1,
|
||||||
function => sub () {
|
function => sub () {
|
||||||
fatal_error "Invalid ACTION (IPTABLES)" unless $family == F_IPV4;
|
fatal_error "Invalid ACTION (IPTABLES)" unless $family == F_IPV4;
|
||||||
my ( $tgt, $options ) = split( ' ', $params );
|
my ( $tgt, $options ) = split( ' ', $params, 2 );
|
||||||
my $target_type = $builtin_target{$tgt};
|
my $target_type = $builtin_target{$tgt};
|
||||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
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 & MANGLE_TABLE;
|
||||||
@@ -4511,7 +4550,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
|||||||
maxparams => 1,
|
maxparams => 1,
|
||||||
function => sub () {
|
function => sub () {
|
||||||
fatal_error "Invalid ACTION (IP6TABLES)" unless $family == F_IPV6;
|
fatal_error "Invalid ACTION (IP6TABLES)" unless $family == F_IPV6;
|
||||||
my ( $tgt, $options ) = split( ' ', $params );
|
my ( $tgt, $options ) = split( ' ', $params, 2 );
|
||||||
my $target_type = $builtin_target{$tgt};
|
my $target_type = $builtin_target{$tgt};
|
||||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
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 & MANGLE_TABLE;
|
||||||
@@ -4797,7 +4836,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
|||||||
$probability ,
|
$probability ,
|
||||||
$dscp ,
|
$dscp ,
|
||||||
$state,
|
$state,
|
||||||
$time );
|
$time,
|
||||||
|
$condition );
|
||||||
$done = 1;
|
$done = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -4934,37 +4974,36 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
|||||||
|
|
||||||
$restriction |= $chainref->{restriction};
|
$restriction |= $chainref->{restriction};
|
||||||
|
|
||||||
if ( ( my $result = expand_rule( $chainref ,
|
expand_rule( $chainref ,
|
||||||
$restriction,
|
$restriction,
|
||||||
$prerule,
|
$prerule,
|
||||||
do_proto( $proto, $ports, $sports) . $matches .
|
do_proto( $proto, $ports, $sports) . $matches .
|
||||||
do_user( $user ) .
|
do_user( $user ) .
|
||||||
do_test( $testval, $globals{TC_MASK} ) .
|
do_test( $testval, $globals{TC_MASK} ) .
|
||||||
do_length( $length ) .
|
do_length( $length ) .
|
||||||
do_tos( $tos ) .
|
do_tos( $tos ) .
|
||||||
do_connbytes( $connbytes ) .
|
do_connbytes( $connbytes ) .
|
||||||
do_helper( $helper ) .
|
do_helper( $helper ) .
|
||||||
do_headers( $headers ) .
|
do_headers( $headers ) .
|
||||||
do_probability( $probability ) .
|
do_probability( $probability ) .
|
||||||
do_dscp( $dscp ) .
|
do_dscp( $dscp ) .
|
||||||
state_match( $state ) .
|
state_match( $state ) .
|
||||||
do_time( $time ) .
|
do_time( $time ) .
|
||||||
( $ttl ? "-t $ttl " : '' ) .
|
do_condition( $condition, $chainref->{name} ) .
|
||||||
$raw_matches ,
|
( $ttl ? "-t $ttl " : '' ) .
|
||||||
$source ,
|
$raw_matches ,
|
||||||
$dest ,
|
$source ,
|
||||||
'' ,
|
$dest ,
|
||||||
$target,
|
'' ,
|
||||||
'' ,
|
$target,
|
||||||
$target ,
|
'' ,
|
||||||
$exceptionrule ,
|
$target ,
|
||||||
$usergenerated ) )
|
$exceptionrule ,
|
||||||
&& $device ) {
|
$usergenerated ,
|
||||||
#
|
'' , # Log Name
|
||||||
# expand_rule() returns destination device if any
|
$device ,
|
||||||
#
|
$params
|
||||||
fatal_error "Class Id $params is not associated with device $result" if $device ne $result &&( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' );
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_message " Mangle Rule \"$currentline\" $done";
|
progress_message " Mangle Rule \"$currentline\" $done";
|
||||||
@@ -5139,50 +5178,50 @@ sub process_tc_rule( ) {
|
|||||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state );
|
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state );
|
||||||
if ( $family == F_IPV4 ) {
|
if ( $family == F_IPV4 ) {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state ) =
|
||||||
split_line2( 'tcrules file',
|
split_rawline2( 'tcrules file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
source => 1,
|
source => 1,
|
||||||
dest => 2,
|
dest => 2,
|
||||||
proto => 3,
|
proto => 3,
|
||||||
dport => 4,
|
dport => 4,
|
||||||
sport => 5,
|
sport => 5,
|
||||||
user => 6,
|
user => 6,
|
||||||
test => 7,
|
test => 7,
|
||||||
length => 8,
|
length => 8,
|
||||||
tos => 9,
|
tos => 9,
|
||||||
connbytes => 10,
|
connbytes => 10,
|
||||||
helper => 11,
|
helper => 11,
|
||||||
probability => 12 ,
|
probability => 12 ,
|
||||||
scp => 13,
|
scp => 13,
|
||||||
state => 14 },
|
state => 14 },
|
||||||
{},
|
{},
|
||||||
15,
|
15,
|
||||||
1 );
|
1 );
|
||||||
$headers = '-';
|
$headers = '-';
|
||||||
} else {
|
} else {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state ) =
|
||||||
split_line2( 'tcrules file',
|
split_rawline2( 'tcrules file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
source => 1,
|
source => 1,
|
||||||
dest => 2,
|
dest => 2,
|
||||||
proto => 3,
|
proto => 3,
|
||||||
dport => 4,
|
dport => 4,
|
||||||
sport => 5,
|
sport => 5,
|
||||||
user => 6,
|
user => 6,
|
||||||
test => 7,
|
test => 7,
|
||||||
length => 8,
|
length => 8,
|
||||||
tos => 9,
|
tos => 9,
|
||||||
connbytes => 10,
|
connbytes => 10,
|
||||||
helper => 11,
|
helper => 11,
|
||||||
headers => 12,
|
headers => 12,
|
||||||
probability => 13,
|
probability => 13,
|
||||||
dscp => 14,
|
dscp => 14,
|
||||||
state => 15 },
|
state => 15 },
|
||||||
{},
|
{},
|
||||||
16,
|
16,
|
||||||
1 );
|
1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
||||||
@@ -5192,9 +5231,9 @@ sub process_tc_rule( ) {
|
|||||||
|
|
||||||
sub process_mangle_rule( $ ) {
|
sub process_mangle_rule( $ ) {
|
||||||
my ( $chainref ) = @_;
|
my ( $chainref ) = @_;
|
||||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time, $conditional );
|
||||||
if ( $family == F_IPV4 ) {
|
if ( $family == F_IPV4 ) {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time, $conditional ) =
|
||||||
split_line2( 'mangle file',
|
split_line2( 'mangle file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -5213,13 +5252,14 @@ sub process_mangle_rule( $ ) {
|
|||||||
scp => 13,
|
scp => 13,
|
||||||
state => 14,
|
state => 14,
|
||||||
time => 15,
|
time => 15,
|
||||||
|
switch => 16,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
16,
|
17,
|
||||||
1 );
|
1 );
|
||||||
$headers = '-';
|
$headers = '-';
|
||||||
} else {
|
} else {
|
||||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) =
|
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time, $conditional ) =
|
||||||
split_line2( 'mangle file',
|
split_line2( 'mangle file',
|
||||||
{ mark => 0,
|
{ mark => 0,
|
||||||
action => 0,
|
action => 0,
|
||||||
@@ -5239,14 +5279,15 @@ sub process_mangle_rule( $ ) {
|
|||||||
dscp => 14,
|
dscp => 14,
|
||||||
state => 15,
|
state => 15,
|
||||||
time => 16,
|
time => 16,
|
||||||
|
switch => 17,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
17,
|
18,
|
||||||
1 );
|
1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
||||||
process_mangle_rule1( $chainref, $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
process_mangle_rule1( $chainref, $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time, $conditional );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ use strict;
|
|||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw( process_tc setup_tc );
|
our @EXPORT = qw( process_tc setup_tc );
|
||||||
our @EXPORT_OK = qw( process_tc_rule initialize );
|
our @EXPORT_OK = qw( initialize );
|
||||||
our $VERSION = 'MODULEVERSION';
|
our $VERSION = 'MODULEVERSION';
|
||||||
|
|
||||||
our %flow_keys = ( 'src' => 1,
|
our %flow_keys = ( 'src' => 1,
|
||||||
@@ -2150,6 +2150,50 @@ sub process_secmark_rule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub convert_one_tos( $ ) {
|
||||||
|
my ( $mangle ) = @_;
|
||||||
|
|
||||||
|
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
|
||||||
|
split_rawline2( 'tos file entry',
|
||||||
|
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 },
|
||||||
|
undef,
|
||||||
|
7 );
|
||||||
|
|
||||||
|
my $chain_designator = 'P';
|
||||||
|
|
||||||
|
decode_tos($tos, 1);
|
||||||
|
|
||||||
|
my ( $srczone , $source , $remainder );
|
||||||
|
|
||||||
|
if ( $family == F_IPV4 ) {
|
||||||
|
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
|
||||||
|
fatal_error 'Invalid SOURCE' if defined $remainder;
|
||||||
|
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
|
||||||
|
$srczone = $1;
|
||||||
|
$source = $2;
|
||||||
|
} else {
|
||||||
|
$srczone = $src;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $srczone eq firewall_zone ) {
|
||||||
|
$chain_designator = 'O';
|
||||||
|
$src = $source || '-';
|
||||||
|
} else {
|
||||||
|
$src =~ s/^all:?//;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dst =~ s/^all:?//;
|
||||||
|
|
||||||
|
$src = '-' unless supplied $src;
|
||||||
|
$dst = '-' unless supplied $dst;
|
||||||
|
$proto = '-' unless supplied $proto;
|
||||||
|
$ports = '-' unless supplied $ports;
|
||||||
|
$sports = '-' unless supplied $sports;
|
||||||
|
$mark = '-' unless supplied $mark;
|
||||||
|
|
||||||
|
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub convert_tos($$) {
|
sub convert_tos($$) {
|
||||||
my ( $mangle, $fn1 ) = @_;
|
my ( $mangle, $fn1 ) = @_;
|
||||||
@@ -2167,6 +2211,25 @@ sub convert_tos($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( my $fn = open_file 'tos' ) {
|
if ( my $fn = open_file 'tos' ) {
|
||||||
|
directive_callback(
|
||||||
|
sub ()
|
||||||
|
{
|
||||||
|
if ( $_[0] eq 'OMITTED' ) {
|
||||||
|
#
|
||||||
|
# Convert the raw rule
|
||||||
|
#
|
||||||
|
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
|
||||||
|
print $mangle "$_[1]\n";
|
||||||
|
} else {
|
||||||
|
convert_one_tos( $mangle );
|
||||||
|
$have_tos = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
first_entry(
|
first_entry(
|
||||||
sub {
|
sub {
|
||||||
my $date = compiletime;
|
my $date = compiletime;
|
||||||
@@ -2180,48 +2243,12 @@ sub convert_tos($$) {
|
|||||||
|
|
||||||
while ( read_a_line( NORMAL_READ ) ) {
|
while ( read_a_line( NORMAL_READ ) ) {
|
||||||
|
|
||||||
|
convert_one_tos( $mangle );
|
||||||
$have_tos = 1;
|
$have_tos = 1;
|
||||||
|
|
||||||
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
|
|
||||||
split_line( 'tos file entry',
|
|
||||||
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } );
|
|
||||||
|
|
||||||
my $chain_designator = 'P';
|
|
||||||
|
|
||||||
decode_tos($tos, 1);
|
|
||||||
|
|
||||||
my ( $srczone , $source , $remainder );
|
|
||||||
|
|
||||||
if ( $family == F_IPV4 ) {
|
|
||||||
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
|
|
||||||
fatal_error 'Invalid SOURCE' if defined $remainder;
|
|
||||||
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
|
|
||||||
$srczone = $1;
|
|
||||||
$source = $2;
|
|
||||||
} else {
|
|
||||||
$srczone = $src;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $srczone eq firewall_zone ) {
|
|
||||||
$chain_designator = 'O';
|
|
||||||
$src = $source || '-';
|
|
||||||
} else {
|
|
||||||
$src =~ s/^all:?//;
|
|
||||||
}
|
|
||||||
|
|
||||||
$dst =~ s/^all:?//;
|
|
||||||
|
|
||||||
$src = '-' unless supplied $src;
|
|
||||||
$dst = '-' unless supplied $dst;
|
|
||||||
$proto = '-' unless supplied $proto;
|
|
||||||
$ports = '-' unless supplied $ports;
|
|
||||||
$sports = '-' unless supplied $sports;
|
|
||||||
$mark = '-' unless supplied $mark;
|
|
||||||
|
|
||||||
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directive_callback(0);
|
||||||
|
|
||||||
if ( $have_tos ) {
|
if ( $have_tos ) {
|
||||||
progress_message2 "Converted $fn to $fn1";
|
progress_message2 "Converted $fn to $fn1";
|
||||||
if ( rename $fn, "$fn.bak" ) {
|
if ( rename $fn, "$fn.bak" ) {
|
||||||
@@ -2250,9 +2277,10 @@ sub open_mangle_for_output( $ ) {
|
|||||||
#
|
#
|
||||||
transfer_permissions( $fn, $fn1 );
|
transfer_permissions( $fn, $fn1 );
|
||||||
|
|
||||||
print $mangle <<'EOF';
|
if ( $family == F_IPV4 ) {
|
||||||
|
print $mangle <<'EOF';
|
||||||
#
|
#
|
||||||
# Shorewall version 4 - Mangle File
|
# Shorewall -- /etc/shorewall/mangle
|
||||||
#
|
#
|
||||||
# For information about entries in this file, type "man shorewall-mangle"
|
# For information about entries in this file, type "man shorewall-mangle"
|
||||||
#
|
#
|
||||||
@@ -2262,13 +2290,31 @@ sub open_mangle_for_output( $ ) {
|
|||||||
#
|
#
|
||||||
# See http://shorewall.net/PacketMarking.html for a detailed description of
|
# See http://shorewall.net/PacketMarking.html for a detailed description of
|
||||||
# the Netfilter/Shorewall packet marking mechanism.
|
# the Netfilter/Shorewall packet marking mechanism.
|
||||||
####################################################################################################################################################
|
##############################################################################################################################################################
|
||||||
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP
|
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH
|
||||||
# PORT(S) PORT(S)
|
EOF
|
||||||
|
} else {
|
||||||
|
print $mangle <<'EOF';
|
||||||
|
#
|
||||||
|
# Shorewall6 -- /etc/shorewall6/mangle
|
||||||
|
#
|
||||||
|
# For information about entries in this file, type "man shorewall6-mangle"
|
||||||
|
#
|
||||||
|
# See http://shorewall.net/traffic_shaping.htm for additional information.
|
||||||
|
# For usage in selecting among multiple ISPs, see
|
||||||
|
# http://shorewall.net/MultiISP.html
|
||||||
|
#
|
||||||
|
# See http://shorewall.net/PacketMarking.html for a detailed description of
|
||||||
|
# the Netfilter/Shorewall packet marking mechanism.
|
||||||
|
#
|
||||||
|
######################################################################################################################################################################
|
||||||
|
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST LENGTH TOS CONNBYTES HELPER HEADERS PROBABILITY DSCP SWITCH
|
||||||
EOF
|
EOF
|
||||||
}
|
|
||||||
|
|
||||||
return ( $mangle, $fn1 );
|
}
|
||||||
|
|
||||||
|
return ( $mangle, $fn1 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -2337,7 +2383,24 @@ sub setup_tc( $ ) {
|
|||||||
#
|
#
|
||||||
( $mangle, $fn1 ) = open_mangle_for_output( $fn );
|
( $mangle, $fn1 ) = open_mangle_for_output( $fn );
|
||||||
|
|
||||||
directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } );
|
directive_callback(
|
||||||
|
sub ()
|
||||||
|
{
|
||||||
|
if ( $_[0] eq 'OMITTED' ) {
|
||||||
|
#
|
||||||
|
# Convert the raw rule
|
||||||
|
#
|
||||||
|
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
|
||||||
|
print $mangle "$_[1]\n";
|
||||||
|
} else {
|
||||||
|
process_tc_rule;
|
||||||
|
$have_tcrules++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
first_entry(
|
first_entry(
|
||||||
sub {
|
sub {
|
||||||
|
@@ -1275,6 +1275,7 @@ sub process_interface( $$ ) {
|
|||||||
my $numval = numeric_value $value;
|
my $numval = numeric_value $value;
|
||||||
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
|
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
|
||||||
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
|
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
|
||||||
|
$options{logmartians} = 1 if $option eq 'routefilter' && $numval && ! $config{LOG_MARTIANS};
|
||||||
$options{$option} = $numval;
|
$options{$option} = $numval;
|
||||||
$hostoptions{$option} = $numval if $hostopt;
|
$hostoptions{$option} = $numval if $hostopt;
|
||||||
} elsif ( $type == IPLIST_IF_OPTION ) {
|
} elsif ( $type == IPLIST_IF_OPTION ) {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#! /usr/bin/perl -w
|
#! /usr/bin/perl -w
|
||||||
#
|
#
|
||||||
# The Shoreline Firewall Packet Filtering Firewall Compiler - V4.4
|
# The Shoreline Firewall Packet Filtering Firewall Compiler
|
||||||
#
|
#
|
||||||
# (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
|
# (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
|
||||||
#
|
#
|
||||||
|
@@ -38,12 +38,11 @@ fi
|
|||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
g_program=$PRODUCT
|
g_basedir=${SHAREDIR}/shorewall
|
||||||
g_sharedir="$SHAREDIR/shorewall"
|
|
||||||
g_confdir="$CONFDIR/$PRODUCT"
|
|
||||||
g_readrc=1
|
|
||||||
|
|
||||||
. $g_sharedir/lib.cli
|
. $g_basedir/lib.cli
|
||||||
|
|
||||||
|
setup_product_environment
|
||||||
|
|
||||||
CONFIG_PATH="$2"
|
CONFIG_PATH="$2"
|
||||||
|
|
||||||
|
@@ -349,7 +349,7 @@ replace_default_route() # $1 = USE_DEFAULT_RT
|
|||||||
case "$default_route" in
|
case "$default_route" in
|
||||||
*metric*)
|
*metric*)
|
||||||
#
|
#
|
||||||
# Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0
|
# Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes or =Exact. Otherwise, we only replace the one with metric 0
|
||||||
#
|
#
|
||||||
[ -n "$1" ] && qt $IP -$g_family route replace $default_route && progress_message "Default Route (${default_route# }) restored"
|
[ -n "$1" ] && qt $IP -$g_family route replace $default_route && progress_message "Default Route (${default_route# }) restored"
|
||||||
default_route=
|
default_route=
|
||||||
@@ -526,13 +526,6 @@ debug_restore_input() {
|
|||||||
qt1 $g_tool -t raw -P $chain ACCEPT
|
qt1 $g_tool -t raw -P $chain ACCEPT
|
||||||
done
|
done
|
||||||
|
|
||||||
qt1 $g_tool -t rawpost -F
|
|
||||||
qt1 $g_tool -t rawpost -X
|
|
||||||
|
|
||||||
for chain in POSTROUTING; do
|
|
||||||
qt1 $g_tool -t rawpost -P $chain ACCEPT
|
|
||||||
done
|
|
||||||
|
|
||||||
qt1 $g_tool -t nat -F
|
qt1 $g_tool -t nat -F
|
||||||
qt1 $g_tool -t nat -X
|
qt1 $g_tool -t nat -X
|
||||||
|
|
||||||
@@ -582,9 +575,6 @@ debug_restore_input() {
|
|||||||
'*'raw)
|
'*'raw)
|
||||||
table=raw
|
table=raw
|
||||||
;;
|
;;
|
||||||
'*'rawpost)
|
|
||||||
table=rawpost
|
|
||||||
;;
|
|
||||||
'*'mangle)
|
'*'mangle)
|
||||||
table=mangle
|
table=mangle
|
||||||
;;
|
;;
|
||||||
|
@@ -130,6 +130,8 @@ g_docker=
|
|||||||
g_dockernetwork=
|
g_dockernetwork=
|
||||||
g_forcereload=
|
g_forcereload=
|
||||||
|
|
||||||
|
[ -n "$SERVICEDIR" ] && SUBSYSLOCK=
|
||||||
|
|
||||||
initialize
|
initialize
|
||||||
|
|
||||||
if [ -n "$STARTUP_LOG" ]; then
|
if [ -n "$STARTUP_LOG" ]; then
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Shorewall Version 4.4 -- /etc/shorewall/shorewall.conf
|
# Shorewall Version 5 -- /etc/shorewall/shorewall.conf
|
||||||
#
|
#
|
||||||
# For information about the settings in this file, type "man shorewall.conf"
|
# For information about the settings in this file, type "man shorewall.conf"
|
||||||
#
|
#
|
||||||
@@ -47,11 +47,11 @@ LOGALLNEW=
|
|||||||
|
|
||||||
LOGFILE=/var/log/messages
|
LOGFILE=/var/log/messages
|
||||||
|
|
||||||
LOGFORMAT="Shorewall:%s:%s:"
|
LOGFORMAT="%s %s "
|
||||||
|
|
||||||
LOGTAGONLY=No
|
LOGTAGONLY=No
|
||||||
|
|
||||||
LOGLIMIT=
|
LOGLIMIT="s:1/sec:10"
|
||||||
|
|
||||||
MACLIST_LOG_LEVEL=info
|
MACLIST_LOG_LEVEL=info
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ UNTRACKED_LOG_LEVEL=
|
|||||||
|
|
||||||
ARPTABLES=
|
ARPTABLES=
|
||||||
|
|
||||||
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
|
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||||
|
|
||||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||||
|
|
||||||
@@ -108,6 +108,7 @@ TC=
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
ACCEPT_DEFAULT="none"
|
ACCEPT_DEFAULT="none"
|
||||||
|
BLACKLIST_DEFAULT="Drop"
|
||||||
DROP_DEFAULT="Drop"
|
DROP_DEFAULT="Drop"
|
||||||
NFQUEUE_DEFAULT="none"
|
NFQUEUE_DEFAULT="none"
|
||||||
QUEUE_DEFAULT="none"
|
QUEUE_DEFAULT="none"
|
||||||
@@ -140,12 +141,12 @@ AUTOHELPERS=Yes
|
|||||||
|
|
||||||
AUTOMAKE=Yes
|
AUTOMAKE=Yes
|
||||||
|
|
||||||
|
BALANCE_PROVIDERS=No
|
||||||
|
|
||||||
BASIC_FILTERS=No
|
BASIC_FILTERS=No
|
||||||
|
|
||||||
BLACKLIST="NEW,INVALID,UNTRACKED"
|
BLACKLIST="NEW,INVALID,UNTRACKED"
|
||||||
|
|
||||||
CHAIN_SCRIPTS=No
|
|
||||||
|
|
||||||
CLAMPMSS=No
|
CLAMPMSS=No
|
||||||
|
|
||||||
CLEAR_TC=Yes
|
CLEAR_TC=Yes
|
||||||
@@ -293,5 +294,3 @@ PROVIDER_OFFSET=
|
|||||||
MASK_BITS=
|
MASK_BITS=
|
||||||
|
|
||||||
ZONE_BITS=0
|
ZONE_BITS=0
|
||||||
|
|
||||||
#LAST LINE -- DO NOT REMOVE
|
|
||||||
|
@@ -58,11 +58,11 @@ LOGALLNEW=
|
|||||||
|
|
||||||
LOGFILE=/var/log/messages
|
LOGFILE=/var/log/messages
|
||||||
|
|
||||||
LOGFORMAT="Shorewall:%s:%s:"
|
LOGFORMAT="%s %s "
|
||||||
|
|
||||||
LOGTAGONLY=No
|
LOGTAGONLY=No
|
||||||
|
|
||||||
LOGLIMIT=
|
LOGLIMIT="s:1/sec:10"
|
||||||
|
|
||||||
MACLIST_LOG_LEVEL=info
|
MACLIST_LOG_LEVEL=info
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ UNTRACKED_LOG_LEVEL=
|
|||||||
|
|
||||||
ARPTABLES=
|
ARPTABLES=
|
||||||
|
|
||||||
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
|
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||||
|
|
||||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||||
|
|
||||||
@@ -119,6 +119,7 @@ TC=
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
ACCEPT_DEFAULT="none"
|
ACCEPT_DEFAULT="none"
|
||||||
|
BLACKLIST_DEFAULT="Drop"
|
||||||
DROP_DEFAULT="Drop"
|
DROP_DEFAULT="Drop"
|
||||||
NFQUEUE_DEFAULT="none"
|
NFQUEUE_DEFAULT="none"
|
||||||
QUEUE_DEFAULT="none"
|
QUEUE_DEFAULT="none"
|
||||||
@@ -151,12 +152,12 @@ AUTOHELPERS=Yes
|
|||||||
|
|
||||||
AUTOMAKE=Yes
|
AUTOMAKE=Yes
|
||||||
|
|
||||||
|
BALANCE_PROVIDERS=No
|
||||||
|
|
||||||
BASIC_FILTERS=No
|
BASIC_FILTERS=No
|
||||||
|
|
||||||
BLACKLIST="NEW,INVALID,UNTRACKED"
|
BLACKLIST="NEW,INVALID,UNTRACKED"
|
||||||
|
|
||||||
CHAIN_SCRIPTS=No
|
|
||||||
|
|
||||||
CLAMPMSS=No
|
CLAMPMSS=No
|
||||||
|
|
||||||
CLEAR_TC=Yes
|
CLEAR_TC=Yes
|
||||||
@@ -304,5 +305,3 @@ PROVIDER_OFFSET=
|
|||||||
MASK_BITS=
|
MASK_BITS=
|
||||||
|
|
||||||
ZONE_BITS=0
|
ZONE_BITS=0
|
||||||
|
|
||||||
#LAST LINE -- DO NOT REMOVE
|
|
||||||
|
@@ -55,11 +55,11 @@ LOGALLNEW=
|
|||||||
|
|
||||||
LOGFILE=/var/log/messages
|
LOGFILE=/var/log/messages
|
||||||
|
|
||||||
LOGFORMAT="Shorewall:%s:%s:"
|
LOGFORMAT="%s %s "
|
||||||
|
|
||||||
LOGTAGONLY=No
|
LOGTAGONLY=No
|
||||||
|
|
||||||
LOGLIMIT=
|
LOGLIMIT="s:1/sec:10"
|
||||||
|
|
||||||
MACLIST_LOG_LEVEL=info
|
MACLIST_LOG_LEVEL=info
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ UNTRACKED_LOG_LEVEL=
|
|||||||
|
|
||||||
ARPTABLES=
|
ARPTABLES=
|
||||||
|
|
||||||
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
|
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||||
|
|
||||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||||
|
|
||||||
@@ -116,6 +116,7 @@ TC=
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
ACCEPT_DEFAULT="none"
|
ACCEPT_DEFAULT="none"
|
||||||
|
BLACKLIST_DEFAULT="Drop"
|
||||||
DROP_DEFAULT="Drop"
|
DROP_DEFAULT="Drop"
|
||||||
NFQUEUE_DEFAULT="none"
|
NFQUEUE_DEFAULT="none"
|
||||||
QUEUE_DEFAULT="none"
|
QUEUE_DEFAULT="none"
|
||||||
@@ -148,12 +149,12 @@ AUTOHELPERS=Yes
|
|||||||
|
|
||||||
AUTOMAKE=Yes
|
AUTOMAKE=Yes
|
||||||
|
|
||||||
|
BALANCE_PROVIDERS=No
|
||||||
|
|
||||||
BASIC_FILTERS=No
|
BASIC_FILTERS=No
|
||||||
|
|
||||||
BLACKLIST="NEW,INVALID,UNTRACKED"
|
BLACKLIST="NEW,INVALID,UNTRACKED"
|
||||||
|
|
||||||
CHAIN_SCRIPTS=No
|
|
||||||
|
|
||||||
CLAMPMSS=Yes
|
CLAMPMSS=Yes
|
||||||
|
|
||||||
CLEAR_TC=Yes
|
CLEAR_TC=Yes
|
||||||
@@ -301,5 +302,3 @@ PROVIDER_OFFSET=
|
|||||||
MASK_BITS=
|
MASK_BITS=
|
||||||
|
|
||||||
ZONE_BITS=0
|
ZONE_BITS=0
|
||||||
|
|
||||||
#LAST LINE -- DO NOT REMOVE
|
|
||||||
|
@@ -58,11 +58,11 @@ LOGALLNEW=
|
|||||||
|
|
||||||
LOGFILE=/var/log/messages
|
LOGFILE=/var/log/messages
|
||||||
|
|
||||||
LOGFORMAT="Shorewall:%s:%s:"
|
LOGFORMAT="%s %s "
|
||||||
|
|
||||||
LOGTAGONLY=No
|
LOGTAGONLY=No
|
||||||
|
|
||||||
LOGLIMIT=
|
LOGLIMIT="s:1/sec:10"
|
||||||
|
|
||||||
MACLIST_LOG_LEVEL=info
|
MACLIST_LOG_LEVEL=info
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ UNTRACKED_LOG_LEVEL=
|
|||||||
|
|
||||||
ARPTABLES=
|
ARPTABLES=
|
||||||
|
|
||||||
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
|
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||||
|
|
||||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||||
|
|
||||||
@@ -119,6 +119,7 @@ TC=
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
ACCEPT_DEFAULT="none"
|
ACCEPT_DEFAULT="none"
|
||||||
|
BLACKLIST_DEFAULT="Drop"
|
||||||
DROP_DEFAULT="Drop"
|
DROP_DEFAULT="Drop"
|
||||||
NFQUEUE_DEFAULT="none"
|
NFQUEUE_DEFAULT="none"
|
||||||
QUEUE_DEFAULT="none"
|
QUEUE_DEFAULT="none"
|
||||||
@@ -151,12 +152,12 @@ AUTOHELPERS=Yes
|
|||||||
|
|
||||||
AUTOMAKE=Yes
|
AUTOMAKE=Yes
|
||||||
|
|
||||||
|
BALANCE_PROVIDERS=No
|
||||||
|
|
||||||
BASIC_FILTERS=No
|
BASIC_FILTERS=No
|
||||||
|
|
||||||
BLACKLIST="NEW,INVALID,UNTRACKED"
|
BLACKLIST="NEW,INVALID,UNTRACKED"
|
||||||
|
|
||||||
CHAIN_SCRIPTS=No
|
|
||||||
|
|
||||||
CLAMPMSS=Yes
|
CLAMPMSS=Yes
|
||||||
|
|
||||||
CLEAR_TC=Yes
|
CLEAR_TC=Yes
|
||||||
@@ -304,5 +305,3 @@ PROVIDER_OFFSET=
|
|||||||
MASK_BITS=
|
MASK_BITS=
|
||||||
|
|
||||||
ZONE_BITS=0
|
ZONE_BITS=0
|
||||||
|
|
||||||
#LAST LINE -- DO NOT REMOVE
|
|
||||||
|
@@ -9,44 +9,43 @@
|
|||||||
# Builtin Actions are:
|
# Builtin Actions are:
|
||||||
#
|
#
|
||||||
?if 0
|
?if 0
|
||||||
A_ACCEPT # Audits then accepts a connection request
|
allowBcast # Silently Allow Broadcast/multicast
|
||||||
A_DROP # Audits then drops a connection request
|
dropBcast # Silently Drop Broadcast/multicast
|
||||||
allowBcast # Silently Allow Broadcast/multicast
|
dropNotSyn # Silently Drop Non-syn TCP packets
|
||||||
dropBcast # Silently Drop Broadcast/multicast
|
rejNotSyn # Silently Reject Non-syn TCP packets
|
||||||
dropNotSyn # Silently Drop Non-syn TCP packets
|
allowinUPnP # Allow UPnP inbound (to firewall) traffic
|
||||||
rejNotSyn # Silently Reject Non-syn TCP packets
|
forwardUPnP # Allow traffic that upnpd has redirected from 'upnp' interfaces.
|
||||||
allowinUPnP # Allow UPnP inbound (to firewall) traffic
|
Limit # Limit the rate of connections from each individual IP address
|
||||||
forwardUPnP # Allow traffic that upnpd has redirected from 'upnp' interfaces.
|
|
||||||
Limit # Limit the rate of connections from each individual IP address
|
|
||||||
?endif
|
?endif
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#ACTION
|
#ACTION
|
||||||
A_Drop # Audited Default Action for DROP policy
|
A_Drop # Audited Default Action for DROP policy
|
||||||
A_REJECT noinline,logjump # Audits then rejects a connection request
|
A_REJECT noinline,logjump # Audits then rejects a connection request
|
||||||
A_REJECT! inline # Audits then rejects a connection request
|
A_REJECT! inline # Audits then rejects a connection request
|
||||||
A_Reject # Audited Default action for REJECT policy
|
A_Reject # Audited Default action for REJECT policy
|
||||||
allowInvalid inline # Accepts packets in the INVALID conntrack state
|
allowInvalid inline # Accepts packets in the INVALID conntrack state
|
||||||
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
||||||
AutoBLL noinline # Helper for AutoBL
|
AutoBLL noinline # Helper for AutoBL
|
||||||
Broadcast noinline,audit # Handles Broadcast/Multicast/Anycast
|
BLACKLIST logjump,section # Add sender to the dynamic blacklist
|
||||||
DNSAmp # Matches one-question recursive DNS queries
|
Broadcast noinline,audit # Handles Broadcast/Multicast/Anycast
|
||||||
Drop # Default Action for DROP policy
|
DNSAmp # Matches one-question recursive DNS queries
|
||||||
|
Drop # Default Action for DROP policy
|
||||||
dropInvalid inline # Drops packets in the INVALID conntrack state
|
dropInvalid inline # Drops packets in the INVALID conntrack state
|
||||||
DropSmurfs noinline # Drop smurf packets
|
DropSmurfs noinline # Drop smurf packets
|
||||||
Established inline,\ # Handles packets in the ESTABLISHED state
|
Established inline,\ # Handles packets in the ESTABLISHED state
|
||||||
state=ESTABLISHED #
|
state=ESTABLISHED #
|
||||||
GlusterFS inline # Handles GlusterFS
|
GlusterFS inline # Handles GlusterFS
|
||||||
IfEvent noinline # Perform an action based on an event
|
IfEvent noinline # Perform an action based on an event
|
||||||
Invalid inline,audit,\ # Handles packets in the INVALID conntrack state
|
Invalid inline,audit,\ # Handles packets in the INVALID conntrack state
|
||||||
state=INVALID #
|
state=INVALID #
|
||||||
New inline,state=NEW # Handles packets in the NEW conntrack state
|
New inline,state=NEW # Handles packets in the NEW conntrack state
|
||||||
NotSyn inline,audit # Handles TCP packets which do not have SYN=1 and ACK=0
|
NotSyn inline,audit # Handles TCP packets which do not have SYN=1 and ACK=0
|
||||||
Reject # Default Action for REJECT policy
|
Reject # Default Action for REJECT policy
|
||||||
Related inline,\ # Handles packets in the RELATED conntrack state
|
Related inline,\ # Handles packets in the RELATED conntrack state
|
||||||
state=RELATED #
|
state=RELATED #
|
||||||
ResetEvent inline # Reset an Event
|
ResetEvent inline # Reset an Event
|
||||||
RST inline,audit # Handle packets with RST set
|
RST inline,audit # Handle packets with RST set
|
||||||
SetEvent inline # Initialize an event
|
SetEvent inline # Initialize an event
|
||||||
TCPFlags # Handle bad flag combinations.
|
TCPFlags # Handle bad flag combinations.
|
||||||
Untracked inline,\ # Handles packets in the UNTRACKED conntrack state
|
Untracked inline,\ # Handles packets in the UNTRACKED conntrack state
|
||||||
state=UNTRACKED #
|
state=UNTRACKED #
|
||||||
|
@@ -10,5 +10,5 @@
|
|||||||
# See http://shorewall.net/PacketMarking.html for a detailed description of
|
# See http://shorewall.net/PacketMarking.html for a detailed description of
|
||||||
# the Netfilter/Shorewall packet marking mechanism.
|
# the Netfilter/Shorewall packet marking mechanism.
|
||||||
#
|
#
|
||||||
####################################################################################################################################################
|
##############################################################################################################################################################
|
||||||
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP
|
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH
|
||||||
|
@@ -47,11 +47,11 @@ LOGALLNEW=
|
|||||||
|
|
||||||
LOGFILE=/var/log/messages
|
LOGFILE=/var/log/messages
|
||||||
|
|
||||||
LOGFORMAT="Shorewall:%s:%s:"
|
LOGFORMAT="%s %s "
|
||||||
|
|
||||||
LOGTAGONLY=No
|
LOGTAGONLY=No
|
||||||
|
|
||||||
LOGLIMIT=
|
LOGLIMIT="s:1/sec:10"
|
||||||
|
|
||||||
MACLIST_LOG_LEVEL=info
|
MACLIST_LOG_LEVEL=info
|
||||||
|
|
||||||
@@ -108,6 +108,7 @@ TC=
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
ACCEPT_DEFAULT=none
|
ACCEPT_DEFAULT=none
|
||||||
|
BLACKLIST_DEFAULT=Drop
|
||||||
DROP_DEFAULT=Drop
|
DROP_DEFAULT=Drop
|
||||||
NFQUEUE_DEFAULT=none
|
NFQUEUE_DEFAULT=none
|
||||||
QUEUE_DEFAULT=none
|
QUEUE_DEFAULT=none
|
||||||
@@ -138,14 +139,14 @@ AUTOCOMMENT=Yes
|
|||||||
|
|
||||||
AUTOHELPERS=Yes
|
AUTOHELPERS=Yes
|
||||||
|
|
||||||
AUTOMAKE=No
|
AUTOMAKE=Yes
|
||||||
|
|
||||||
|
BALANCE_PROVIDERS=No
|
||||||
|
|
||||||
BASIC_FILTERS=No
|
BASIC_FILTERS=No
|
||||||
|
|
||||||
BLACKLIST="NEW,INVALID,UNTRACKED"
|
BLACKLIST="NEW,INVALID,UNTRACKED"
|
||||||
|
|
||||||
CHAIN_SCRIPTS=Yes
|
|
||||||
|
|
||||||
CLAMPMSS=No
|
CLAMPMSS=No
|
||||||
|
|
||||||
CLEAR_TC=Yes
|
CLEAR_TC=Yes
|
||||||
@@ -184,7 +185,7 @@ INLINE_MATCHES=No
|
|||||||
|
|
||||||
IPSET_WARNINGS=Yes
|
IPSET_WARNINGS=Yes
|
||||||
|
|
||||||
IP_FORWARDING=On
|
IP_FORWARDING=Keep
|
||||||
|
|
||||||
KEEP_RT_TABLES=No
|
KEEP_RT_TABLES=No
|
||||||
|
|
||||||
@@ -210,7 +211,7 @@ MUTEX_TIMEOUT=60
|
|||||||
|
|
||||||
NULL_ROUTE_RFC1918=No
|
NULL_ROUTE_RFC1918=No
|
||||||
|
|
||||||
OPTIMIZE=0
|
OPTIMIZE=All
|
||||||
|
|
||||||
OPTIMIZE_ACCOUNTING=No
|
OPTIMIZE_ACCOUNTING=No
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ wait_for_pppd () {
|
|||||||
|
|
||||||
# start the firewall
|
# start the firewall
|
||||||
shorewall_start () {
|
shorewall_start () {
|
||||||
echo -n "Starting \"Shorewall firewall\": "
|
printf "Starting \"Shorewall firewall\": "
|
||||||
wait_for_pppd
|
wait_for_pppd
|
||||||
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
@@ -98,10 +98,10 @@ shorewall_start () {
|
|||||||
# stop the firewall
|
# stop the firewall
|
||||||
shorewall_stop () {
|
shorewall_stop () {
|
||||||
if [ "$SAFESTOP" = 1 ]; then
|
if [ "$SAFESTOP" = 1 ]; then
|
||||||
echo -n "Stopping \"Shorewall firewall\": "
|
printf "Stopping \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
else
|
else
|
||||||
echo -n "Clearing all \"Shorewall firewall\" rules: "
|
printf "Clearing all \"Shorewall firewall\" rules: "
|
||||||
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -109,21 +109,21 @@ shorewall_stop () {
|
|||||||
|
|
||||||
# reload the firewall
|
# reload the firewall
|
||||||
shorewall_reload () {
|
shorewall_reload () {
|
||||||
echo -n "Reloading \"Shorewall firewall\": "
|
printf "Reloading \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS restart $RELOADOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS restart $RELOADOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# restart the firewall
|
# restart the firewall
|
||||||
shorewall_restart () {
|
shorewall_restart () {
|
||||||
echo -n "Restarting \"Shorewall firewall\": "
|
printf "Restarting \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# refresh the firewall
|
# refresh the firewall
|
||||||
shorewall_refresh () {
|
shorewall_refresh () {
|
||||||
echo -n "Refreshing \"Shorewall firewall\": "
|
printf "Refreshing \"Shorewall firewall\": "
|
||||||
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ if [ -f ${SYSCONFDIR}/$prog ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo -n $"Starting Shorewall: "
|
printf $"Starting Shorewall: "
|
||||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -52,7 +52,7 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo -n $"Stopping Shorewall: "
|
printf $"Stopping Shorewall: "
|
||||||
$shorewall $OPTIONS stop 2>&1 | $logger
|
$shorewall $OPTIONS stop 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -66,7 +66,7 @@ stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
echo -n $"Reloading Shorewall: "
|
printf $"Reloading Shorewall: "
|
||||||
$shorewall $OPTIONS reload $RELOADOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS reload $RELOADOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -83,7 +83,7 @@ reload() {
|
|||||||
restart() {
|
restart() {
|
||||||
# Note that we don't simply stop and start since shorewall has a built in
|
# Note that we don't simply stop and start since shorewall has a built in
|
||||||
# restart which stops the firewall if running and then starts it.
|
# restart which stops the firewall if running and then starts it.
|
||||||
echo -n $"Restarting Shorewall: "
|
printf $"Restarting Shorewall: "
|
||||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
|
@@ -103,7 +103,7 @@ require()
|
|||||||
|
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname $0)"
|
||||||
|
|
||||||
if [ -f shorewall ]; then
|
if [ -f shorewall.service ]; then
|
||||||
PRODUCT=shorewall
|
PRODUCT=shorewall
|
||||||
Product=Shorewall
|
Product=Shorewall
|
||||||
else
|
else
|
||||||
@@ -175,7 +175,6 @@ if [ $# -eq 0 ]; then
|
|||||||
. ./shorewallrc
|
. ./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
|
||||||
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
@@ -381,9 +380,9 @@ fi
|
|||||||
echo "Installing $Product Version $VERSION"
|
echo "Installing $Product Version $VERSION"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for /sbin/$PRODUCT
|
# Check for /usr/share/$PRODUCT/version
|
||||||
#
|
#
|
||||||
if [ -f ${DESTDIR}${SBINDIR}/$PRODUCT ]; then
|
if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
|
||||||
first_install=""
|
first_install=""
|
||||||
else
|
else
|
||||||
first_install="Yes"
|
first_install="Yes"
|
||||||
@@ -394,10 +393,6 @@ if [ -z "${DESTDIR}" -a $PRODUCT = shorewall -a ! -f ${SHAREDIR}/$PRODUCT/coreve
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0755
|
|
||||||
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/${PRODUCT}
|
|
||||||
echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install the Firewall Script
|
# Install the Firewall Script
|
||||||
#
|
#
|
||||||
@@ -1047,18 +1042,11 @@ fi
|
|||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
#
|
|
||||||
# Install the Makefiles
|
|
||||||
#
|
|
||||||
run_install $OWNERSHIP -m 0644 Makefile-lite ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/Makefile
|
|
||||||
|
|
||||||
if [ -z "$SPARSE" ]; then
|
|
||||||
run_install $OWNERSHIP -m 0600 Makefile ${DESTDIR}${CONFDIR}/$PRODUCT
|
|
||||||
echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile"
|
|
||||||
fi
|
|
||||||
#
|
#
|
||||||
# Install the Action files
|
# Install the Action files
|
||||||
#
|
#
|
||||||
|
cd Actions
|
||||||
|
|
||||||
for f in action.* ; do
|
for f in action.* ; do
|
||||||
case $f in
|
case $f in
|
||||||
*.deprecated)
|
*.deprecated)
|
||||||
@@ -1071,8 +1059,10 @@ for f in action.* ; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
#
|
||||||
cd Macros
|
# Now the Macros
|
||||||
|
#
|
||||||
|
cd ../Macros
|
||||||
|
|
||||||
for f in macro.* ; do
|
for f in macro.* ; do
|
||||||
case $f in
|
case $f in
|
||||||
@@ -1104,7 +1094,10 @@ if [ $PRODUCT = shorewall6 ]; then
|
|||||||
# Symbolically link 'functions' to lib.base
|
# Symbolically link 'functions' to lib.base
|
||||||
#
|
#
|
||||||
ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions
|
ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions
|
||||||
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
|
#
|
||||||
|
# And create a sybolic link for the CLI
|
||||||
|
#
|
||||||
|
ln -sf shorewall ${DESTDIR}${SBINDIR}/shorewall6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d Perl ]; then
|
if [ -d Perl ]; then
|
||||||
@@ -1179,7 +1172,7 @@ if [ -n "$MANDIR" ]; then
|
|||||||
|
|
||||||
cd manpages
|
cd manpages
|
||||||
|
|
||||||
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
|
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man5/
|
||||||
|
|
||||||
for f in *.5; do
|
for f in *.5; do
|
||||||
gzip -9c $f > $f.gz
|
gzip -9c $f > $f.gz
|
||||||
@@ -1187,6 +1180,8 @@ for f in *.5; do
|
|||||||
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man8/
|
||||||
|
|
||||||
for f in *.8; do
|
for f in *.8; do
|
||||||
gzip -9c $f > $f.gz
|
gzip -9c $f > $f.gz
|
||||||
run_install $INSTALLD -m 0644 $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz
|
run_install $INSTALLD -m 0644 $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz
|
||||||
|
@@ -48,10 +48,10 @@ get_config() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
config=$(find_file $g_program.conf)
|
config=$(find_file ${PRODUCT}.conf)
|
||||||
else
|
else
|
||||||
[ -n "$g_shorewalldir" ] || fatal_error "Ordinary users may not $COMMAND the $CONFDIR/$g_program configuration"
|
[ -n "$g_shorewalldir" ] || fatal_error "Ordinary users may not $COMMAND the $CONFDIR/$PRODUCT configuration"
|
||||||
config="$g_shorewalldir/$g_program.conf"
|
config="$g_shorewalldir/$PRODUCT.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $config ]; then
|
if [ -f $config ]; then
|
||||||
@@ -155,7 +155,7 @@ get_config() {
|
|||||||
if [ "$2" = Yes ]; then
|
if [ "$2" = Yes ]; then
|
||||||
case $STARTUP_ENABLED in
|
case $STARTUP_ENABLED in
|
||||||
No|no|NO)
|
No|no|NO)
|
||||||
not_configured_error "$g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${g_confdir}/${g_program}.conf"
|
not_configured_error "$g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${g_confdir}/${PRODUCT}.conf"
|
||||||
;;
|
;;
|
||||||
Yes|yes|YES)
|
Yes|yes|YES)
|
||||||
;;
|
;;
|
||||||
@@ -318,21 +318,23 @@ get_config() {
|
|||||||
|
|
||||||
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
|
||||||
|
|
||||||
if [ -n "$PAGER" -a -t 1 ]; then
|
if [ -z "$g_nopager" ]; then
|
||||||
case $PAGER in
|
if [ -n "$PAGER" -a -t 1 ]; then
|
||||||
/*)
|
case $PAGER in
|
||||||
g_pager="$PAGER"
|
/*)
|
||||||
[ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist"
|
g_pager="$PAGER"
|
||||||
;;
|
[ -f "$g_pager" ] || fatal_error "PAGER $PAGER does not exist"
|
||||||
*)
|
;;
|
||||||
g_pager=$(mywhich $PAGER 2> /dev/null)
|
*)
|
||||||
[ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found"
|
g_pager=$(mywhich $PAGER 2> /dev/null)
|
||||||
;;
|
[ -n "$g_pager" ] || fatal_error "PAGER $PAGER not found"
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
|
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
|
||||||
|
|
||||||
g_pager="| $g_pager"
|
g_pager="| $g_pager"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DYNAMIC_BLACKLIST" ]; then
|
if [ -n "$DYNAMIC_BLACKLIST" ]; then
|
||||||
@@ -395,8 +397,8 @@ compiler() {
|
|||||||
pc=${LIBEXECDIR}/shorewall/compiler.pl
|
pc=${LIBEXECDIR}/shorewall/compiler.pl
|
||||||
|
|
||||||
if [ $(id -u) -ne 0 ]; then
|
if [ $(id -u) -ne 0 ]; then
|
||||||
if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = $CONFDIR/$g_program ]; then
|
if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = $CONFDIR/$PRODUCT ]; then
|
||||||
startup_error "Ordinary users may not $COMMAND the $CONFDIR/$g_program configuration"
|
startup_error "Ordinary users may not $COMMAND the $CONFDIR/$PRODUCT configuration"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#
|
#
|
||||||
@@ -441,20 +443,21 @@ compiler() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
options="--verbose=$VERBOSITY --family=$g_family --config_path=$CONFIG_PATH --shorewallrc=${shorewallrc}"
|
options="--verbose=$VERBOSITY --family=$g_family --config_path=$CONFIG_PATH --shorewallrc=${shorewallrc}"
|
||||||
[ -n "$shorewallrc1" ] && options="$options --shorewallrc1=${shorewallrc1}"
|
|
||||||
[ -n "$STARTUP_LOG" ] && options="$options --log=$STARTUP_LOG"
|
[ -n "$shorewallrc1" ] && options="$options --shorewallrc1=${shorewallrc1}"
|
||||||
[ -n "$LOG_VERBOSITY" ] && options="$options --log_verbosity=$LOG_VERBOSITY";
|
[ -n "$STARTUP_LOG" ] && options="$options --log=$STARTUP_LOG"
|
||||||
[ -n "$g_export" ] && options="$options --export"
|
[ -n "$LOG_VERBOSITY" ] && options="$options --log_verbosity=$LOG_VERBOSITY";
|
||||||
[ -n "$g_shorewalldir" ] && options="$options --directory=$g_shorewalldir"
|
[ -n "$g_export" ] && options="$options --export"
|
||||||
[ -n "$g_timestamp" ] && options="$options --timestamp"
|
[ -n "$g_shorewalldir" ] && options="$options --directory=$g_shorewalldir"
|
||||||
[ -n "$g_test" ] && options="$options --test"
|
[ -n "$g_timestamp" ] && options="$options --timestamp"
|
||||||
[ -n "$g_preview" ] && options="$options --preview"
|
[ -n "$g_test" ] && options="$options --test"
|
||||||
|
[ -n "$g_preview" ] && options="$options --preview"
|
||||||
[ "$g_debugging" = trace ] && options="$options --debug"
|
[ "$g_debugging" = trace ] && options="$options --debug"
|
||||||
[ -n "$g_refreshchains" ] && options="$options --refresh=$g_refreshchains"
|
[ -n "$g_refreshchains" ] && options="$options --refresh=$g_refreshchains"
|
||||||
[ -n "$g_confess" ] && options="$options --confess"
|
[ -n "$g_confess" ] && options="$options --confess"
|
||||||
[ -n "$g_update" ] && options="$options --update"
|
[ -n "$g_update" ] && options="$options --update"
|
||||||
[ -n "$g_annotate" ] && options="$options --annotate"
|
[ -n "$g_annotate" ] && options="$options --annotate"
|
||||||
[ -n "$g_inline" ] && options="$options --inline"
|
[ -n "$g_inline" ] && options="$options --inline"
|
||||||
|
|
||||||
if [ -n "$PERL" ]; then
|
if [ -n "$PERL" ]; then
|
||||||
if [ ! -x "$PERL" ]; then
|
if [ ! -x "$PERL" ]; then
|
||||||
@@ -1227,13 +1230,13 @@ safe_commands() {
|
|||||||
|
|
||||||
if run_it ${VARDIR}/.$command $g_debugging $command; then
|
if run_it ${VARDIR}/.$command $g_debugging $command; then
|
||||||
|
|
||||||
echo -n "Do you want to accept the new firewall configuration? [y/n] "
|
printf "Do you want to accept the new firewall configuration? [y/n] "
|
||||||
|
|
||||||
if read_yesno_with_timeout $timeout ; then
|
if read_yesno_with_timeout $timeout ; then
|
||||||
echo "New configuration has been accepted"
|
echo "New configuration has been accepted"
|
||||||
else
|
else
|
||||||
if [ "$command" = "restart" -o "$command" = "reload" ]; then
|
if [ "$command" = "restart" -o "$command" = "reload" ]; then
|
||||||
run_it ${VARDIR}/.safe restore
|
run_it ${VARDIR}/.safe -r restore
|
||||||
else
|
else
|
||||||
run_it ${VARDIR}/.$command clear
|
run_it ${VARDIR}/.$command clear
|
||||||
fi
|
fi
|
||||||
@@ -1417,6 +1420,7 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
sharedir=${SHAREDIR}
|
sharedir=${SHAREDIR}
|
||||||
local litedir
|
local litedir
|
||||||
local exitstatus
|
local exitstatus
|
||||||
|
local program
|
||||||
|
|
||||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||||
option=$1
|
option=$1
|
||||||
@@ -1493,12 +1497,17 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
sbindir="$SBINDIR"
|
sbindir="$SBINDIR"
|
||||||
confdir="$CONFDIR"
|
confdir="$CONFDIR"
|
||||||
libexec="$LIBEXECDIR"
|
libexec="$LIBEXECDIR"
|
||||||
|
litedir="${VARDIR}-lite"
|
||||||
. $sharedir/shorewall/shorewallrc
|
. $sharedir/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
error_message " WARNING: $g_shorewalldir/shorewallrc does not exist; using settings from $SHAREDIR/shorewall" >&2
|
error_message " WARNING: $g_shorewalldir/shorewallrc does not exist; using settings from $g_basedir/shorewalrc" >&2
|
||||||
|
sbindir="$SBINDIR"
|
||||||
|
confdir="$CONFDIR"
|
||||||
|
libexec="$LIBEXECDIR"
|
||||||
|
litedir="${VARDIR}-lite"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $g_shorewalldir/${g_program}.conf ]; then
|
if [ -f $g_shorewalldir/${PRODUCT}.conf ]; then
|
||||||
if [ -f $g_shorewalldir/params ]; then
|
if [ -f $g_shorewalldir/params ]; then
|
||||||
. $g_shorewalldir/params
|
. $g_shorewalldir/params
|
||||||
fi
|
fi
|
||||||
@@ -1514,7 +1523,7 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
[ -n "$system" ] || fatal_error "No system name given and the FIREWALL option is not set"
|
[ -n "$system" ] || fatal_error "No system name given and the FIREWALL option is not set"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
fatal_error "$g_shorewalldir/$g_program.conf does not exist"
|
fatal_error "$g_shorewalldir/$PRODUCT.conf does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$getcaps" ]; then
|
if [ -z "$getcaps" ]; then
|
||||||
@@ -1539,12 +1548,14 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
|
|
||||||
g_export=Yes
|
g_export=Yes
|
||||||
|
|
||||||
temp=$(rsh_command ${g_program}-lite show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
|
program=$sbindir/${PRODUCT}-lite
|
||||||
|
#
|
||||||
|
# Handle nonstandard remote VARDIR
|
||||||
|
#
|
||||||
|
temp=$(rsh_command $program show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
|
||||||
|
|
||||||
[ -n "$temp" ] && litedir="$temp"
|
[ -n "$temp" ] && litedir="$temp"
|
||||||
|
|
||||||
[ -n "$litedir" ] || litedir=${VARLIB}/${g_program}-lite
|
|
||||||
|
|
||||||
g_file="$g_shorewalldir/firewall"
|
g_file="$g_shorewalldir/firewall"
|
||||||
|
|
||||||
exitstatus=0
|
exitstatus=0
|
||||||
@@ -1555,30 +1566,29 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
save=$(find_file save);
|
save=$(find_file save);
|
||||||
|
|
||||||
if [ -f $save ]; then
|
if [ -f $save ]; then
|
||||||
progress_message3 "Copying $save to ${system}:${confdir}/${g_program}-lite/"
|
progress_message3 "Copying $save to ${system}:${confdir}/${PRODUCT}-lite/"
|
||||||
rcp_command $save ${confdir}/shorewall-lite/
|
rcp_command $save ${confdir}/$PRODUCT/
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $exitstatus -eq 0 ]; then
|
if [ $exitstatus -eq 0 ]; then
|
||||||
|
|
||||||
progress_message3 "Copy complete"
|
progress_message3 "Copy complete"
|
||||||
|
|
||||||
if [ $COMMAND = remote-reload ]; then
|
if [ $COMMAND = remote-reload ]; then
|
||||||
if rsh_command "${sbindir}/${g_program}-lite $g_debugging $verbose $timestamp reload"; then
|
if rsh_command "$program $g_debugging $verbose $timestamp reload"; then
|
||||||
progress_message3 "System $system reloaded"
|
progress_message3 "System $system reloaded"
|
||||||
else
|
else
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
savit=
|
savit=
|
||||||
fi
|
fi
|
||||||
elif [ $COMMAND = remote-restart ]; then
|
elif [ $COMMAND = remote-restart ]; then
|
||||||
if rsh_command "${sbindir}/${g_program}-lite $g_debugging $verbose $timestamp restart"; then
|
if rsh_command "$program $g_debugging $verbose $timestamp restart"; then
|
||||||
progress_message3 "System $system restarted"
|
progress_message3 "System $system restarted"
|
||||||
else
|
else
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
saveit=
|
saveit=
|
||||||
fi
|
fi
|
||||||
elif rsh_command "${sbindir}/${g_program}-lite $g_debugging $verbose $timestamp start"; then
|
elif rsh_command "$program $g_debugging $verbose $timestamp start"; then
|
||||||
progress_message3 "System $system started"
|
progress_message3 "System $system started"
|
||||||
else
|
else
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
@@ -1586,7 +1596,7 @@ remote_reload_command() # $* = original arguments less the command.
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$saveit" ]; then
|
if [ -n "$saveit" ]; then
|
||||||
if rsh_command "${sbindir}/${g_program}-lite $g_debugging $verbose $timestamp save"; then
|
if rsh_command "$program $g_debugging $verbose $timestamp save"; then
|
||||||
progress_message3 "Configuration on system $system saved"
|
progress_message3 "Configuration on system $system saved"
|
||||||
else
|
else
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
@@ -1651,7 +1661,7 @@ export_command() # $* = original arguments less the command.
|
|||||||
target=$2
|
target=$2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fatal_error "Invalid command syntax (\"man $g_program\" for help)"
|
fatal_error "Invalid command syntax (\"man shorewall\" for help)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@@ -191,6 +191,25 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>section</option></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 5.1.1. When specified, this option
|
||||||
|
causes the rules file section name and a comma to be prepended
|
||||||
|
to the parameters passed to the action (if any). Note that
|
||||||
|
this means that the first parameter passed to the action by
|
||||||
|
the user is actually the second parameter to the action. If
|
||||||
|
the action is invoked out of the blrules file, 'BLACKLIST' is
|
||||||
|
used as the section name.</para>
|
||||||
|
|
||||||
|
<para>Given that neither the <filename>snat</filename> nor the
|
||||||
|
<filename>mangle</filename> file is sectioned, this parameter
|
||||||
|
has no effect when <option>mangle</option> or
|
||||||
|
<option>nat</option> is specified. </para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>state</option>={<option>UNTRACKED</option>|<option>NEW</option>|<option>ESTABLISHED</option>|<option>RELATED</option>|<option>INVALID</option>}</term>
|
<term><option>state</option>={<option>UNTRACKED</option>|<option>NEW</option>|<option>ESTABLISHED</option>|<option>RELATED</option>|<option>INVALID</option>}</term>
|
||||||
|
|
||||||
@@ -205,9 +224,9 @@
|
|||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Added in Shorewall 4.6.4. When used with
|
<para>Added in Shorewall 4.6.4. When used with
|
||||||
<replaceable>builtin</replaceable>, indicates that the
|
<option>builtin</option>, indicates that the built-in action
|
||||||
built-in action is termiating (i.e., if the action is jumped
|
is termiating (i.e., if the action is jumped to, the next rule
|
||||||
to, the next rule in the chain is not evaluated).</para>
|
in the chain is not evaluated).</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
@@ -380,7 +380,7 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>SOURCE (format 3) ‒
|
<term>SOURCE (format 3 prior to Shorewall 5.1.0) ‒
|
||||||
{-|<emphasis>interface</emphasis>[:<emphasis>address-list</emphasis>]|<replaceable>address-list</replaceable>}</term>
|
{-|<emphasis>interface</emphasis>[:<emphasis>address-list</emphasis>]|<replaceable>address-list</replaceable>}</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -394,7 +394,91 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>DEST ‒
|
<term><emphasis role="bold">SOURCE (format 3 on Shorewall 5.1.0 and
|
||||||
|
later) -
|
||||||
|
{-|[<replaceable>source-spec</replaceable>[,...]]}</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>source-spec</replaceable> is one of the
|
||||||
|
following:</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>interface</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Where interface is the logical name of an interface
|
||||||
|
defined in <ulink
|
||||||
|
url="shorewall-interfaces.html">shorewall-interface</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>address</replaceable> may be:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>A host or network IP address.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>A MAC address in Shorewall format (preceded by a
|
||||||
|
tilde ("~") and using dash ("-") as a separator.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The name of an ipset preceded by a plus sign ("+").
|
||||||
|
See <ulink
|
||||||
|
url="shorewall-ipsets.html">shorewall-ipsets</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para><replaceable>exclusion</replaceable> is described in
|
||||||
|
<ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form combines the preceding two and requires that
|
||||||
|
both the incoming interace and source address match.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>See <ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>
|
||||||
|
(5)</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, multiple
|
||||||
|
<replaceable>source-spec</replaceable>s separated by commas may be
|
||||||
|
specified provided that the following alternative forms are
|
||||||
|
used:</para>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<para>(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para>(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
</blockquote>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>DEST (Prior to Shorewall 5.1.0) ‒
|
||||||
{-|<emphasis>interface</emphasis>[:<emphasis>address-list</emphasis>]|<replaceable>address-list</replaceable>}</term>
|
{-|<emphasis>interface</emphasis>[:<emphasis>address-list</emphasis>]|<replaceable>address-list</replaceable>}</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -406,6 +490,89 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis role="bold">DEST (Shorewall 5.1.0 and later) -
|
||||||
|
{-|<replaceable>dest-spec</replaceable>[,...]}</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>dest-spec</replaceable> is one of the
|
||||||
|
following:</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>interface</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Where interface is the logical name of an interface
|
||||||
|
defined in <ulink
|
||||||
|
url="shorewall-interfaces.html">shorewall-interface</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>address</replaceable> may be:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>A host or network IP address.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>A MAC address in Shorewall format (preceded by a
|
||||||
|
tilde ("~") and using dash ("-") as a separator.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The name of an ipset preceded by a plus sign ("+").
|
||||||
|
See <ulink
|
||||||
|
url="shorewall-ipsets.html">shorewall-ipsets</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para><replaceable>exclusion</replaceable> is described in
|
||||||
|
<ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form combines the preceding two and requires that
|
||||||
|
both the outgoing interace and destination address
|
||||||
|
match.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>See <ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>
|
||||||
|
(5)</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, multiple source-specs
|
||||||
|
separated by commas may be specified provided that the following
|
||||||
|
alternative forms are used:</para>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<para>(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para>(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
</blockquote>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>PROTO ‒
|
<term>PROTO ‒
|
||||||
<replaceable>protocol-name-or-number</replaceable>[,...]</term>
|
<replaceable>protocol-name-or-number</replaceable>[,...]</term>
|
||||||
|
@@ -762,6 +762,13 @@ loc eth2 -</programlisting>
|
|||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.1, when
|
||||||
|
<option>routefilter</option> is set to a non-zero value, the
|
||||||
|
<option>logmartians</option> option is also implicitly set. If
|
||||||
|
you actually want route filtering without logging, then you
|
||||||
|
must also specify <option>logmartians=0</option> after
|
||||||
|
<option>routefilter</option>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@@ -774,7 +781,7 @@ loc eth2 -</programlisting>
|
|||||||
iptables and kernel. It provides a more efficient alternative
|
iptables and kernel. It provides a more efficient alternative
|
||||||
to the <option>sfilter</option> option below. It performs a
|
to the <option>sfilter</option> option below. It performs a
|
||||||
function similar to <option>routefilter</option> (see above)
|
function similar to <option>routefilter</option> (see above)
|
||||||
but works with Multi-ISP configurations that do now use
|
but works with Multi-ISP configurations that do not use
|
||||||
balanced routes.</para>
|
balanced routes.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@@ -775,98 +775,253 @@ Normal-Service => 0x00</programlisting>
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">SOURCE</emphasis> - {<emphasis
|
<term><emphasis role="bold">SOURCE -
|
||||||
role="bold">-</emphasis>|{<emphasis>interface</emphasis>|<emphasis
|
{-|<replaceable>source-spec</replaceable>[,...]}</emphasis></term>
|
||||||
role="bold">$FW</emphasis>}|[{<emphasis>interface</emphasis>|<emphasis
|
|
||||||
role="bold">$FW</emphasis>}:]<emphasis>address-or-range</emphasis>[<emphasis
|
|
||||||
role="bold">,</emphasis><emphasis>address-or-range</emphasis>]...}[<emphasis>exclusion</emphasis>]</term>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>May be:</para>
|
<para>where <replaceable>source-spec</replaceable> is one of:</para>
|
||||||
|
|
||||||
<orderedlist>
|
<variablelist>
|
||||||
<listitem>
|
<varlistentry>
|
||||||
<para>An interface name - matches traffic entering the firewall
|
<term><replaceable>interface</replaceable></term>
|
||||||
on the specified interface. May not be used in classify rules or
|
|
||||||
in rules using the :T chain qualifier.</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>A comma-separated list of host or network IP addresses or
|
<para>where <replaceable>interface</replaceable> is the
|
||||||
MAC addresses. <emphasis role="bold">This form will not match
|
logical name of an interface defined in <ulink
|
||||||
traffic that originates on the firewall itself unless either
|
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
||||||
<major><minor> or the :T chain qualifier is used in
|
Matches packets entering the firewall from the named
|
||||||
the ACTION column.</emphasis></para>
|
interface. May not be used in CLASSIFY rules or in rules using
|
||||||
|
the :T chain qualifier.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<para>Examples:<simplelist>
|
<varlistentry>
|
||||||
<member>0.0.0.0/0</member>
|
<term><replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
</simplelist></para>
|
|
||||||
|
|
||||||
<para><simplelist>
|
<listitem>
|
||||||
<member>192.168.1.0/24, 172.20.4.0/24</member>
|
<para>where <replaceable>address</replaceable> is:</para>
|
||||||
</simplelist></para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<blockquote>
|
||||||
<para>An interface name followed by a colon (":") followed by a
|
<para>A host or network IP address.</para>
|
||||||
comma-separated list of host or network IP addresses or MAC
|
|
||||||
addresses. May not be used in classify rules or in rules using
|
|
||||||
the :T chain qualifier.</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<para>The name of an ipset preceded by a plus sign
|
||||||
<para>$FW optionally followed by a colon (":") and a
|
("+").</para>
|
||||||
comma-separated list of host or network IP addresses. Matches
|
|
||||||
packets originating on the firewall. May not be used with a
|
|
||||||
chain qualifier (:P, :F, etc.) in the ACTION column.</para>
|
|
||||||
</listitem>
|
|
||||||
</orderedlist>
|
|
||||||
|
|
||||||
<para>MAC addresses must be prefixed with "~" and use "-" as a
|
<para>A MAC address in Shorewall format (preceded by a tilde
|
||||||
separator.</para>
|
("~") and using dash ("-") as a separator (e.g.,
|
||||||
|
~00-A0-C9-15-39-78).</para>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
<para>Example: ~00-A0-C9-15-39-78</para>
|
<para>Matches traffic whose source IP address matches one of
|
||||||
|
the listed addresses and that does not match an address listed
|
||||||
|
in the <replaceable>exclusion</replaceable> (see <ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
|
||||||
<para>You may exclude certain hosts from the set already defined
|
<para><emphasis role="bold">This form will not match traffic
|
||||||
through use of an <emphasis>exclusion</emphasis> (see <ulink
|
that originates on the firewall itself unless either
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
<major><minor> or the :T chain qualifier is used
|
||||||
|
in the ACTION column.</emphasis></para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<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>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<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>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Matches packets originating on the firewall system. May
|
||||||
|
not be used with a chain qualifier (:P, :F, etc.) in the
|
||||||
|
ACTION column.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW:<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>address</replaceable> is as above
|
||||||
|
(MAC addresses are not permitted). Matches packets originating
|
||||||
|
on the firewall and whose source IP address matches one of the
|
||||||
|
listed addresses and does not match any address listed in the
|
||||||
|
<replaceable>exclusion</replaceable>. May not be used with a
|
||||||
|
chain qualifier (:P, :F, etc.) in the ACTION column. </para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Matches traffic originating on the firewall, provided
|
||||||
|
that the source IP address does not match any address listed
|
||||||
|
in the <replaceable>exclusion</replaceable>.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, multiple
|
||||||
|
<replaceable>source_spec</replaceable>s, separated by commas, may be
|
||||||
|
given provided that the following alternative forms are used:</para>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<para>(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
|
||||||
|
<para>$FW:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para>$FW:(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
</blockquote>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">DEST</emphasis> - {<emphasis
|
<term><emphasis role="bold">DEST -
|
||||||
role="bold">-</emphasis>|{<emphasis>interface</emphasis>|$FW}|[<emphasis>{interface</emphasis>|$FW}:]<emphasis>address-or-range</emphasis>[<emphasis
|
{-|<replaceable>dest-spec</replaceable>[,...]}</emphasis></term>
|
||||||
role="bold">,</emphasis><emphasis>address-or-range</emphasis>]...}[<emphasis>exclusion</emphasis>]</term>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>May be:</para>
|
<para>where <replaceable>dest-spec</replaceable> is one of:</para>
|
||||||
|
|
||||||
<orderedlist>
|
<variablelist>
|
||||||
<listitem>
|
<varlistentry>
|
||||||
<para>An interface name. May not be used in the PREROUTING chain
|
<term><replaceable>interface</replaceable></term>
|
||||||
(:P in the mark column or no chain qualifier and
|
|
||||||
MARK_IN_FORWARD_CHAIN=No in <ulink
|
|
||||||
url="manpages/shorewall.conf">shorewall.conf</ulink> (5)). The
|
|
||||||
interface name may be optionally followed by a colon (":") and
|
|
||||||
an IP address list.</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>A comma-separated list of host or network IP addresses.
|
<para>where <replaceable>interface</replaceable> is the
|
||||||
The list may include ip address ranges if your kernel and
|
logical name of an interface defined in <ulink
|
||||||
iptables include iprange support.</para>
|
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
||||||
</listitem>
|
Matches packets leaving the firewall through the named
|
||||||
|
interface. May not be used in the PREROUTING chain (:P in the
|
||||||
|
mark column or no chain qualifier and MARK_IN_FORWARD_CHAIN=No
|
||||||
|
in <ulink url="manpages/shorewall.conf">shorewall.conf</ulink>
|
||||||
|
(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<listitem>
|
<varlistentry>
|
||||||
<para>Beginning with Shorewall 4.4.13, $FW may be specified by
|
<term><replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
itself or qualified by an address list. This causes marking to
|
|
||||||
occur in the INPUT chain.</para>
|
|
||||||
</listitem>
|
|
||||||
</orderedlist>
|
|
||||||
|
|
||||||
<para>You may exclude certain hosts from the set already defined
|
<listitem>
|
||||||
through use of an <emphasis>exclusion</emphasis> (see <ulink
|
<para>where <replaceable>address</replaceable> is:</para>
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
|
||||||
|
<blockquote>
|
||||||
|
<para>A host or network IP address.</para>
|
||||||
|
|
||||||
|
<para>The name of an ipset preceded by a plus sign
|
||||||
|
("+").</para>
|
||||||
|
|
||||||
|
<para>A MAC address in Shorewall format (preceded by a tilde
|
||||||
|
("~") and using dash ("-") as a separator (e.g.,
|
||||||
|
~00-A0-C9-15-39-78).</para>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<para>Matches traffic whose destination IP address matches one
|
||||||
|
of the listed addresses and that does not match an address
|
||||||
|
listed in the <replaceable>exclusion</replaceable> (see <ulink
|
||||||
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<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 outgoing interface and destination IP address
|
||||||
|
match. May not be used in the PREROUTING chain (:P in the mark
|
||||||
|
column or no chain qualifier and MARK_IN_FORWARD_CHAIN=No in
|
||||||
|
<ulink url="manpages/shorewall.conf">shorewall.conf</ulink>
|
||||||
|
(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form matches packets leaving through the named
|
||||||
|
<replaceable>interface</replaceable> and whose destination IP
|
||||||
|
address does not match any of the addresses in the
|
||||||
|
<replaceable>exclusion</replaceable>. May not be used in the
|
||||||
|
PREROUTING chain (:P in the mark column or no chain qualifier
|
||||||
|
and MARK_IN_FORWARD_CHAIN=No in <ulink
|
||||||
|
url="manpages/shorewall.conf">shorewall.conf</ulink>
|
||||||
|
(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Matches packets originating on the firewall system. May
|
||||||
|
not be used with a chain qualifier (:P, :F, etc.) in the
|
||||||
|
ACTION column.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW:<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where <replaceable>address</replaceable> is as above
|
||||||
|
(MAC addresses are not permitted). Matches packets destined
|
||||||
|
for the firewall and whose destination IP address matches one
|
||||||
|
of the listed addresses and does not match any address listed
|
||||||
|
in the <replaceable>exclusion</replaceable>. May not be used
|
||||||
|
with a chain qualifier (:P, :F, etc.) in the ACTION
|
||||||
|
column.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Matches traffic destined for the firewall, provided that
|
||||||
|
the destination IP address does not match any address listed
|
||||||
|
in the <replaceable>exclusion</replaceable>.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, multiple
|
||||||
|
<replaceable>dest_spec</replaceable>s, separated by commas, may be
|
||||||
|
given provided that the following alternative forms are used:</para>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<para>(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para><replaceable>interface</replaceable>:(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
|
||||||
|
<para>$FW:(<replaceable>address</replaceable>[,...][<replaceable>exclusion</replaceable>])</para>
|
||||||
|
|
||||||
|
<para>$FW:(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
</blockquote>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@@ -1332,6 +1487,53 @@ Normal-Service => 0x00</programlisting>
|
|||||||
</variablelist>
|
</variablelist>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis role="bold">SWITCH -
|
||||||
|
[!]<replaceable>switch-name</replaceable>[={0|1}]</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 5.1.0 and allows enabling and disabling the
|
||||||
|
rule without requiring <command>shorewall restart</command>.</para>
|
||||||
|
|
||||||
|
<para>The rule is enabled if the value stored in
|
||||||
|
<filename>/proc/net/nf_condition/<replaceable>switch-name</replaceable></filename>
|
||||||
|
is 1. The rule is disabled if that file contains 0 (the default). If
|
||||||
|
'!' is supplied, the test is inverted such that the rule is enabled
|
||||||
|
if the file contains 0.</para>
|
||||||
|
|
||||||
|
<para>Within the <replaceable>switch-name</replaceable>, '@0' and
|
||||||
|
'@{0}' are replaced by the name of the chain to which the rule is a
|
||||||
|
added. The <replaceable>switch-name</replaceable> (after '@...'
|
||||||
|
expansion) must begin with a letter and be composed of letters,
|
||||||
|
decimal digits, underscores or hyphens. Switch names must be 30
|
||||||
|
characters or less in length.</para>
|
||||||
|
|
||||||
|
<para>Switches are normally <emphasis role="bold">off</emphasis>. To
|
||||||
|
turn a switch <emphasis role="bold">on</emphasis>:</para>
|
||||||
|
|
||||||
|
<simplelist>
|
||||||
|
<member><command>echo 1 >
|
||||||
|
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
|
||||||
|
</simplelist>
|
||||||
|
|
||||||
|
<para>To turn it <emphasis role="bold">off</emphasis> again:</para>
|
||||||
|
|
||||||
|
<simplelist>
|
||||||
|
<member><command>echo 0 >
|
||||||
|
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
|
||||||
|
</simplelist>
|
||||||
|
|
||||||
|
<para>Switch settings are retained over <command>shorewall
|
||||||
|
restart</command>.</para>
|
||||||
|
|
||||||
|
<para>When the <replaceable>switch-name</replaceable> is followed by
|
||||||
|
<option>=0</option> or <option>=1</option>, then the switch is
|
||||||
|
initialized to off or on respectively by the
|
||||||
|
<command>start</command> command. Other commands do not affect the
|
||||||
|
switch setting.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@@ -41,38 +41,18 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">TYPE</emphasis> - <emphasis
|
<term><emphasis role="bold">TYPE</emphasis> - <emphasis
|
||||||
role="bold">{DNAT</emphasis>|<emphasis
|
role="bold">{DNAT</emphasis>|<emphasis
|
||||||
role="bold">SNAT}[:{P|O|T}</emphasis>]</term>
|
role="bold">SNAT}</emphasis></term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Must be DNAT or SNAT; beginning with Shorewall 4.4.23, may be
|
<para>Must be DNAT or SNAT</para>
|
||||||
optionally followed by :P, :O or :T to perform <firstterm>stateless
|
|
||||||
NAT</firstterm>. Stateless NAT requires <firstterm>Rawpost Table
|
|
||||||
support</firstterm> in your kernel and iptables (see the output of
|
|
||||||
<command>shorewall show capabilities</command>).</para>
|
|
||||||
|
|
||||||
<para>If DNAT or DNAT:P, traffic entering INTERFACE and addressed to
|
<para>If DNAT, traffic entering INTERFACE and addressed to NET1 has
|
||||||
NET1 has its destination address rewritten to the corresponding
|
its destination address rewritten to the corresponding address in
|
||||||
address in NET2.</para>
|
NET2.</para>
|
||||||
|
|
||||||
<para>If SNAT or SNAT:T, traffic leaving INTERFACE with a source
|
<para>If SNAT, traffic leaving INTERFACE with a source address in
|
||||||
address in NET1 has it's source address rewritten to the
|
NET1 has it's source address rewritten to the corresponding address
|
||||||
corresponding address in NET2.</para>
|
in NET2.</para>
|
||||||
|
|
||||||
<para>If DNAT:O, traffic originating on the firewall and leaving via
|
|
||||||
INTERFACE and addressed to NET1 has its destination address
|
|
||||||
rewritten to the corresponding address in NET2.</para>
|
|
||||||
|
|
||||||
<para>If DNAT:P, traffic entering via INTERFACE and addressed to
|
|
||||||
NET1 has its destination address rewritten to the corresponding
|
|
||||||
address in NET2.</para>
|
|
||||||
|
|
||||||
<para>If SNAT:P, traffic entering via INTERFACE with a destination
|
|
||||||
address in NET1 has it's source address rewritten to the
|
|
||||||
corresponding address in NET2.</para>
|
|
||||||
|
|
||||||
<para>If SNAT:O, traffic originating on the firewall and leaving via
|
|
||||||
INTERFACE with a source address in NET1 has it's source address
|
|
||||||
rewritten to the corresponding address in NET2.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@@ -115,6 +115,7 @@
|
|||||||
role="bold">ACCEPT</emphasis>|<emphasis
|
role="bold">ACCEPT</emphasis>|<emphasis
|
||||||
role="bold">DROP</emphasis>|<emphasis
|
role="bold">DROP</emphasis>|<emphasis
|
||||||
role="bold">REJECT</emphasis>|<emphasis
|
role="bold">REJECT</emphasis>|<emphasis
|
||||||
|
role="bold">BLACKLIST</emphasis>|<emphasis
|
||||||
role="bold">CONTINUE</emphasis>|<emphasis
|
role="bold">CONTINUE</emphasis>|<emphasis
|
||||||
role="bold">QUEUE</emphasis>|<emphasis
|
role="bold">QUEUE</emphasis>|<emphasis
|
||||||
role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber1</emphasis>[:<replaceable>queuenumber2</replaceable>])]|<emphasis
|
role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber1</emphasis>[:<replaceable>queuenumber2</replaceable>])]|<emphasis
|
||||||
@@ -177,6 +178,19 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis role="bold">BLACKLIST</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 5.1.1 and requires that the
|
||||||
|
DYNAMIC_BLACKLIST setting in <ulink
|
||||||
|
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5)
|
||||||
|
specifies ipset-based dynamic blacklisting. The SOURCE IP
|
||||||
|
address is added to the blacklist ipset and the connection
|
||||||
|
request is ignored.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">QUEUE</emphasis></term>
|
<term><emphasis role="bold">QUEUE</emphasis></term>
|
||||||
|
|
||||||
|
@@ -208,6 +208,16 @@
|
|||||||
<option>balance=</option><replaceable>weight</replaceable>
|
<option>balance=</option><replaceable>weight</replaceable>
|
||||||
where <replaceable>weight</replaceable> is the weight of the
|
where <replaceable>weight</replaceable> is the weight of the
|
||||||
route out of this interface.</para>
|
route out of this interface.</para>
|
||||||
|
|
||||||
|
<para>Prior to Shorewall 5.1.1, when USE_DEFAULT_RT=Yes,
|
||||||
|
<option>balance=1</option> is assumed unless the
|
||||||
|
<option>fallback</option>, <option>loose</option>,
|
||||||
|
<option>load</option> or <option>tproxy</option> option is
|
||||||
|
specified. Beginning with Shorewall 5.1.1, when
|
||||||
|
BALANCE_PROVIDERS=Yes, <option>balance=1</option> is assumed
|
||||||
|
unless the <option>fallback</option>, <option>loose</option>,
|
||||||
|
<option>load</option> or <option>tproxy</option> option is
|
||||||
|
specified.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@@ -629,7 +629,7 @@
|
|||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis
|
<term><emphasis
|
||||||
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber</replaceable>1[:<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</term>
|
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber</replaceable>1[:<replaceable>queuenumber2</replaceable>[c]][,bypass]]|bypass)]</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Queues the packet to a user-space application using the
|
<para>Queues the packet to a user-space application using the
|
||||||
@@ -648,12 +648,19 @@
|
|||||||
systems: start multiple instances of the userspace program on
|
systems: start multiple instances of the userspace program on
|
||||||
queues x, x+1, .. x+n and use "x:x+n". Packets belonging to
|
queues x, x+1, .. x+n and use "x:x+n". Packets belonging to
|
||||||
the same connection are put into the same nfqueue.</para>
|
the same connection are put into the same nfqueue.</para>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, queuenumber2 may be
|
||||||
|
followed by the letter 'c' to indicate that the CPU ID will be
|
||||||
|
used as an index to map packets to the queues. The idea is
|
||||||
|
that you can improve performance if there's a queue per CPU.
|
||||||
|
Requires the NFQUEUE CPU Fanout capability in your kernel and
|
||||||
|
iptables.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold"><emphasis
|
<term><emphasis role="bold"><emphasis
|
||||||
role="bold">NFQUEUE!</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
|
role="bold">NFQUEUE!</emphasis>[([<replaceable>queuenumber1</replaceable>[:<replaceable>queuenumber2</replaceable>[c]][,bypass]]|bypass)]</emphasis></term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>like NFQUEUE but exempts the rule from being suppressed
|
<para>like NFQUEUE but exempts the rule from being suppressed
|
||||||
@@ -900,108 +907,199 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">SOURCE</emphasis> -
|
<term><emphasis role="bold">SOURCE -
|
||||||
{<emphasis>zone</emphasis>|<emphasis>zone-list</emphasis>[+]|{<emphasis
|
<replaceable>source-spec</replaceable>[,...]</emphasis></term>
|
||||||
role="bold">all</emphasis>|<emphasis
|
|
||||||
role="bold">any</emphasis>}[<emphasis
|
|
||||||
role="bold">+</emphasis>][<emphasis
|
|
||||||
role="bold">-</emphasis>]}<emphasis
|
|
||||||
role="bold">[:</emphasis><emphasis>interface</emphasis>][<emphasis
|
|
||||||
role="bold">:</emphasis>{<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis
|
|
||||||
role="bold">+</emphasis><emphasis>ipset</emphasis>|<replaceable>^countrycode-list</replaceable>}</term>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Source hosts to which the rule applies. May be a
|
<para>Source hosts to which the rule applies.</para>
|
||||||
<replaceable>zone</replaceable> declared in /etc/shorewall/zones,
|
|
||||||
<emphasis role="bold">$FW</emphasis> to indicate the firewall
|
|
||||||
itself, <emphasis role="bold">all</emphasis>, <emphasis
|
|
||||||
role="bold">all+</emphasis>, <emphasis role="bold">all-</emphasis>,
|
|
||||||
<emphasis role="bold">all+-</emphasis> or <emphasis
|
|
||||||
role="bold">none</emphasis>.</para>
|
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.4.13, you may use a
|
<para><replaceable>source-spec</replaceable> is one of the
|
||||||
<replaceable>zone-list </replaceable>which consists of a
|
following:</para>
|
||||||
comma-separated list of zones declared in <ulink
|
|
||||||
url="/manpages/shorewall-zones.html">shorewall-zones</ulink> (5).
|
|
||||||
This <replaceable>zone-list</replaceable> may be optionally followed
|
|
||||||
by "+" to indicate that the rule is to apply to intra-zone traffic
|
|
||||||
as well as inter-zone traffic.</para>
|
|
||||||
|
|
||||||
<para>When <emphasis role="bold">none</emphasis> is used either in
|
<variablelist>
|
||||||
the <emphasis role="bold">SOURCE</emphasis> or <emphasis
|
<varlistentry>
|
||||||
role="bold">DEST</emphasis> column, the rule is ignored.</para>
|
<term><emphasis
|
||||||
|
role="bold"><replaceable>zone</replaceable>[,...[+]]</emphasis></term>
|
||||||
|
|
||||||
<para><emphasis role="bold">all</emphasis> means "All Zones",
|
<listitem>
|
||||||
including the firewall itself. <emphasis role="bold">all-</emphasis>
|
<para>The name of a zone defined in <ulink
|
||||||
means "All Zones, except the firewall itself". When <emphasis
|
url="shorewall-zones.html">shorewall-zones</ulink>(5). When
|
||||||
role="bold">all</emphasis>[<emphasis role="bold">-</emphasis>] is
|
only the zone name is specified, the packet source may be any
|
||||||
used either in the <emphasis role="bold">SOURCE</emphasis> or
|
host in that zone.</para>
|
||||||
<emphasis role="bold">DEST</emphasis> column intra-zone traffic is
|
|
||||||
not affected. When <emphasis role="bold">all+</emphasis>[<emphasis
|
|
||||||
role="bold">-</emphasis>] is "used, intra-zone traffic is affected.
|
|
||||||
Beginning with Shorewall 4.4.13, exclusion is supported -- see see
|
|
||||||
<ulink
|
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
|
||||||
|
|
||||||
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis
|
<para>zone may also be one of the following:</para>
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] or
|
|
||||||
<emphasis role="bold">any</emphasis>[<emphasis
|
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] is
|
|
||||||
specified, clients may be further restricted to a list of networks
|
|
||||||
and/or hosts by appending ":" and a comma-separated list of network
|
|
||||||
and/or host addresses. Hosts may be specified by IP or MAC address;
|
|
||||||
mac addresses must begin with "~" and must use "-" as a
|
|
||||||
separator.</para>
|
|
||||||
|
|
||||||
<para>The above restriction on <emphasis
|
<variablelist>
|
||||||
role="bold">all</emphasis>[<emphasis
|
<varlistentry>
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] and
|
<term>all[+][-]</term>
|
||||||
<emphasis role="bold">any</emphasis>[<emphasis
|
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] is
|
|
||||||
removed in Shorewall-4.4.13.</para>
|
|
||||||
|
|
||||||
<para><emphasis role="bold">any</emphasis> is equivalent to
|
<listitem>
|
||||||
<emphasis role="bold">all</emphasis> when there are no nested zones.
|
<para><emphasis role="bold">all</emphasis>, without the
|
||||||
When there are nested zones, <emphasis role="bold">any</emphasis>
|
"-" means "All Zones, including the firewall zone". If
|
||||||
only refers to top-level zones (those with no parent zones). Note
|
the "-" is included, the firewall zone is omitted.
|
||||||
that <emphasis role="bold">any</emphasis> excludes all vserver
|
Normally all omits intra-zone traffic, but intra-zone
|
||||||
zones, since those zones are nested within the firewall zone.
|
traffic can be included specifying "+".</para>
|
||||||
Beginning with Shorewall 4.4.13, exclusion is supported with
|
</listitem>
|
||||||
<emphasis role="bold">any</emphasis> -- see see <ulink
|
</varlistentry>
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
|
||||||
|
|
||||||
<para>Hosts may also be specified as an IP address range using the
|
<varlistentry>
|
||||||
syntax
|
<term>any[+][-]</term>
|
||||||
<emphasis>lowaddress</emphasis>-<emphasis>highaddress</emphasis>.
|
|
||||||
This requires that your kernel and iptables contain iprange match
|
|
||||||
support. If your kernel and iptables have ipset match support then
|
|
||||||
you may give the name of an ipset prefaced by "+". The ipset name
|
|
||||||
may be optionally followed by a number from 1 to 6 enclosed in
|
|
||||||
square brackets ([]) to indicate the number of levels of source
|
|
||||||
bindings to be matched.</para>
|
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.4.17, the primary IP address of a
|
<listitem>
|
||||||
firewall interface can be specified by an ampersand ('&')
|
<para><emphasis role="bold">any</emphasis> is equivalent
|
||||||
followed by the logical name of the interface as found in the
|
to <emphasis role="bold">all</emphasis> when there are
|
||||||
INTERFACE column of <ulink
|
no nested zones. When there are nested zones, <emphasis
|
||||||
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
|
role="bold">any</emphasis> only refers to top-level
|
||||||
(5).</para>
|
zones (those with no parent zones). Note that <emphasis
|
||||||
|
role="bold">any</emphasis> excludes all vserver zones,
|
||||||
|
since those zones are nested within the firewall
|
||||||
|
zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.5.4, A
|
<varlistentry>
|
||||||
<replaceable>countrycode-list</replaceable> may be specified. A
|
<term>none</term>
|
||||||
countrycode-list is a comma-separated list of up to 15 two-character
|
|
||||||
ISO-3661 country codes enclosed in square brackets ('[...]') and
|
|
||||||
preceded by a caret ('^'). When a single country code is given, the
|
|
||||||
square brackets may be omitted. A list of country codes supported by
|
|
||||||
Shorewall may be found at <ulink
|
|
||||||
url="/ISO-3661.html">http://www.shorewall.net/ISO-3661.html</ulink>.
|
|
||||||
Specifying a <replaceable>countrycode-list</replaceable> requires
|
|
||||||
<firstterm>GeoIP Match</firstterm> support in your iptables and
|
|
||||||
Kernel.</para>
|
|
||||||
|
|
||||||
<para>You may exclude certain hosts from the set already defined
|
<listitem>
|
||||||
through use of an <emphasis>exclusion</emphasis> (see <ulink
|
<para>When <emphasis role="bold">none</emphasis> is used
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
either in the <emphasis role="bold">SOURCE</emphasis> or
|
||||||
|
<emphasis role="bold">DEST</emphasis> column, the rule
|
||||||
|
is ignored.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Similar to with <emphasis role="bold">all</emphasis> and
|
||||||
|
<emphasis role="bold">any</emphasis>, intra-zone traffic is
|
||||||
|
normally excluded when multiple zones are listed. Intra-zone
|
||||||
|
traffic may be included by following the list with a plus sign
|
||||||
|
("+").</para>
|
||||||
|
|
||||||
|
<para><emphasis role="bold">all</emphasis> and <emphasis
|
||||||
|
role="bold">any</emphasis> may be followed by an exclamation
|
||||||
|
point ("!") and a comma-separated list of zone names to be
|
||||||
|
omitted.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>When this form is used,
|
||||||
|
<replaceable>interface</replaceable> must be the name of an
|
||||||
|
interface associated with the named
|
||||||
|
<replaceable>zone</replaceable> in either <ulink
|
||||||
|
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)
|
||||||
|
or <ulink
|
||||||
|
url="shorewall.hosts.html">shorewall-hosts</ulink>(5). Only
|
||||||
|
packets from hosts in the <replaceable>zone</replaceable> that
|
||||||
|
arrive through the named interface will match the rule.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>address</replaceable>[,...]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where address can be:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>A host or network IP address. A network address may
|
||||||
|
be followed by exclusion (see <ulink
|
||||||
|
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>An address range, specified using the syntax
|
||||||
|
<emphasis>lowaddress</emphasis>-<emphasis>highaddress</emphasis>.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>+<replaceable>ipset</replaceable> where
|
||||||
|
<replaceable>ipset</replaceable> is the name of an ipset
|
||||||
|
and must be preceded by a plus sign ("+").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>A MAC address in Shorewall format (preceded by a
|
||||||
|
tilde ("~") and with the hex byte values separated by
|
||||||
|
dashes (e.g., "~00-0a-f6-04-9c-7d").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>^<replaceable>country-code</replaceable> where
|
||||||
|
country-code is a two-character ISO-3661 country code
|
||||||
|
preceded by a caret ("^").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>^<replaceable>country-code-list</replaceable> where
|
||||||
|
<replaceable>country-code-list</replaceable> is a
|
||||||
|
comma-separated list of up to 15 ISO-3661 country codes
|
||||||
|
enclosed in square brackets ("[...]").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The primary IP address of a firewall interface can
|
||||||
|
be specified by an ampersand ('&') followed by the
|
||||||
|
logical name of the interface as found in the INTERFACE
|
||||||
|
column of <ulink
|
||||||
|
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
|
||||||
|
(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>address</replaceable>[,...]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form combines the preceding two and requires that
|
||||||
|
both the incoming interface and source address match.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form matches if the host IP address does not match
|
||||||
|
any of the entries in the exclusion (see <ulink
|
||||||
|
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form matches packets from the named
|
||||||
|
<replaceable>zone</replaceable> entering through the specified
|
||||||
|
<replaceable>interface</replaceable> where the source address
|
||||||
|
does not match any entry in the
|
||||||
|
<replaceable>exclusion</replaceable>.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Beginning with Shorewall 5.1.0, multiple
|
||||||
|
<replaceable>source-spec</replaceable>s may be listed, provided that
|
||||||
|
extended forms of the source-spec are used:</para>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<para><replaceable>zone</replaceable>:(<replaceable>interface</replaceable>)</para>
|
||||||
|
|
||||||
|
<para><replaceable>zone</replaceable>:(<replaceable>address</replaceable>[,...])</para>
|
||||||
|
|
||||||
|
<para>zone:(interface:address[,...])</para>
|
||||||
|
|
||||||
|
<para><replaceable>zone</replaceable>:(<replaceable>exclusion</replaceable>)</para>
|
||||||
|
|
||||||
|
<para><replaceable>zone</replaceable>:(<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable>)</para>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
<para>Examples:</para>
|
<para>Examples:</para>
|
||||||
|
|
||||||
@@ -1070,8 +1168,8 @@
|
|||||||
<term>$FW:&eth0</term>
|
<term>$FW:&eth0</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The primary IP address of eth0 in the firewall zone
|
<para>The primary IP address of eth0 in the firewall
|
||||||
(Shorewall 4.4.17 and later).</para>
|
zone.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@@ -1092,92 +1190,259 @@
|
|||||||
zone.</para>
|
zone.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:^CN</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>China.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>loc:(eth1:1.2.3.4,2.3.4.5),dmz:(eth2:5.6.7.8,9.10.11.12),net</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Hosts 1.2.3.4 and 2.3.4.5 in the loc zone when the
|
||||||
|
packet arrives through eth1 plus hosts 5.6.7.8 and 9.10.11.12
|
||||||
|
in the dmz zone when the packet arrives through eth2 plus all
|
||||||
|
of the net zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">DEST</emphasis> -
|
<term><emphasis role="bold">DEST -
|
||||||
{<emphasis>zone</emphasis>|<emphasis>zone-list</emphasis>[+]|{<emphasis
|
<replaceable>dest-spec</replaceable>[,...]</emphasis></term>
|
||||||
role="bold">all</emphasis>|<emphasis
|
|
||||||
role="bold">any</emphasis>}[<emphasis
|
|
||||||
role="bold">+</emphasis>][<emphasis
|
|
||||||
role="bold">-</emphasis>]}<emphasis
|
|
||||||
role="bold">[:{</emphasis><emphasis>interface</emphasis>|<emphasis>address-or-range</emphasis>[,<emphasis>address-or-range</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>|<emphasis
|
|
||||||
role="bold">+</emphasis><emphasis>ipset</emphasis>|<emphasis>^countrycode-list</emphasis>}][<option>:</option><replaceable>port</replaceable>[:<emphasis
|
|
||||||
role="bold">random</emphasis>]]</term>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Location of Server. May be a zone declared in <ulink
|
<para>Destination hosts to which the rule applies.</para>
|
||||||
url="/manpages/shorewall-zones.html">shorewall-zones</ulink>(5),
|
|
||||||
$<emphasis role="bold">FW</emphasis> to indicate the firewall
|
|
||||||
itself, <emphasis role="bold">all</emphasis>. <emphasis
|
|
||||||
role="bold">all+</emphasis> or <emphasis
|
|
||||||
role="bold">none</emphasis>.</para>
|
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.4.13, you may use a
|
<para><replaceable>dest-spec</replaceable> is one of the
|
||||||
<replaceable>zone-list </replaceable>which consists of a
|
following:</para>
|
||||||
comma-separated list of zones declared in <ulink
|
|
||||||
url="/manpages/shorewall-zones.html">shorewall-zones</ulink> (5).
|
|
||||||
This <replaceable>zone-list</replaceable> may be optionally followed
|
|
||||||
by "+" to indicate that the rule is to apply to intra-zone traffic
|
|
||||||
as well as inter-zone traffic.</para>
|
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.5.4, A
|
<variablelist>
|
||||||
<replaceable>countrycode-list</replaceable> may be specified. A
|
<varlistentry>
|
||||||
countrycode-list is a comma-separated list of up to 15 two-character
|
<term><emphasis
|
||||||
ISO-3661 country codes enclosed in square brackets ('[...]') and
|
role="bold"><replaceable>zone</replaceable>[,...[+]]</emphasis></term>
|
||||||
preceded by a caret ('^'). When a single country code is given, the
|
|
||||||
square brackets may be omitted. A list of country codes supported by
|
|
||||||
Shorewall may be found at <ulink
|
|
||||||
url="/ISO-3661.html">http://www.shorewall.net/ISO-3661.html</ulink>.
|
|
||||||
Specifying a <replaceable>countrycode-list</replaceable> requires
|
|
||||||
<firstterm>GeoIP Match</firstterm> support in your iptables and
|
|
||||||
Kernel.</para>
|
|
||||||
|
|
||||||
<para>When <emphasis role="bold">none</emphasis> is used either in
|
<listitem>
|
||||||
the <emphasis role="bold">SOURCE</emphasis> or <emphasis
|
<para>The name of a zone defined in <ulink
|
||||||
role="bold">DEST</emphasis> column, the rule is ignored.</para>
|
url="shorewall-zones.html">shorewall-zones</ulink>(5). When
|
||||||
|
only the zone name is specified, the packet destination may be
|
||||||
|
any host in that zone.</para>
|
||||||
|
|
||||||
<para><emphasis role="bold">all</emphasis> means "All Zones",
|
<para>zone may also be one of the following:</para>
|
||||||
including the firewall itself. <emphasis role="bold">all-</emphasis>
|
|
||||||
means "All Zones, except the firewall itself". When <emphasis
|
|
||||||
role="bold">all</emphasis>[<emphasis role="bold">-</emphasis>] is
|
|
||||||
used either in the <emphasis role="bold">SOURCE</emphasis> or
|
|
||||||
<emphasis role="bold">DEST</emphasis> column intra-zone traffic is
|
|
||||||
not affected. When <emphasis role="bold">all+</emphasis>[<emphasis
|
|
||||||
role="bold">-</emphasis>] is "used, intra-zone traffic is affected.
|
|
||||||
Beginning with Shorewall 4.4.13, exclusion is supported -- see see
|
|
||||||
<ulink
|
|
||||||
url="/manpages6/shorewall6-exclusion.html">shorewall6-exclusion</ulink>(5).</para>
|
|
||||||
|
|
||||||
<para><emphasis role="bold">any</emphasis> is equivalent to
|
<variablelist>
|
||||||
<emphasis role="bold">all</emphasis> when there are no nested zones.
|
<varlistentry>
|
||||||
When there are nested zones, <emphasis role="bold">any</emphasis>
|
<term>all[+][-]</term>
|
||||||
only refers to top-level zones (those with no parent zones). Note
|
|
||||||
that <emphasis role="bold">any</emphasis> excludes all vserver
|
|
||||||
zones, since those zones are nested within the firewall zone.</para>
|
|
||||||
|
|
||||||
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis
|
<listitem>
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] or
|
<para><emphasis role="bold">all</emphasis>, without the
|
||||||
<emphasis role="bold">any</emphasis>[<emphasis
|
"-" means "All Zones, including the firewall zone". If
|
||||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] is
|
the "-" is included, the firewall zone is omitted.
|
||||||
specified, clients may be further restricted to a list of networks
|
Normally all omits intra-zone traffic, but intra-zone
|
||||||
and/or hosts by appending ":" and a comma-separated list of network
|
traffic can be included specifying "+".</para>
|
||||||
and/or host addresses. Hosts may be specified by IP or MAC address;
|
</listitem>
|
||||||
mac addresses must begin with "~" and must use "-" as a
|
</varlistentry>
|
||||||
separator.</para>
|
|
||||||
|
|
||||||
<para>When <emphasis role="bold">all</emphasis> is used either in
|
<varlistentry>
|
||||||
the <emphasis role="bold">SOURCE</emphasis> or <emphasis
|
<term>any[+][-]</term>
|
||||||
role="bold">DEST</emphasis> column intra-zone traffic is not
|
|
||||||
affected. When <emphasis role="bold">all+</emphasis> is used,
|
|
||||||
intra-zone traffic is affected. Beginning with Shorewall 4.4.13,
|
|
||||||
exclusion is supported -- see see <ulink
|
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
|
||||||
|
|
||||||
<para>The <replaceable>zone</replaceable> should be omitted in
|
<listitem>
|
||||||
DNAT-, REDIRECT- and NONAT rules.</para>
|
<para><emphasis role="bold">any</emphasis> is equivalent
|
||||||
|
to <emphasis role="bold">all</emphasis> when there are
|
||||||
|
no nested zones. When there are nested zones, <emphasis
|
||||||
|
role="bold">any</emphasis> only refers to top-level
|
||||||
|
zones (those with no parent zones). Note that <emphasis
|
||||||
|
role="bold">any</emphasis> excludes all vserver zones,
|
||||||
|
since those zones are nested within the firewall
|
||||||
|
zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>none</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>When <emphasis role="bold">none</emphasis> is used
|
||||||
|
either in the <emphasis role="bold">SOURCE</emphasis> or
|
||||||
|
<emphasis role="bold">DEST</emphasis> column, the rule
|
||||||
|
is ignored.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Similar to with <emphasis role="bold">all</emphasis> and
|
||||||
|
<emphasis role="bold">any</emphasis>, intra-zone traffic is
|
||||||
|
normally excluded when multiple zones are listed. Intra-zone
|
||||||
|
traffic may be included by following the list with a plus sign
|
||||||
|
("+").</para>
|
||||||
|
|
||||||
|
<para><emphasis role="bold">all</emphasis> and <emphasis
|
||||||
|
role="bold">any</emphasis> may be followed by an exclamation
|
||||||
|
point ("!") and a comma-separated list of zone names to be
|
||||||
|
omitted.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>When this form is used,
|
||||||
|
<replaceable>interface</replaceable> must be the name of an
|
||||||
|
interface associated with the named
|
||||||
|
<replaceable>zone</replaceable> in either <ulink
|
||||||
|
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)
|
||||||
|
or <ulink
|
||||||
|
url="shorewall.hosts.html">shorewall-hosts</ulink>(5). Only
|
||||||
|
packets to hosts in the <replaceable>zone</replaceable> that
|
||||||
|
are sent through the named interface will match the
|
||||||
|
rule.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>address</replaceable>[,...]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>where address can be:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>A host or network IP address. A network address may
|
||||||
|
be followed by exclusion (see <ulink
|
||||||
|
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>An address range, specified using the syntax
|
||||||
|
<emphasis>lowaddress</emphasis>-<emphasis>highaddress</emphasis>.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>+<replaceable>ipset</replaceable> where
|
||||||
|
<replaceable>ipset</replaceable> is the name of an ipset
|
||||||
|
and must be preceded by a plus sign ("+").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>^<replaceable>country-code</replaceable> where
|
||||||
|
country-code is a two-character ISO-3661 country code
|
||||||
|
preceded by a caret ("^").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>^<replaceable>country-code-list</replaceable> where
|
||||||
|
<replaceable>country-code-list</replaceable> is a
|
||||||
|
comma-separated list of up to 15 ISO-3661 country codes
|
||||||
|
enclosed in square brackets ("[...]").</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The primary IP address of a firewall interface can
|
||||||
|
be specified by an ampersand ('&') followed by the
|
||||||
|
logical name of the interface as found in the INTERFACE
|
||||||
|
column of <ulink
|
||||||
|
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
|
||||||
|
(5).</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<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>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form matches if the host IP address does not match
|
||||||
|
any of the entries in the exclusion (see <ulink
|
||||||
|
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable>zone</replaceable>:<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form matches packets to the named
|
||||||
|
<replaceable>zone</replaceable> leaving through the specified
|
||||||
|
<replaceable>interface</replaceable> where the destination
|
||||||
|
address does not match any entry in the
|
||||||
|
<replaceable>exclusion</replaceable>.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>[<replaceable>zone</replaceable>]:[<replaceable>server-IP</replaceable>][:<replaceable>port-or-port-range</replaceable>[:random]]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This form applies when the ACTION is DNAT[-] or
|
||||||
|
REDIRECT[-]. The zone may be omitted in REDIRECT rules ($FW is
|
||||||
|
assumed) and must be omitted in DNAT-, REDIRECT- and NONAT
|
||||||
|
rules.</para>
|
||||||
|
|
||||||
|
<para><replaceable role="bold">server-IP</replaceable> is not
|
||||||
|
allowed in REDIRECT rules and may be omitted in DNAT[-] rules
|
||||||
|
provided that <replaceable>port-or-port-range</replaceable> is
|
||||||
|
included.</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>The IP address of the server to which the packet is
|
||||||
|
to be sent.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>A range of IP address with the low and high address
|
||||||
|
separated by a dash (:"-"). Connections are distributed
|
||||||
|
among the IP addresses in the range.</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>If <replaceable>server-IP </replaceable>is omitted in a
|
||||||
|
DNAT[-] rule, only the destination port number is modified by
|
||||||
|
the rule.</para>
|
||||||
|
|
||||||
|
<para>port-or-port-range may be:</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>An integer port number in the range 1 -
|
||||||
|
65535.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The name of a service from
|
||||||
|
<filename>/etc/services</filename>.</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>A port range with the low and high integer port
|
||||||
|
numbers separated by a dash ("-"). Connections are
|
||||||
|
distributed among the ports in the range.</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>If <emphasis role="bold">random</emphasis> is specified,
|
||||||
|
port mapping will be randomized.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
<para>If the DEST <replaceable>zone</replaceable> is a bport zone,
|
<para>If the DEST <replaceable>zone</replaceable> is a bport zone,
|
||||||
then either:<orderedlist numeration="loweralpha">
|
then either:<orderedlist numeration="loweralpha">
|
||||||
@@ -1194,82 +1459,134 @@
|
|||||||
<para>the SOURCE <replaceable>zone</replaceable> must be an
|
<para>the SOURCE <replaceable>zone</replaceable> must be an
|
||||||
ipv4 zone that is associated with only the same bridge.</para>
|
ipv4 zone that is associated with only the same bridge.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</orderedlist></para>
|
</orderedlist>Beginning with Shorewall 5.1.0, multiple
|
||||||
|
<replaceable>dest-spec</replaceable>s may be listed, provided that
|
||||||
|
extended forms of the source-spec are used:</para>
|
||||||
|
|
||||||
<para>Except when <emphasis
|
<blockquote>
|
||||||
role="bold">{all|any}</emphasis>[<emphasis
|
<para><replaceable>zone</replaceable>:(<replaceable>interface</replaceable>)</para>
|
||||||
role="bold">+]|[-</emphasis>] is specified, the server may be
|
|
||||||
further restricted to a particular network, host or interface by
|
|
||||||
appending ":" and the network, host or interface. See <emphasis
|
|
||||||
role="bold">SOURCE</emphasis> above.</para>
|
|
||||||
|
|
||||||
<para>You may exclude certain hosts from the set already defined
|
<para><replaceable>zone</replaceable>:(<replaceable>address</replaceable>[,...])</para>
|
||||||
through use of an <emphasis>exclusion</emphasis> (see <ulink
|
|
||||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5)).</para>
|
|
||||||
|
|
||||||
<para>Restriction: MAC addresses are not allowed (this is a
|
<para>zone:(interface:address[,...])</para>
|
||||||
Netfilter restriction).</para>
|
|
||||||
|
|
||||||
<para>Like in the <emphasis role="bold">SOURCE</emphasis> column,
|
<para><replaceable>zone</replaceable>:(<replaceable>exclusion</replaceable>)</para>
|
||||||
you may specify a range of IP addresses using the syntax
|
|
||||||
<emphasis>lowaddress</emphasis>-<emphasis>highaddress</emphasis>.
|
|
||||||
When the <emphasis role="bold">ACTION</emphasis> is <emphasis
|
|
||||||
role="bold">DNAT</emphasis> or <emphasis
|
|
||||||
role="bold">DNAT-</emphasis>, the connections will be assigned to
|
|
||||||
addresses in the range in a round-robin fashion.</para>
|
|
||||||
|
|
||||||
<para>If your kernel and iptables have ipset match support then you
|
<para><replaceable>zone</replaceable>:(<replaceable>interface</replaceable>:<replaceable>exclusion</replaceable>)</para>
|
||||||
may give the name of an ipset prefaced by "+". The ipset name may be
|
</blockquote>
|
||||||
optionally followed by a number from 1 to 6 enclosed in square
|
|
||||||
brackets ([]) to indicate the number of levels of destination
|
|
||||||
bindings to be matched. Only one of the <emphasis
|
|
||||||
role="bold">SOURCE</emphasis> and <emphasis
|
|
||||||
role="bold">DEST</emphasis> columns may specify an ipset
|
|
||||||
name.</para>
|
|
||||||
|
|
||||||
<para>Beginning with Shorewall 4.4.17, the primary IP address of a
|
<para>Multiple <replaceable>dest-spec</replaceable>s are not
|
||||||
firewall interface can be specified by an ampersand ('&')
|
permitted in DNAT[-] and REDIRECT[-] rules.</para>
|
||||||
followed by the logical name of the interface as found in the
|
|
||||||
INTERFACE column of <ulink
|
|
||||||
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>
|
|
||||||
(5).</para>
|
|
||||||
|
|
||||||
<para>The <replaceable>port</replaceable> that the server is
|
<para>Examples:</para>
|
||||||
listening on may be included and separated from the server's IP
|
|
||||||
address by ":". If omitted, the firewall will not modify the
|
|
||||||
destination port. A destination port may only be included if the
|
|
||||||
<emphasis role="bold">ACTION</emphasis> is <emphasis
|
|
||||||
role="bold">DNAT</emphasis> or <emphasis
|
|
||||||
role="bold">REDIRECT</emphasis>.</para>
|
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>Example:</term>
|
<term>dmz:192.168.2.2</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para><emphasis role="bold">loc:192.168.1.3:3128</emphasis>
|
<para>Host 192.168.2.2 in the DMZ</para>
|
||||||
specifies a local server at IP address 192.168.1.3 and
|
</listitem>
|
||||||
listening on port 3128.</para>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:155.186.235.0/24</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Subnet 155.186.235.0/24 on the Internet</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>loc:192.168.1.1,192.168.1.2</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Hosts 192.168.1.1 and 192.168.1.2 in the local
|
||||||
|
zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:192.0.2.11-192.0.2.17</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Hosts 192.0.2.11-192.0.2.17 in the net zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:!192.0.2.11-192.0.2.17</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>All hosts in the net zone except for
|
||||||
|
192.0.2.11-192.0.2.17.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:155.186.235.0/24!155.186.235.16/28</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Subnet 155.186.235.0/24 on the Internet except for
|
||||||
|
155.186.235.16/28</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>$FW:&eth0</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>The primary IP address of eth0 in the firewall
|
||||||
|
zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>loc,dmz</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Both the <emphasis role="bold">loc</emphasis> and
|
||||||
|
<emphasis role="bold">dmz</emphasis> zones.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>all!dmz</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>All but the <emphasis role="bold">dmz</emphasis>
|
||||||
|
zone.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>net:^CN</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>China.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>dmz:192.168.10.4:25</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Port 25 on server 192.168.10.4 in the dmz zone (DNAT
|
||||||
|
rule).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>loc:(eth1:1.2.3.4,2.3.4.5),dmz:(eth2:5.6.7.8,9.10.11.12),net</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Hosts 1.2.3.4 and 2.3.4.5 in the loc zone when the
|
||||||
|
packet arrives through eth1 plus hosts 5.6.7.8 and 9.10.11.12
|
||||||
|
in the dmz zone when the packet arrives through eth2 plus all
|
||||||
|
of the net zone.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<para>The <emphasis>port</emphasis> may be specified as a service
|
|
||||||
name. You may specify a port range in the form
|
|
||||||
<emphasis>lowport-highport</emphasis> to cause connections to be
|
|
||||||
assigned to ports in the range in round-robin fashion. When a port
|
|
||||||
range is specified, <emphasis>lowport</emphasis> and
|
|
||||||
<emphasis>highport</emphasis> must be given as integers; service
|
|
||||||
names are not permitted. Additionally, the port range may be
|
|
||||||
optionally followed by <emphasis role="bold">:random</emphasis>
|
|
||||||
which causes assignment to ports in the list to be random.</para>
|
|
||||||
|
|
||||||
<para>If the <emphasis role="bold">ACTION</emphasis> is <emphasis
|
|
||||||
role="bold">REDIRECT</emphasis> or <emphasis
|
|
||||||
role="bold">REDIRECT-</emphasis>, this column needs only to contain
|
|
||||||
the port number on the firewall that the request should be
|
|
||||||
redirected to. That is equivalent to specifying
|
|
||||||
<option>$FW</option>::<replaceable>port</replaceable>.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@@ -171,7 +171,7 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">SOURCE</emphasis> (Optional) -
|
<term><emphasis role="bold">SOURCE</emphasis> (Optional) -
|
||||||
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
|
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
|
||||||
role="bold">,</emphasis><emphasis>address</emphasis>][<emphasis>exclusion</emphasis>]]</term>
|
role="bold">,</emphasis><emphasis>address</emphasis>...][<emphasis>exclusion</emphasis>]]</term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Set of hosts that you wish to masquerade. You can specify this
|
<para>Set of hosts that you wish to masquerade. You can specify this
|
||||||
|
@@ -117,6 +117,16 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis
|
||||||
|
role="bold">BLACKLIST_DEFAULT=</emphasis>{<emphasis>action</emphasis>[(<replaceable>parameters</replaceable>)][:<replaceable>level</replaceable>]|<emphasis
|
||||||
|
role="bold">none</emphasis>}</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para/>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis
|
<term><emphasis
|
||||||
role="bold">DROP_DEFAULT=</emphasis>{<emphasis>action</emphasis>[(<replaceable>parameters</replaceable>)][:<replaceable>level</replaceable>]|<emphasis
|
role="bold">DROP_DEFAULT=</emphasis>{<emphasis>action</emphasis>[(<replaceable>parameters</replaceable>)][:<replaceable>level</replaceable>]|<emphasis
|
||||||
@@ -176,6 +186,9 @@
|
|||||||
|
|
||||||
<member>REJECT_DEFAULT="Reject"</member>
|
<member>REJECT_DEFAULT="Reject"</member>
|
||||||
|
|
||||||
|
<member>BLACKLIST_DEFAULT="Drop" (added in Shorewall
|
||||||
|
5.1.1)</member>
|
||||||
|
|
||||||
<member>ACCEPT_DEFAULT="none"</member>
|
<member>ACCEPT_DEFAULT="none"</member>
|
||||||
|
|
||||||
<member>QUEUE_DEFAULT="none"</member>
|
<member>QUEUE_DEFAULT="none"</member>
|
||||||
@@ -443,6 +456,24 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis role="bold">BALANCE_PROVIDERS=</emphasis>[<emphasis
|
||||||
|
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 5.1.1. When USE_DEFAULT_RT=Yes, this option
|
||||||
|
determines whether the <option>balance</option> provider option (see
|
||||||
|
<ulink
|
||||||
|
url="shorewall-providers.html">shorewall-providers(5)</ulink>) is
|
||||||
|
the default. When BALANCE_PROVIDERS=Yes, then the
|
||||||
|
<option>balance</option> option is assumed unless the
|
||||||
|
<option>fallback</option>, <option>loose</option>,
|
||||||
|
<option>load</option> or <option>tproxy</option> option is
|
||||||
|
specified. If this option is not set or is set to the empty value,
|
||||||
|
then the default value is the value of USE_DEFAULT_RT.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">BASIC_FILTERS=</emphasis>[<emphasis
|
<term><emphasis role="bold">BASIC_FILTERS=</emphasis>[<emphasis
|
||||||
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
|
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
|
||||||
@@ -533,22 +564,6 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><emphasis role="bold">CHAIN_SCRIPTS=</emphasis>{<emphasis
|
|
||||||
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>Added in Shorewall 4.5.16. Prior to the availability of BEGIN
|
|
||||||
PERL....END PERL in configuration files, the only way to execute a
|
|
||||||
chain-specific script was to create a script file with the same name
|
|
||||||
as the chain and place it in a directory on the CONFIG_PATH. That
|
|
||||||
facility has the drawback that the compiler will attempt to run a
|
|
||||||
non-script file just because it has the same name as a chain. To
|
|
||||||
disable this facility, set CHAIN_SCRIPTS=No. If not specified or
|
|
||||||
specified as the empty value, CHAIN_SCRIPTS=Yes is assumed.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><emphasis role="bold">CLAMPMSS=[</emphasis><emphasis
|
<term><emphasis role="bold">CLAMPMSS=[</emphasis><emphasis
|
||||||
role="bold">Yes</emphasis>|<emphasis
|
role="bold">Yes</emphasis>|<emphasis
|
||||||
@@ -2151,36 +2166,27 @@ LOG:info:,bar net fw</programlisting>
|
|||||||
<command>load</command> and <command>reload</command> commands.
|
<command>load</command> and <command>reload</command> commands.
|
||||||
Beginning with release 3.9.5, you may define an alternative means
|
Beginning with release 3.9.5, you may define an alternative means
|
||||||
for accessing the remote firewall system. In that release, two new
|
for accessing the remote firewall system. In that release, two new
|
||||||
options were added to shorewall.conf:<simplelist>
|
options were added to shorewall.conf:</para>
|
||||||
<member>RSH_COMMAND</member>
|
|
||||||
|
|
||||||
<member>RCP_COMMAND</member>
|
<simplelist>
|
||||||
</simplelist>The default values for these are as
|
<member>RSH_COMMAND</member>
|
||||||
follows:<simplelist>
|
|
||||||
<member>RSH_COMMAND: ssh ${root}@${system} ${command}</member>
|
|
||||||
|
|
||||||
<member>RCP_COMMAND: scp ${files}
|
<member>RCP_COMMAND</member>
|
||||||
${root}@${system}:${destination}</member>
|
</simplelist>
|
||||||
</simplelist>Shell variables that will be set when the commands
|
|
||||||
are invoked are as follows:<simplelist>
|
|
||||||
<member><replaceable>root</replaceable> - root user. Normally
|
|
||||||
<option>root</option> but may be overridden using the '-r'
|
|
||||||
option.</member>
|
|
||||||
|
|
||||||
<member><replaceable>system</replaceable> - The name/IP address
|
<para>The default values for these are as follows:</para>
|
||||||
of the remote firewall system.</member>
|
|
||||||
|
|
||||||
<member><replaceable>command</replaceable> - For RSH_COMMAND,
|
<programlisting>RSH_COMMAND: ssh ${root}@${system} ${command}
|
||||||
the command to be executed on the firewall system.</member>
|
RCP_COMMAND: scp ${files} ${root}@${system}:${destination}</programlisting>
|
||||||
|
|
||||||
<member><replaceable>files</replaceable> - For RCP_COMMAND, a
|
<para>Shell variables that will be set when the commands are invoked
|
||||||
space-separated list of files to be copied to the remote
|
are as follows:</para>
|
||||||
firewall system.</member>
|
|
||||||
|
|
||||||
<member><replaceable>destination</replaceable> - The directory
|
<programlisting><replaceable>root</replaceable> - root user. Normally <option>root</option> but may be overridden using the '-r' option.
|
||||||
on the remote system that the files are to be copied
|
<replaceable>system</replaceable> - The name/IP address of the remote firewall system.
|
||||||
into.</member>
|
<replaceable>command</replaceable> - For RSH_COMMAND, the command to be executed on the firewall system.
|
||||||
</simplelist></para>
|
<replaceable>files</replaceable> - For RCP_COMMAND, a space-separated list of files to be copied to the remote firewall system.
|
||||||
|
<replaceable>destination</replaceable> - The directory on the remote system that the files are to be copied into.</programlisting>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@@ -2595,9 +2601,19 @@ INLINE - - - ;; -j REJECT
|
|||||||
<para>This parameter should be set to the name of a file that the
|
<para>This parameter should be set to the name of a file that the
|
||||||
firewall should create if it starts successfully and remove when it
|
firewall should create if it starts successfully and remove when it
|
||||||
stops. Creating and removing this file allows Shorewall to work with
|
stops. Creating and removing this file allows Shorewall to work with
|
||||||
your distribution's initscripts. For RedHat and OpenSuSE, this
|
your distribution's initscripts. For OpenSuSE, this should be set to
|
||||||
should be set to /var/lock/subsys/shorewall. For Debian, the value
|
/var/lock/subsys/shorewall (var/lock/subsys/shorewall-lite if
|
||||||
is /var/lock/shorewall and in LEAF it is /var/run/shorewall.</para>
|
building for export). For Gentoo, it should be set to
|
||||||
|
/run/lock/shorewall (/run/lock/shorewall-lite). For Redhat and
|
||||||
|
derivatives as well as Debian and derivatives, the pathname should
|
||||||
|
be omitted.</para>
|
||||||
|
|
||||||
|
<important>
|
||||||
|
<para>Beginning with Shorewall 5.1.0, this setting is ignored when
|
||||||
|
SERVICEDIR is non-empty in
|
||||||
|
<filename>${SHAREDIR}/shorewall/shorewallrc</filename> (usually
|
||||||
|
<filename>/usr/share/shorewall/shorewallrc</filename>).</para>
|
||||||
|
</important>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
@@ -2846,8 +2862,12 @@ INLINE - - - ;; -j REJECT
|
|||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para><emphasis role="bold">balance</emphasis> is assumed unless
|
<para>If running Shorewall 5.1.0 or earlier or if
|
||||||
<emphasis role="bold">loose</emphasis> is specified.</para>
|
BALANCE_PROVIDERS=Yes (Shorewall 5.1.1 or later), then the
|
||||||
|
<emphasis role="bold">balance</emphasis> provider option is
|
||||||
|
assumed unless the <option>fallback</option>,
|
||||||
|
<option>loose</option>, <option>load</option> or
|
||||||
|
<option>tproxy</option> option is specified.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@@ -25,6 +25,8 @@ loadmodule ip_conntrack
|
|||||||
loadmodule nf_conntrack
|
loadmodule nf_conntrack
|
||||||
loadmodule nf_conntrack_ipv4
|
loadmodule nf_conntrack_ipv4
|
||||||
loadmodule iptable_nat
|
loadmodule iptable_nat
|
||||||
|
loadmodule nf_nat
|
||||||
|
loadmodule nf_nat_ipv4
|
||||||
loadmodule iptable_raw
|
loadmodule iptable_raw
|
||||||
loadmodule xt_state
|
loadmodule xt_state
|
||||||
loadmodule xt_tcpudp
|
loadmodule xt_tcpudp
|
||||||
|
@@ -31,6 +31,7 @@ loadmodule xt_mac
|
|||||||
loadmodule xt_mark
|
loadmodule xt_mark
|
||||||
loadmodule xt_MARK
|
loadmodule xt_MARK
|
||||||
loadmodule xt_multiport
|
loadmodule xt_multiport
|
||||||
|
loadmodule xt_nat
|
||||||
loadmodule xt_NFQUEUE
|
loadmodule xt_NFQUEUE
|
||||||
loadmodule xt_owner
|
loadmodule xt_owner
|
||||||
loadmodule xt_physdev
|
loadmodule xt_physdev
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
VERSION=xxx #The Build script inserts the actual version
|
VERSION=xxx #The Build script inserts the actual version
|
||||||
PRODUCT=shorewall
|
PRODUCT=shorewall
|
||||||
|
Product=Shorewall
|
||||||
|
|
||||||
usage() # $1 = exit status
|
usage() # $1 = exit status
|
||||||
{
|
{
|
||||||
@@ -127,7 +128,6 @@ if [ $# -eq 0 ]; then
|
|||||||
. ./shorewallrc
|
. ./shorewallrc
|
||||||
elif [ -f ~/.shorewallrc ]; then
|
elif [ -f ~/.shorewallrc ]; then
|
||||||
. ~/.shorewallrc || exit 1
|
. ~/.shorewallrc || exit 1
|
||||||
file=./.shorewallrc
|
|
||||||
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
else
|
else
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
# Shorewall6 Lite Makefile to restart if firewall script is newer than last restart
|
|
||||||
VARDIR=$(shell /sbin/shorewall6-lite show vardir)
|
|
||||||
SHAREDIR=/usr/share/shorewall6-lite
|
|
||||||
RESTOREFILE?=.restore
|
|
||||||
|
|
||||||
all: $(VARDIR)/$(RESTOREFILE)
|
|
||||||
|
|
||||||
$(VARDIR)/$(RESTOREFILE): $(VARDIR)/firewall
|
|
||||||
@/sbin/shorewall6-lite -q save >/dev/null; \
|
|
||||||
if \
|
|
||||||
/sbin/shorewall6-lite -q restart >/dev/null 2>&1; \
|
|
||||||
then \
|
|
||||||
/sbin/shorewall6-lite -q save >/dev/null; \
|
|
||||||
else \
|
|
||||||
/sbin/shorewall6-lite -q restart 2>&1 | tail >&2; exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# EOF
|
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
SRWL=/sbin/shorewall6-lite
|
SRWL='/sbin/shorewall6-lite -6'
|
||||||
SRWL_OPTS="-tvv"
|
SRWL_OPTS="-tvv"
|
||||||
test -n ${INITLOG:=/var/log/shorewall6-lite-init.log}
|
test -n ${INITLOG:=/var/log/shorewall6-lite-init.log}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ fi
|
|||||||
|
|
||||||
# start the firewall
|
# start the firewall
|
||||||
shorewall6_start () {
|
shorewall6_start () {
|
||||||
echo -n "Starting \"Shorewall6 Lite firewall\": "
|
printf "Starting \"Shorewall6 Lite firewall\": "
|
||||||
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -93,10 +93,10 @@ shorewall6_start () {
|
|||||||
# stop the firewall
|
# stop the firewall
|
||||||
shorewall6_stop () {
|
shorewall6_stop () {
|
||||||
if [ "$SAFESTOP" = 1 ]; then
|
if [ "$SAFESTOP" = 1 ]; then
|
||||||
echo -n "Stopping \"Shorewall6 Lite firewall\": "
|
printf "Stopping \"Shorewall6 Lite firewall\": "
|
||||||
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
else
|
else
|
||||||
echo -n "Clearing all \"Shorewall6 Lite firewall\" rules: "
|
printf "Clearing all \"Shorewall6 Lite firewall\" rules: "
|
||||||
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -104,14 +104,14 @@ shorewall6_stop () {
|
|||||||
|
|
||||||
# restart the firewall
|
# restart the firewall
|
||||||
shorewall6_restart () {
|
shorewall6_restart () {
|
||||||
echo -n "Restarting \"Shorewall6 Lite firewall\": "
|
printf "Restarting \"Shorewall6 Lite firewall\": "
|
||||||
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# refresh the firewall
|
# refresh the firewall
|
||||||
shorewall6_refresh () {
|
shorewall6_refresh () {
|
||||||
echo -n "Refreshing \"Shorewall6 Lite firewall\": "
|
printf "Refreshing \"Shorewall6 Lite firewall\": "
|
||||||
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#
|
#
|
||||||
. /usr/share/shorewall/shorewallrc
|
. /usr/share/shorewall/shorewallrc
|
||||||
|
|
||||||
prog="shorewall6-lite"
|
prog="shorewall -6l"
|
||||||
shorewall="${SBINDIR}/$prog"
|
shorewall="${SBINDIR}/$prog"
|
||||||
logger="logger -i -t $prog"
|
logger="logger -i -t $prog"
|
||||||
lockfile="/var/lock/subsys/$prog"
|
lockfile="/var/lock/subsys/$prog"
|
||||||
@@ -38,7 +38,7 @@ if [ -f ${SYSCONFDIR}/$prog ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo -n $"Starting Shorewall: "
|
printf $"Starting Shorewall: "
|
||||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -52,7 +52,7 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo -n $"Stopping Shorewall: "
|
printf $"Stopping Shorewall: "
|
||||||
$shorewall $OPTIONS stop 2>&1 | $logger
|
$shorewall $OPTIONS stop 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
@@ -68,7 +68,7 @@ stop() {
|
|||||||
restart() {
|
restart() {
|
||||||
# Note that we don't simply stop and start since shorewall has a built in
|
# Note that we don't simply stop and start since shorewall has a built in
|
||||||
# restart which stops the firewall if running and then starts it.
|
# restart which stops the firewall if running and then starts it.
|
||||||
echo -n $"Restarting Shorewall: "
|
printf $"Restarting Shorewall: "
|
||||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||||
retval=${PIPESTATUS[0]}
|
retval=${PIPESTATUS[0]}
|
||||||
if [[ $retval == 0 ]]; then
|
if [[ $retval == 0 ]]; then
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user