forked from extern/shorewall_code
Compare commits
231 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4a5a6ee008 | ||
|
48241d62d5 | ||
|
1621251d04 | ||
|
27f3ad5ee5 | ||
|
f816f9b3b2 | ||
|
b8196a932f | ||
|
422911f06b | ||
|
2a12e0950a | ||
|
9869dd25d7 | ||
|
e47b57fd4a | ||
|
3cbe0e7a1c | ||
|
221753c3c0 | ||
|
b14924bd64 | ||
|
c0a608ef84 | ||
|
c518e85215 | ||
|
34fd10df41 | ||
|
e7004da47c | ||
|
91c76f7559 | ||
|
2e4af68b98 | ||
|
de9f29d7d4 | ||
|
99ddb17c9e | ||
|
8ea9d0bbef | ||
|
ebe09a95b8 | ||
|
f32b304eb6 | ||
|
7bdd69d151 | ||
|
a08f0cfe10 | ||
|
09a81ae574 | ||
|
7042d586b2 | ||
|
e17c4ac8af | ||
|
37101a2031 | ||
|
40bcfd15e5 | ||
|
230ab06e5d | ||
|
09cda21dd4 | ||
|
9253f90ac5 | ||
|
f4cae55c1e | ||
|
070a67d665 | ||
|
9796c58eb2 | ||
|
cabc20957f | ||
|
a9a379c5a5 | ||
|
3bf5066f82 | ||
|
b2c33a0f9a | ||
|
64f704a964 | ||
|
416224ee05 | ||
|
92ce1beddc | ||
|
4d6bf8564e | ||
|
fb4b362724 | ||
|
97de2be778 | ||
|
85cae3c7f8 | ||
|
acd425a3c2 | ||
|
4e6949f996 | ||
|
5d7dcc3122 | ||
|
23d498146b | ||
|
422d0b216a | ||
|
37ecbff23a | ||
|
491309a78a | ||
|
bc993c384c | ||
|
0e4c1cdac1 | ||
|
27a0f0f7a0 | ||
|
9ac075fd56 | ||
|
b2604583af | ||
|
62c6411cb0 | ||
|
6badf3ce1a | ||
|
1bc90beb01 | ||
|
eaccf033c6 | ||
|
056711d304 | ||
|
0aa0bebe07 | ||
|
1a68d87c94 | ||
|
c518cfaa4a | ||
|
196a56ea3c | ||
|
2c3f121835 | ||
|
18ba5c7311 | ||
|
c8774110c6 | ||
|
1479e955d4 | ||
|
09980cc75e | ||
|
e0a757ea03 | ||
|
550003f0f4 | ||
|
4f50303318 | ||
|
5053999442 | ||
|
6b5889177b | ||
|
71f8bad300 | ||
|
377c9f5708 | ||
|
45a164733b | ||
|
6f82bfe7d1 | ||
|
4e5b98d3d9 | ||
|
078c781dfa | ||
|
46f68c6dcb | ||
|
b42678269c | ||
|
9bd10c0c00 | ||
|
f861f8da35 | ||
|
9e3cb27d0a | ||
|
5b97800901 | ||
|
d8a22d13dd | ||
|
675e41e6a6 | ||
|
28f6379956 | ||
|
c9b58e203b | ||
|
9afe8daae0 | ||
|
43adcd26a1 | ||
|
65371437b5 | ||
|
cc2022e172 | ||
|
f2a565729f | ||
|
ea8b2a803a | ||
|
16832149ca | ||
|
7edf4918d7 | ||
|
d3a1dc1e2a | ||
|
f68f47d01b | ||
|
b1d1fa862a | ||
|
24acf25451 | ||
|
229c47ac6c | ||
|
38de9c1732 | ||
|
17f4fd7cd2 | ||
|
cfd02c1bb6 | ||
|
02caeb5aa0 | ||
|
19b7601c72 | ||
|
5a8e9cd0a3 | ||
|
b5a6067588 | ||
|
45468af2d2 | ||
|
6c018f478c | ||
|
dec3cacb2a | ||
|
4ab8e1f0a2 | ||
|
821d72093a | ||
|
42d5d13780 | ||
|
7121a0f1b1 | ||
|
ab12d63a4f | ||
|
6ba1d5413b | ||
|
4fc572f664 | ||
|
138e64c54a | ||
|
b04b65cac8 | ||
|
c907748b52 | ||
|
7f3414e3d8 | ||
|
c75fe2ea8d | ||
|
5dcb684efc | ||
|
3e87e5004a | ||
|
c89b113a61 | ||
|
7289175070 | ||
|
5aaf1e53de | ||
|
a9373d727b | ||
|
528b473f6b | ||
|
d22210c074 | ||
|
89d6009200 | ||
|
f411f7dd31 | ||
|
502e98eb9f | ||
|
f73bad440d | ||
|
f0cb3f50e4 | ||
|
23bc019a82 | ||
|
9d299ef866 | ||
|
2a9272ccd1 | ||
|
130ddff9de | ||
|
9cf298482d | ||
|
c5a586aa37 | ||
|
0670ecaf5e | ||
|
d3eebde464 | ||
|
832418585a | ||
|
605f61fb3c | ||
|
824f4ca570 | ||
|
9acdbb5acf | ||
|
8dfa0be611 | ||
|
ef8b85fc3e | ||
|
2b5613026a | ||
|
c7c318c0e7 | ||
|
b48e5a8932 | ||
|
d1976189aa | ||
|
6b4905c2c0 | ||
|
774b707352 | ||
|
c3bd58827f | ||
|
b35f1112f4 | ||
|
a0eb91cb90 | ||
|
105e6a3d01 | ||
|
77d9eeb915 | ||
|
17838c1443 | ||
|
5867ce6c3b | ||
|
84cd80eba9 | ||
|
9b02f7a922 | ||
|
f1975ae9b0 | ||
|
7b9f7c095d | ||
|
8ea96098bf | ||
|
02ed36332a | ||
|
15a3b29a32 | ||
|
cb4f9e7261 | ||
|
bfab002dda | ||
|
ddb12fcad9 | ||
|
42ce754961 | ||
|
5cd4d63bc5 | ||
|
5b567f2d8b | ||
|
39a3c72057 | ||
|
b47e633c38 | ||
|
1b55a37a28 | ||
|
a97dcd23d0 | ||
|
108b169d8d | ||
|
a9fbaa57ed | ||
|
317f12041b | ||
|
8469f983d8 | ||
|
f54acb665a | ||
|
3d2e9eb93e | ||
|
c6a939301f | ||
|
1cb98254cc | ||
|
baa791a1e3 | ||
|
8b4b965f63 | ||
|
8ee2d6246c | ||
|
a7be3dfece | ||
|
846e8c4ece | ||
|
e2bf7e6584 | ||
|
ff3994f6a1 | ||
|
494ec9c59c | ||
|
1cde92e8f3 | ||
|
721a1e3b33 | ||
|
84fa774cb7 | ||
|
c39bc7b65f | ||
|
2548e8741d | ||
|
0a31fba6bb | ||
|
9701c9c522 | ||
|
973d352209 | ||
|
91e59c2ed4 | ||
|
be5aabcbfb | ||
|
a8937e6bc8 | ||
|
e91bd9a0e9 | ||
|
5e1cf17ebc | ||
|
85a7ec6fe5 | ||
|
fb831e3128 | ||
|
2ed11c7e15 | ||
|
ef1353790e | ||
|
4f79d2e82b | ||
|
e6a2ba78a4 | ||
|
41ea3bdeda | ||
|
1065c2951b | ||
|
3b373f3f21 | ||
|
0c05ab3bff | ||
|
ef3a33e3f4 | ||
|
b54a691110 | ||
|
90f33dd436 | ||
|
6f475cde3f | ||
|
6053a40af0 |
2
Shorewall-core/configure
vendored
2
Shorewall-core/configure
vendored
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Shorewall Packet Filtering Firewall RPM configuration program - V4.6
|
||||
#
|
||||
# (c) 2012,2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
#
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Script to install Shoreline Firewall Core Modules
|
||||
#
|
||||
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -335,9 +335,8 @@ for f in lib.* ; do
|
||||
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
|
||||
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/lib.base
|
||||
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/lib.cli
|
||||
fi
|
||||
|
||||
#
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.base
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.base
|
||||
#
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.cli.
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.cli.
|
||||
#
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -25,7 +25,7 @@
|
||||
# loaded after this one and replaces some of the functions declared here.
|
||||
#
|
||||
|
||||
SHOREWALL_CAPVERSION=50106
|
||||
SHOREWALL_CAPVERSION=50112
|
||||
|
||||
if [ -z "$g_basedir" ]; then
|
||||
#
|
||||
@@ -47,6 +47,10 @@ startup_error() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
only_root() {
|
||||
[ "$(id -u)" != 0 ] && fatal_error "The '$COMMAND' command may only be run by root"
|
||||
}
|
||||
|
||||
#
|
||||
# Display a chain if it exists
|
||||
#
|
||||
@@ -634,7 +638,7 @@ show_routing() {
|
||||
ip -$g_family rule list | find_tables | sort -u | while read table; do
|
||||
heading "Table $table:"
|
||||
if [ $g_family -eq 6 ]; then
|
||||
ip -$g_family -o route list table $table | grep -vF cache | sort_routes
|
||||
ip -6 -o route list table $table | grep -vF cache | sort_routes
|
||||
else
|
||||
ip -4 -o route list table $table | sort_routes
|
||||
fi
|
||||
@@ -647,7 +651,7 @@ show_routing() {
|
||||
else
|
||||
heading "Routing Table"
|
||||
if [ $g_family -eq 6 ]; then
|
||||
ip -$g_family -o route list | grep -vF cache | sort_routes
|
||||
ip -6 -o route list | grep -vF cache | sort_routes
|
||||
else
|
||||
ip -4 -o route list table $table | sort_routes
|
||||
fi
|
||||
@@ -1137,16 +1141,31 @@ show_a_macro() {
|
||||
cat ${directory}/macro.$1
|
||||
}
|
||||
#
|
||||
# Don't dump empty SPD entries
|
||||
# Don't dump empty SPD entries or entries from the other address family
|
||||
#
|
||||
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; };'
|
||||
spd_filter() {
|
||||
#
|
||||
# af = Address Family (4 or 6)
|
||||
# afok = Address Family of entry matches af
|
||||
# p = print the contents of A (entry is not empty)
|
||||
# i = Number of lines stored in A
|
||||
#
|
||||
awk -v af=$g_family \
|
||||
'function prnt(A,i, j) { while ( j < i ) print A[j++]; };\
|
||||
\
|
||||
/^src / { if (p) prnt( A, i );\
|
||||
afok = 1;\
|
||||
p = 0;\
|
||||
i = 0;\
|
||||
if ( af == 4 )\
|
||||
{ if ( /:/ ) afok = 0; }\
|
||||
else\
|
||||
{ if ( /\./ ) afok = 0; }\
|
||||
};\
|
||||
{ if ( afok ) A[i++] = $0; };\
|
||||
/tmpl/ { p = afok; };\
|
||||
\
|
||||
END { if (p) prnt( A, i ); }'
|
||||
}
|
||||
#
|
||||
# Print a heading with leading and trailing black lines
|
||||
@@ -1159,7 +1178,8 @@ heading() {
|
||||
|
||||
show_ipsec() {
|
||||
heading "PFKEY SPD"
|
||||
$IP -s xfrm policy | spd_filter
|
||||
$IP -s -$g_family xfrm policy | spd_filter
|
||||
|
||||
heading "PFKEY SAD"
|
||||
$IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # Don't divulge the keys
|
||||
}
|
||||
@@ -1187,6 +1207,7 @@ show_command() {
|
||||
show_macro() {
|
||||
foo=`grep 'This macro' $macro | sed 's/This macro //'`
|
||||
if [ -n "$foo" ]; then
|
||||
macro=$(basename $macro)
|
||||
macro=${macro#*.}
|
||||
foo=${foo%.*}
|
||||
if [ ${#macro} -gt 5 ]; then
|
||||
@@ -1281,37 +1302,47 @@ show_command() {
|
||||
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
|
||||
COMMAND="$COMMAND $1"
|
||||
|
||||
case "$1" in
|
||||
connections)
|
||||
only_root
|
||||
eval show_connections $@ $g_pager
|
||||
;;
|
||||
nat)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_nat $g_pager
|
||||
;;
|
||||
raw)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_raw $g_pager
|
||||
;;
|
||||
tos|mangle)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_mangle $g_pager
|
||||
;;
|
||||
log)
|
||||
[ $# -gt 2 ] && too_many_arguments $2
|
||||
|
||||
only_root
|
||||
setup_logread
|
||||
eval show_log $g_pager
|
||||
;;
|
||||
tc)
|
||||
only_root
|
||||
[ $# -gt 2 ] && too_many_arguments $2
|
||||
eval show_tc $@ $g_pager
|
||||
;;
|
||||
classifiers|filters)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_classifiers_command $g_pager
|
||||
;;
|
||||
zones)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
if [ -f ${VARDIR}/zones ]; then
|
||||
echo "$g_product $SHOREWALL_VERSION Zones at $g_hostname - $(date)"
|
||||
@@ -1335,6 +1366,7 @@ show_command() {
|
||||
fi
|
||||
;;
|
||||
capabilities)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
determine_capabilities
|
||||
VERBOSITY=2
|
||||
@@ -1371,6 +1403,7 @@ show_command() {
|
||||
fi
|
||||
;;
|
||||
chain)
|
||||
only_root
|
||||
shift
|
||||
eval show_chain $@ $g_pager
|
||||
;;
|
||||
@@ -1378,26 +1411,31 @@ show_command() {
|
||||
echo $VARDIR;
|
||||
;;
|
||||
policies)
|
||||
only_root
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_policies $g_pager
|
||||
;;
|
||||
ipa)
|
||||
only_root
|
||||
[ $g_family -eq 4 ] || fatal_error "'show ipa' is now available in $g_product"
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
eval show_ipa $g_pager
|
||||
;;
|
||||
marks)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
echo "$g_product $SHOREWALL_VERSION Mark Layout at $g_hostname - $(date)"
|
||||
echo
|
||||
[ -f ${VARDIR}/marks ] && cat ${VARDIR}/marks;
|
||||
;;
|
||||
nfacct)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
eval show_nfacct_command $g_pager
|
||||
;;
|
||||
arptables)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
resolve_arptables
|
||||
if [ -n "$arptables" -a -x $arptables ]; then
|
||||
eval show_arptables $g_pager
|
||||
@@ -1407,6 +1445,7 @@ show_command() {
|
||||
;;
|
||||
event)
|
||||
[ $# -gt 1 ] || too_many_arguments $2
|
||||
only_root
|
||||
echo "$g_product $SHOREWALL_VERSION events at $g_hostname - $(date)"
|
||||
echo
|
||||
shift
|
||||
@@ -1414,14 +1453,18 @@ show_command() {
|
||||
;;
|
||||
events)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
eval show_events_command $g_pager
|
||||
;;
|
||||
bl|blacklists)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
setup_dbl
|
||||
eval show_blacklists $g_pager
|
||||
;;
|
||||
opens)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
echo "$g_product $SHOREWALL_VERSION Temporarily opened connections at $g_hostname - $(date)"
|
||||
|
||||
if chain_exists dynamic; then
|
||||
@@ -1432,6 +1475,7 @@ show_command() {
|
||||
;;
|
||||
ipsec)
|
||||
[ $# -gt 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
eval show_ipsec_command $g_pager
|
||||
;;
|
||||
*)
|
||||
@@ -1480,6 +1524,8 @@ show_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
only_root
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
if [ $1 = dynamic -a $# -gt 1 ]; then
|
||||
shift
|
||||
@@ -1797,7 +1843,7 @@ do_dump_command() {
|
||||
|
||||
echo
|
||||
|
||||
qt mywhich ss && ss -${g_family}tunap || { qt mywhich netstat && netatat -tunap; }
|
||||
qt mywhich ss && ss -${g_family}tunap || { qt mywhich netstat && netstat -tunap; }
|
||||
|
||||
if [ -n "$TC_ENABLED" ]; then
|
||||
heading "Traffic Control"
|
||||
@@ -1911,41 +1957,6 @@ show_proc() # $1 = name of a file
|
||||
[ -f $1 ] && echo " $1 = $(cat $1)"
|
||||
}
|
||||
|
||||
read_yesno_with_timeout() {
|
||||
local timeout
|
||||
timeout=${1:-60}
|
||||
|
||||
case $timeout in
|
||||
*s)
|
||||
;;
|
||||
*m)
|
||||
timeout=$((${timeout%m} * 60))
|
||||
;;
|
||||
*h)
|
||||
timeout=$((${timeout%h} * 3600))
|
||||
;;
|
||||
esac
|
||||
|
||||
read -t $timeout yn 2> /dev/null
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
# read doesn't support timeout
|
||||
test -x /bin/bash || return 2 # bash is not installed so the feature is not available
|
||||
/bin/bash -c "read -t $timeout yn ; if [ \"\$yn\" == \"y\" ] ; then exit 0 ; else exit 1 ; fi" # invoke bash and use its version of read
|
||||
return $?
|
||||
else
|
||||
# read supports timeout
|
||||
case "$yn" in
|
||||
y|Y)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Create the appropriate -q option to pass onward
|
||||
#
|
||||
@@ -2529,109 +2540,114 @@ hits_command() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Issue an error message and terminate if the firewall isn't started
|
||||
#
|
||||
require_started() {
|
||||
if ! product_is_started; then
|
||||
error_message "ERROR: $g_product is not started"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# 'allow' command executor
|
||||
#
|
||||
allow_command() {
|
||||
|
||||
local allowed
|
||||
local which
|
||||
which='-s'
|
||||
local range
|
||||
range='--src-range'
|
||||
local dynexists
|
||||
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && missing_argument
|
||||
|
||||
if product_is_started ; then
|
||||
local allowed
|
||||
local which
|
||||
which='-s'
|
||||
local range
|
||||
range='--src-range'
|
||||
local dynexists
|
||||
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
|
||||
case ${IPSET:=ipset} in
|
||||
*/*)
|
||||
if [ ! -x "$IPSET" ]; then
|
||||
fatal_error "IPSET=$IPSET does not exist or is not executable"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
IPSET="$(mywhich $IPSET)"
|
||||
[ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if chain_exists dynamic; then
|
||||
dynexists=Yes
|
||||
elif [ -z "$g_blacklistipset" ]; then
|
||||
fatal_error "Dynamic blacklisting is not enabled in the current $g_product configuration"
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
|
||||
allowed=''
|
||||
|
||||
case $1 in
|
||||
from)
|
||||
which='-s'
|
||||
range='--src-range'
|
||||
continue
|
||||
;;
|
||||
to)
|
||||
which='-d'
|
||||
range='--dst-range'
|
||||
continue
|
||||
;;
|
||||
*-*)
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
if qt $IPSET -D $g_blacklistipset $1; then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$dynexists" ]; then
|
||||
if qt $g_tool -D dynamic -m iprange $range $1 -j reject ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j DROP ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j logdrop ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j logreject
|
||||
then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
if qt $IPSET -D $g_blacklistipset $1; then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$dynexists" ]; then
|
||||
if qt $g_tool -D dynamic $which $1 -j reject ||\
|
||||
qt $g_tool -D dynamic $which $1 -j DROP ||\
|
||||
qt $g_tool -D dynamic $which $1 -j logdrop ||\
|
||||
qt $g_tool -D dynamic $which $1 -j logreject
|
||||
then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$allowed" ]; then
|
||||
progress_message2 "$1 Allowed"
|
||||
else
|
||||
error_message "WARNING: $1 already allowed (not dynamically blacklisted)"
|
||||
fi
|
||||
done
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
else
|
||||
error_message "ERROR: $g_product is not started"
|
||||
exit 2
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
case ${IPSET:=ipset} in
|
||||
*/*)
|
||||
if [ ! -x "$IPSET" ]; then
|
||||
fatal_error "IPSET=$IPSET does not exist or is not executable"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
IPSET="$(mywhich $IPSET)"
|
||||
[ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if chain_exists dynamic; then
|
||||
dynexists=Yes
|
||||
elif [ -z "$g_blacklistipset" ]; then
|
||||
require_started
|
||||
fatal_error "Dynamic blacklisting is not enabled in the current $g_product configuration"
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
|
||||
allowed=''
|
||||
|
||||
case $1 in
|
||||
from)
|
||||
which='-s'
|
||||
range='--src-range'
|
||||
continue
|
||||
;;
|
||||
to)
|
||||
which='-d'
|
||||
range='--dst-range'
|
||||
continue
|
||||
;;
|
||||
*-*)
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
if qt $IPSET -D $g_blacklistipset $1; then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$dynexists" ]; then
|
||||
if qt $g_tool -D dynamic -m iprange $range $1 -j reject ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j DROP ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j logdrop ||\
|
||||
qt $g_tool -D dynamic -m iprange $range $1 -j logreject
|
||||
then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ -n "$g_blacklistipset" ]; then
|
||||
if qt $IPSET -D $g_blacklistipset $1; then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$dynexists" ]; then
|
||||
if qt $g_tool -D dynamic $which $1 -j reject ||\
|
||||
qt $g_tool -D dynamic $which $1 -j DROP ||\
|
||||
qt $g_tool -D dynamic $which $1 -j logdrop ||\
|
||||
qt $g_tool -D dynamic $which $1 -j logreject
|
||||
then
|
||||
allowed=Yes
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$allowed" ]; then
|
||||
progress_message2 "$1 Allowed"
|
||||
else
|
||||
error_message "WARNING: $1 already allowed (not dynamically blacklisted)"
|
||||
fi
|
||||
done
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2770,7 +2786,7 @@ determine_capabilities() {
|
||||
GOTO_TARGET=
|
||||
LOGMARK_TARGET=
|
||||
IPMARK_TARGET=
|
||||
LOG_TARGET=Yes
|
||||
LOG_TARGET=
|
||||
ULOG_TARGET=
|
||||
NFLOG_TARGET=
|
||||
PERSISTENT_SNAT=
|
||||
@@ -2847,6 +2863,7 @@ determine_capabilities() {
|
||||
qt $g_tool -t nat -A $chain -j NETMAP --to 2001:470:B:227::/64 && NETMAP_TARGET=Yes
|
||||
fi
|
||||
qt $g_tool -t nat -A $chain -j MASQUERADE && MASQUERADE_TGT=Yes
|
||||
qt $g_tool -t nat -L INPUT -n && NAT_INPUT_CHAIN=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 -F $chain
|
||||
qt $g_tool -t nat -X $chain
|
||||
@@ -3138,7 +3155,7 @@ determine_capabilities() {
|
||||
qt $g_tool -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes
|
||||
qt $g_tool -A $chain -g $chain1 && GOTO_TARGET=Yes
|
||||
qt $g_tool -A $chain -j LOGMARK && LOGMARK_TARGET=Yes
|
||||
qt $g_tool -A $chain -j LOG || LOG_TARGET=
|
||||
qt $g_tool -A $chain -j LOG && LOG_TARGET=Yes
|
||||
qt $g_tool -A $chain -j ULOG && ULOG_TARGET=Yes
|
||||
qt $g_tool -A $chain -j MARK --set-mark 5 && MARK_ANYWHERE=Yes
|
||||
qt $g_tool -A $chain -m statistic --mode nth --every 2 --packet 1 && STATISTIC_MATCH=Yes
|
||||
@@ -3221,8 +3238,8 @@ report_capabilities_unsorted() {
|
||||
[ -n "$RECENT_MATCH" ] && report_capability 'Recent Match "--reap" option (REAP_OPTION)' $REAP_OPTION
|
||||
report_capability "Owner Match (OWNER_MATCH)" $OWNER_MATCH
|
||||
report_capability "Owner Name Match (OWNER_NAME_MATCH)" $OWNER_NAME_MATCH
|
||||
report_capability "Ipset Match (IPSET_MATCH)" $IPSET_MATCH
|
||||
if [ -n "$IPSET_MATCH" ]; then
|
||||
report_capability "Ipset Match (IPSET_MATCH)" $IPSET_MATCH
|
||||
[ -n "$OLD_IPSET_MATCH" ] && report_capability "OLD_Ipset Match (OLD_IPSET_MATCH)" $OLD_IPSET_MATCH
|
||||
[ -n "$IPSET_MATCH_NOMATCH" ] && report_capability "Ipset Match Nomatch (IPSET_MATCH_NOMATCH)" $IPSET_MATCH_NOMATCH
|
||||
[ -n "$IPSET_MATCH_NOMATCH" ] && report_capability "Ipset Match Counters (IPSET_MATCH_COUNTERS)" $IPSET_MATCH_COUNTERS
|
||||
@@ -3315,6 +3332,7 @@ report_capabilities_unsorted() {
|
||||
report_capability "NFQUEUE CPU Fanout (CPU_FANOUT)" $CPU_FANOUT
|
||||
report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET
|
||||
report_capability "--nflog-size support (NFLOG_SIZE)" $NFLOG_SIZE
|
||||
report_capability "INPUT chain in nat table (NAT_INPUT_CHAIN)" $NAT_INPUT_CHAIN
|
||||
|
||||
echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
|
||||
echo " Capabilities Version (CAPVERSION): $CAPVERSION"
|
||||
@@ -3423,6 +3441,7 @@ report_capabilities_unsorted1() {
|
||||
report_capability1 NETMAP_TARGET
|
||||
report_capability1 NFLOG_SIZE
|
||||
report_capability1 RESTORE_WAIT_OPTION
|
||||
report_capability1 NAT_INPUT_CHAIN
|
||||
|
||||
report_capability1 AMANDA_HELPER
|
||||
report_capability1 FTP_HELPER
|
||||
@@ -3727,7 +3746,7 @@ ipcalc_command() {
|
||||
|
||||
valid_address $address || fatal_error "Invalid IP address: $address"
|
||||
[ -z "$vlsm" ] && fatal_error "Missing VLSM"
|
||||
[ "x$address" = "x$vlsm" ] && "Invalid VLSM"
|
||||
[ "x$address" = "x$vlsm" ] && fatal_error "Invalid VLSM"
|
||||
[ $vlsm -gt 32 ] && fatal_error "Invalid VLSM: /$vlsm"
|
||||
|
||||
address=$address/$vlsm
|
||||
@@ -4569,12 +4588,14 @@ shorewall_cli() {
|
||||
|
||||
case "$COMMAND" in
|
||||
start)
|
||||
only_root
|
||||
get_config Yes Yes
|
||||
shift
|
||||
start_command $@
|
||||
;;
|
||||
stop|clear)
|
||||
[ $# -ne 1 ] && too_many_arguments $2
|
||||
only_root
|
||||
get_config
|
||||
[ -x $g_firewall ] || fatal_error "$g_product has never been started"
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
@@ -4582,6 +4603,7 @@ shorewall_cli() {
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
;;
|
||||
reset)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
@@ -4590,11 +4612,13 @@ shorewall_cli() {
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
;;
|
||||
reload|restart)
|
||||
only_root
|
||||
get_config Yes Yes
|
||||
shift
|
||||
restart_command $@
|
||||
;;
|
||||
disable|enable|reenable)
|
||||
only_root
|
||||
get_config Yes
|
||||
if product_is_started; then
|
||||
run_it ${VARDIR}/firewall $g_debugging $@
|
||||
@@ -4603,6 +4627,7 @@ shorewall_cli() {
|
||||
fi
|
||||
;;
|
||||
blacklist)
|
||||
only_root
|
||||
get_config Yes
|
||||
shift
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
@@ -4611,6 +4636,7 @@ shorewall_cli() {
|
||||
;;
|
||||
run)
|
||||
[ $# -gt 1 ] || fatal_error "Missing function name"
|
||||
only_root
|
||||
get_config Yes
|
||||
run_command $@
|
||||
;;
|
||||
@@ -4620,18 +4646,20 @@ shorewall_cli() {
|
||||
show_command $@
|
||||
;;
|
||||
status)
|
||||
[ "$(id -u)" != 0 ] && fatal_error "The status command may only be run by root"
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
status_command $@
|
||||
;;
|
||||
dump)
|
||||
only_root
|
||||
get_config Yes No Yes
|
||||
shift
|
||||
dump_command $@
|
||||
;;
|
||||
hits)
|
||||
[ $g_family -eq 6 ] && fatal_error "$g_product does not support the hits command"
|
||||
only_root
|
||||
get_config Yes No Yes
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
shift
|
||||
@@ -4642,53 +4670,63 @@ shorewall_cli() {
|
||||
version_command $@
|
||||
;;
|
||||
logwatch)
|
||||
only_root
|
||||
get_config Yes Yes Yes
|
||||
banner="${g_product}-$SHOREWALL_VERSION Logwatch at $g_hostname -"
|
||||
logwatch_command $@
|
||||
;;
|
||||
drop)
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && missing_argument
|
||||
drop_command $@
|
||||
;;
|
||||
logdrop)
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && missing_argument
|
||||
logdrop_command $@
|
||||
;;
|
||||
reject|logreject)
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && missing_argument
|
||||
reject_command $@
|
||||
;;
|
||||
open|close)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
open_close_command $@
|
||||
;;
|
||||
allow)
|
||||
only_root
|
||||
get_config
|
||||
allow_command $@
|
||||
;;
|
||||
add)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
add_command $@
|
||||
;;
|
||||
delete)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
delete_command $@
|
||||
;;
|
||||
save)
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
save_command $@
|
||||
;;
|
||||
forget)
|
||||
only_root
|
||||
get_config
|
||||
forget_command $@
|
||||
;;
|
||||
@@ -4705,11 +4743,13 @@ shorewall_cli() {
|
||||
ipdecimal_command $@
|
||||
;;
|
||||
restore)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
restore_command $@
|
||||
;;
|
||||
call)
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
#
|
||||
@@ -4747,17 +4787,20 @@ shorewall_cli() {
|
||||
usage
|
||||
;;
|
||||
iptrace)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
iptrace_command $@
|
||||
;;
|
||||
noiptrace)
|
||||
only_root
|
||||
get_config
|
||||
shift
|
||||
noiptrace_command $@
|
||||
;;
|
||||
savesets)
|
||||
[ $# -eq 1 ] || too_many_arguments $2
|
||||
only_root
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
savesets1
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.common.
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.common.
|
||||
#
|
||||
# (c) 2010-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2010-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -269,53 +269,48 @@ loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
shift
|
||||
local moduleoptions
|
||||
moduleoptions=$*
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if [ -d /sys/module/ ]; then
|
||||
if ! list_search $modulename $DONT_LOAD; then
|
||||
if [ ! -d /sys/module/$modulename ]; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
for directory in $moduledirectories; do
|
||||
for modulefile in $directory/${modulename}.*; do
|
||||
if [ -f $modulefile ]; then
|
||||
insmod $modulefile $moduleoptions
|
||||
return
|
||||
fi
|
||||
done
|
||||
done
|
||||
;;
|
||||
*)
|
||||
modprobe -q $modulename $moduleoptions
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
elif ! list_search $modulename $DONT_LOAD $MODULES; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
for directory in $moduledirectories; do
|
||||
for modulefile in $directory/${modulename}.*; do
|
||||
if [ -f $modulefile ]; then
|
||||
insmod $modulefile $moduleoptions
|
||||
return
|
||||
fi
|
||||
done
|
||||
done
|
||||
;;
|
||||
*)
|
||||
modprobe -q $modulename $moduleoptions
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -338,8 +333,6 @@ reload_kernel_modules() {
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
|
||||
|
||||
if [ -n "$MODULESDIR" ]; then
|
||||
case "$MODULESDIR" in
|
||||
+*)
|
||||
@@ -394,8 +387,6 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
|
||||
|
||||
if [ -n "$MODULESDIR" ]; then
|
||||
case "$MODULESDIR" in
|
||||
+*)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.core
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.core
|
||||
#
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -24,7 +24,7 @@
|
||||
# generated scripts.
|
||||
#
|
||||
|
||||
SHOREWALL_LIBVERSION=50100
|
||||
SHOREWALL_LIBVERSION=50108
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.installer.
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
|
||||
#
|
||||
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.installer.
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
|
||||
#
|
||||
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
|
||||
|
@@ -3187,14 +3187,15 @@
|
||||
shorewall-arprules(5), shorewall-blrules(5), shorewall.conf(5),
|
||||
shorewall-conntrack(5), shorewall-ecn(5), shorewall-exclusion(5),
|
||||
shorewall-hosts(5), shorewall-init(5), shorewall_interfaces(5),
|
||||
shorewall-ipsets(5), shorewall-maclist(5), shorewall-mangle(5),
|
||||
shorewall-masq(5), shorewall-modules(5), shorewall-nat(5),
|
||||
shorewall-nesting(5), shorewall-netmap(5), shorewall-params(5),
|
||||
shorewall-policy(5), shorewall-providers(5), shorewall-proxyarp(5),
|
||||
shorewall6-proxyndp(5), shorewall-routes(5), shorewall-rtrules(5),
|
||||
shorewall-rtrules(5), shorewall-rules(5), shorewall-secmarks(5),
|
||||
shorewall-snat(5), shorewall-tcclasses(5), shorewall-tcdevices(5),
|
||||
shorewall-tcfilters(5), shorewall-tcinterfaces(5), shorewall-tcpri(5),
|
||||
shorewall-tunnels(5), shorewall-vardir(5), shorewall-zones(5)</para>
|
||||
shorewall-ipsets(5), shorewall-logging(), shorewall-maclist(5),
|
||||
shorewall-mangle(5), shorewall-masq(5), shorewall-modules(5),
|
||||
shorewall-nat(5), shorewall-nesting(5), shorewall-netmap(5),
|
||||
shorewall-params(5), shorewall-policy(5), shorewall-providers(5),
|
||||
shorewall-proxyarp(5), shorewall6-proxyndp(5), shorewall-routes(5),
|
||||
shorewall-rtrules(5), shorewall-rtrules(5), shorewall-rules(5),
|
||||
shorewall-secmarks(5), shorewall-snat(5), shorewall-tcclasses(5),
|
||||
shorewall-tcdevices(5), shorewall-tcfilters(5), shorewall-tcinterfaces(5),
|
||||
shorewall-tcpri(5), shorewall-tunnels(5), shorewall-vardir(5),
|
||||
shorewall-zones(5)</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall Packet Filtering Firewall Control Program - V5.0
|
||||
# Shorewall Packet Filtering Firewall Control Program - V5.1
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015 -
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017
|
||||
# Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
@@ -25,6 +25,10 @@
|
||||
# For a list of supported commands, type 'shorewall help' or 'shorewall6 help'
|
||||
#
|
||||
################################################################################################
|
||||
#
|
||||
# Default product is Shorewall. PRODUCT will be set based on $0 and on passed -[46] and -l
|
||||
# options
|
||||
#
|
||||
PRODUCT=shorewall
|
||||
|
||||
#
|
||||
|
@@ -73,12 +73,16 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
else
|
||||
return 0
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -108,16 +112,14 @@ shorewall_start () {
|
||||
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
)
|
||||
fi
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
)
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -145,9 +147,7 @@ shorewall_stop () {
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -159,8 +159,9 @@ shorewall_stop () {
|
||||
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
echo_notdone
|
||||
fi
|
||||
|
||||
|
@@ -44,12 +44,14 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -66,20 +68,20 @@ start () {
|
||||
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
|
||||
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
||||
ipset -R < "$SAVE_IPSETS"
|
||||
fi
|
||||
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq 0 ]; then
|
||||
if [ -x "${STATEDIR}/firewall" ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
[ $retval -ne 0 ] && break
|
||||
else
|
||||
retval=6 #Product not configured
|
||||
break
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
[ $retval -ne 0 ] && break
|
||||
else
|
||||
retval=6 #Product not configured
|
||||
break
|
||||
fi
|
||||
done
|
||||
@@ -106,20 +108,25 @@ stop () {
|
||||
retval=$?
|
||||
|
||||
if [ $retval -eq 0 ]; then
|
||||
if [ -x "${STATEDIR}/firewall" ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
[ $retval -ne 0 ] && break
|
||||
else
|
||||
retval=6 #Product not configured
|
||||
break
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
[ $retval -ne 0 ] && break
|
||||
else
|
||||
retval=6 #Product not configured
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $retval -eq 0 ]; then
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f $lockfile
|
||||
success
|
||||
else
|
||||
|
24
Shorewall-init/init.openwrt.sh
Normal file → Executable file
24
Shorewall-init/init.openwrt.sh
Normal file → Executable file
@@ -75,12 +75,14 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -92,10 +94,8 @@ start () {
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -103,6 +103,8 @@ start () {
|
||||
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
||||
ipset -R < "$SAVE_IPSETS"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
boot () {
|
||||
@@ -117,17 +119,19 @@ stop () {
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@@ -69,10 +69,12 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
||||
else
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -84,10 +86,8 @@ shorewall_start () {
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -107,16 +107,16 @@ shorewall_stop () {
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -79,12 +79,14 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 0
|
||||
return 6
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -96,10 +98,8 @@ shorewall_start () {
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x $STATEDIR/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
|
||||
fi
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -117,16 +117,16 @@ shorewall_stop () {
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@@ -33,12 +33,12 @@ setstatedir() {
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
return 0
|
||||
elif [ $PRODUCT = shorewall ]; then
|
||||
${SBINDIR}/shorewall compile
|
||||
elif [ $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/shorewall -6 compile
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -67,16 +67,14 @@ shorewall_start () {
|
||||
printf "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
)
|
||||
fi
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
)
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -95,16 +93,16 @@ shorewall_stop () {
|
||||
printf "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
|
||||
else
|
||||
rm -f "${SAVE_IPSETS}.tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#
|
||||
# On the target system (the system where the firewall program is to run):
|
||||
#
|
||||
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities
|
||||
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
|
||||
#
|
||||
# Now move the capabilities file to the compilation system. The file must
|
||||
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
|
||||
@@ -38,7 +38,6 @@
|
||||
#
|
||||
# IPTABLES - iptables
|
||||
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
|
||||
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
|
||||
#
|
||||
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
|
||||
# used during firewall compilation, then the generated firewall program will likewise not
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/action.A_REJECTWITH
|
||||
# Shorewall -- /usr/share/shorewall/action.A_REJECT
|
||||
#
|
||||
# A_REJECT Action.
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2012-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2012-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -13,7 +13,6 @@ DEFAULTS ACCEPT
|
||||
@1 - - icmp time-exceeded {comment="Needed ICMP types"}
|
||||
?else
|
||||
?COMMENT Needed ICMP types (RFC4890)
|
||||
|
||||
@1 - - ipv6-icmp destination-unreachable
|
||||
@1 - - ipv6-icmp packet-too-big
|
||||
@1 - - ipv6-icmp time-exceeded
|
||||
@@ -38,7 +37,7 @@ DEFAULTS ACCEPT
|
||||
@1 - - ipv6-icmp 148 # Certificate path solicitation
|
||||
@1 - - ipv6-icmp 149 # Certificate path advertisement
|
||||
|
||||
# The following should have a link local source address and a ttl of 1 and must be allowed to transit abridge
|
||||
# The following should have a link local source address and a ttl of 1 and must be allowed to transit a bridge
|
||||
@1 fe80::/10 - ipv6-icmp 151 # Multicast router advertisement
|
||||
@1 fe80::/10 - ipv6-icmp 152 # Multicast router solicitation
|
||||
@1 fe80::/10 - ipv6-icmp 153 # Multicast router termination
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2012-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -30,4 +30,4 @@
|
||||
|
||||
DEFAULTS ACCEPT,-
|
||||
|
||||
@1 - - ;;+ -p 6 --tcp-flags ACK,FIN,PSH ACK,FIN,PSH
|
||||
@1 - - ;;+ -p 6 --tcp-flags ACK,FIN ACK,FIN
|
||||
|
@@ -107,6 +107,11 @@ if ( $command & $REAP_OPT ) {
|
||||
|
||||
$duration .= '--rttl ' if $command & $TTL_OPT;
|
||||
|
||||
if ( ( $targets{$action} || 0 ) & NATRULE ) {
|
||||
perl_action_helper( "${action}-", "-m recent --rcheck ${duration}--hitcount $hitcount" );
|
||||
$action = 'ACCEPT';
|
||||
}
|
||||
|
||||
if ( $command & $RESET_CMD ) {
|
||||
require_capability 'MARK_ANYWHERE', '"reset"', 's';
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
# Invalid Action
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2012-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -41,6 +41,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
|
||||
set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( ( $targets{$action} || 0 ) & NATRULE ) {
|
||||
perl_action_helper( "${action}-", "" );
|
||||
$action = 'ACCEPT';
|
||||
}
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rdest" );
|
||||
} else {
|
||||
|
@@ -37,6 +37,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
|
||||
set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( ( $targets{$action} || 0 ) & NATRULE ) {
|
||||
perl_action_helper( "${action}-", "" );
|
||||
$action = 'ACCEPT';
|
||||
}
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --set --rdest" );
|
||||
} else {
|
||||
|
@@ -26,4 +26,4 @@ $tcpflags_action - - ;;+ -p 6 --tcp-flags ALL FIN,URG,PSH
|
||||
$tcpflags_action - - ;;+ -p 6 --tcp-flags ALL NONE
|
||||
$tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,RST SYN,RST
|
||||
$tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,FIN SYN,FIN
|
||||
$tcpflags_action - - ;;+ -p tcp --syn --sport 0
|
||||
$tcpflags_action - - ;;+ -p 6 --syn --sport 0
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
9
Shorewall/Macros/macro.Apcupsd
Normal file
9
Shorewall/Macros/macro.Apcupsd
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.Apcupsd
|
||||
#
|
||||
# This macro handles apcupsd traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 3551
|
16
Shorewall/Macros/macro.FreeIPA
Normal file
16
Shorewall/Macros/macro.FreeIPA
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.FreeIPA
|
||||
#
|
||||
# This macro handles FreeIPA server traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
DNS
|
||||
HTTP
|
||||
HTTPS
|
||||
Kerberos
|
||||
Kpasswd
|
||||
LDAP
|
||||
LDAPS
|
||||
NTP
|
@@ -11,13 +11,20 @@
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 623 # RMCP
|
||||
PARAM - - udp 623 # RMCP
|
||||
PARAM - - tcp 3668,3669 # Virtual Media, Secure (Dell)
|
||||
PARAM - - tcp 5120,5123 # CD, floppy (Asus, Aten)
|
||||
PARAM - - tcp 5120,5122,5123 # CD,FD,HD (Asus, Aten)
|
||||
PARAM - - tcp 5900,5901 # Remote Console (Aten, Dell)
|
||||
PARAM - - tcp 7578 # Remote Console (AMI)
|
||||
PARAM - - udp 623 # RMCP
|
||||
PARAM - - tcp 8889 # WS-MAN
|
||||
HTTP
|
||||
HTTPS
|
||||
SNMP
|
||||
SSH # Serial over Lan
|
||||
Telnet
|
||||
SNMP
|
||||
|
||||
# TLS/secure ports
|
||||
PARAM - - tcp 3520 # Remote Console (Redfish)
|
||||
PARAM - - tcp 3669 # Virtual Media (Dell)
|
||||
PARAM - - tcp 5124,5126,5127 # CD,FD,HD (AMI)
|
||||
PARAM - - tcp 7582 # Remote Console (AMI)
|
||||
HTTPS
|
||||
SSH # Serial over Lan
|
||||
|
10
Shorewall/Macros/macro.Kpasswd
Normal file
10
Shorewall/Macros/macro.Kpasswd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.Kpasswd
|
||||
#
|
||||
# This macro handles Kerberos "passwd" traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 464
|
||||
PARAM - - udp 464
|
9
Shorewall/Macros/macro.RedisSecure
Normal file
9
Shorewall/Macros/macro.RedisSecure
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.RedisSecure
|
||||
#
|
||||
# This macro handles Redis Secure (SSL/TLS) traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 6380
|
9
Shorewall/Macros/macro.Rwhois
Normal file
9
Shorewall/Macros/macro.Rwhois
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.Rwhois
|
||||
#
|
||||
# This macro handles Remote Who Is (rwhois) traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - tcp 4321
|
9
Shorewall/Macros/macro.SSDP
Normal file
9
Shorewall/Macros/macro.SSDP
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.SSDP
|
||||
#
|
||||
# This macro handles SSDP (used by DLNA/UPnP) client traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - udp 1900
|
10
Shorewall/Macros/macro.SSDPserver
Normal file
10
Shorewall/Macros/macro.SSDPserver
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# Shorewall -- /usr/share/shorewall/macro.SSDPserver
|
||||
#
|
||||
# This macro handles SSDP (used by DLNA/UPnP) server bidirectional traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
|
||||
|
||||
PARAM - - udp 1900
|
||||
PARAM DEST SOURCE udp - 1900
|
@@ -1,82 +0,0 @@
|
||||
# Shorewall Packet Filtering Firewall Export Directory Makefile - V4.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of Version 2 of the GNU General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
################################################################################
|
||||
# Place this file in each export directory. Modify each copy to set HOST
|
||||
# to the name of the remote firewall corresponding to the directory.
|
||||
#
|
||||
# To make the 'firewall' script, type "make".
|
||||
#
|
||||
# Once the script is compiling correctly, you can install it by
|
||||
# typing "make install".
|
||||
#
|
||||
################################################################################
|
||||
# V A R I A B L E S
|
||||
#
|
||||
# Files in the export directory on which the firewall script does not depend
|
||||
#
|
||||
IGNOREFILES = firewall% Makefile% trace% %~
|
||||
#
|
||||
# Remote Firewall system
|
||||
#
|
||||
HOST = gateway
|
||||
#
|
||||
# Save some typing
|
||||
#
|
||||
LITEDIR = /var/lib/shorewall-lite
|
||||
#
|
||||
# Set this if the remote system has a non-standard modules directory
|
||||
#
|
||||
MODULESDIR=
|
||||
#
|
||||
# Default target is the firewall script
|
||||
#
|
||||
################################################################################
|
||||
# T A R G E T S
|
||||
#
|
||||
all: firewall
|
||||
#
|
||||
# Only generate the capabilities file if it doesn't already exist
|
||||
#
|
||||
capabilities:
|
||||
ssh root@$(HOST) "MODULESDIR=$(MODULESDIR) /usr/share/shorewall-lite/shorecap > $(LITEDIR)/capabilities"
|
||||
scp root@$(HOST):$(LITEDIR)/capabilities .
|
||||
#
|
||||
# Compile the firewall script. Using the 'wildcard' function causes "*" to be expanded so that
|
||||
# 'filter-out' will be presented with the list of files in this directory rather than "*"
|
||||
#
|
||||
firewall: $(filter-out $(IGNOREFILES) capabilities , $(wildcard *) ) capabilities
|
||||
shorewall compile -e . firewall
|
||||
#
|
||||
# Only reload on demand.
|
||||
#
|
||||
install: firewall
|
||||
scp firewall firewall.conf root@$(HOST):$(LITEDIR)
|
||||
ssh root@$(HOST) "/sbin/shorewall-lite restart"
|
||||
#
|
||||
# Save running configuration
|
||||
#
|
||||
save:
|
||||
ssh root@$(HOST) "/sbin/shorewall-lite save"
|
||||
#
|
||||
# Remove generated files
|
||||
#
|
||||
clean:
|
||||
rm -f capabilities firewall firewall.conf reload
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Accounting.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Accounting.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Chains.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Chains.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -335,7 +335,7 @@ our $VERSION = 'MODULEVERSION';
|
||||
# logchains => { <key1> = <chainref1>, ... }
|
||||
# references => { <ref1> => <refs>, <ref2> => <refs>, ... }
|
||||
# blacklistsection
|
||||
# => Chain was created by entries in the BLACKLIST section of the rules file
|
||||
# => Chain was created by entries in the blrules file
|
||||
# action => <action tuple that generated this chain>
|
||||
# restricted => Logical OR of restrictions of rules in this chain.
|
||||
# restriction => Restrictions on further rules in this chain.
|
||||
@@ -361,13 +361,13 @@ our $VERSION = 'MODULEVERSION';
|
||||
#
|
||||
# Only 'referenced' chains get written to the iptables-restore input.
|
||||
#
|
||||
# 'loglevel', 'synparams', 'synchain', 'audit', 'default' abd 'origin' only apply to policy chains.
|
||||
# 'loglevel', 'synparams', 'synchain', 'audit', 'default' and 'origin' only apply to policy chains.
|
||||
###########################################################################################################################################
|
||||
#
|
||||
# For each ordered pair of zones, there may exist a 'canonical rules chain' in the filter table; the name of this chain is formed by
|
||||
# joining the names of the zones using the ZONE_SEPARATOR ('2' or '-'). This chain contains the rules that specifically deal with
|
||||
# connections from the first zone to the second. These chains will end with the policy rules when EXPAND_POLICIES=Yes and when there is an
|
||||
# explicit policy for the order pair. Otherwise, unless the applicable policy is CONTINUE, the chain will terminate with a jump to a
|
||||
# explicit policy for the ordered pair. Otherwise, unless the applicable policy is CONTINUE, the chain will terminate with a jump to a
|
||||
# wildcard policy chain (all[2-]zone, zone[2-]all, or all[2-]all).
|
||||
#
|
||||
# Except in the most trivial one-interface configurations, each zone has a "forward chain" which is branched to from the filter table
|
||||
@@ -397,7 +397,7 @@ our $VERSION = 'MODULEVERSION';
|
||||
# MAC Recent - <dev>_rec
|
||||
# SNAT - <dev>_snat
|
||||
# ECN - <dev>_ecn
|
||||
# FORWARD Options - <dev>_fop
|
||||
# INPUT Options - <dev>_iop
|
||||
# OUTPUT Options - <dev>_oop
|
||||
# FORWARD Options - <dev>_fop
|
||||
#
|
||||
@@ -874,6 +874,9 @@ sub validate_port( $$ ) {
|
||||
fatal_error "Invalid/Unknown $proto port/service ($_[1])" unless defined $value;
|
||||
}
|
||||
|
||||
#
|
||||
# Port or port-pair separated by ':'. Either port may be omitted in the pair
|
||||
#
|
||||
sub validate_portpair( $$ ) {
|
||||
my ($proto, $portpair) = @_;
|
||||
my $what;
|
||||
@@ -914,15 +917,15 @@ sub validate_portpair( $$ ) {
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# Port or port-pair separated by '-'. Neither port may be omitted in the pair
|
||||
#
|
||||
sub validate_portpair1( $$ ) {
|
||||
my ($proto, $portpair) = @_;
|
||||
my $what;
|
||||
|
||||
fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/-/-/ > 1;
|
||||
|
||||
$portpair = "1$portpair" if substr( $portpair, 0, 1 ) eq ':';
|
||||
$portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':';
|
||||
|
||||
my @ports = split /-/, $portpair, 2;
|
||||
|
||||
my $protonum = resolve_proto( $proto ) || 0;
|
||||
@@ -1316,14 +1319,14 @@ sub pop_match( $$ ) {
|
||||
|
||||
sub clone_irule( $ );
|
||||
|
||||
sub format_rule( $$;$ ) {
|
||||
my ( $chainref, $rulerefp, $suppresshdr ) = @_;
|
||||
sub format_rule( $$ ) {
|
||||
my ( $chainref, $rulerefp ) = @_;
|
||||
|
||||
return $rulerefp->{cmd} if exists $rulerefp->{cmd};
|
||||
|
||||
my $rule = $suppresshdr ? '' : "-A $chainref->{name}";
|
||||
my $rule = "-A $chainref->{name}";
|
||||
#
|
||||
# The code the follows can be destructive of the rule so we clone it
|
||||
# The code that follows can be destructive of the rule so we clone it
|
||||
#
|
||||
my $ruleref = $rulerefp->{complex} ? clone_irule( $rulerefp ) : $rulerefp;
|
||||
my $nfacct = $rulerefp->{nfacct};
|
||||
@@ -1403,13 +1406,15 @@ sub compatible( $$ ) {
|
||||
}
|
||||
#
|
||||
# Don't combine chains where each specifies
|
||||
# -m policy
|
||||
# -m policy and the policies are different
|
||||
# or when one specifies
|
||||
# -m multiport
|
||||
# and the other specifies
|
||||
# --dport or --sport or -m multiport
|
||||
#
|
||||
return ! ( $ref1->{policy} && $ref2->{policy} ||
|
||||
my ( $p1, $p2 );
|
||||
|
||||
return ! ( ( ( $p1 = $ref1->{policy} ) && ( $p2 = $ref2->{policy} ) && $p1 ne $p2 ) ||
|
||||
( ( $ref1->{multiport} && ( $ref2->{dport} || $ref2->{sport} || $ref2->{multiport} ) ) ||
|
||||
( $ref2->{multiport} && ( $ref1->{dport} || $ref1->{sport} ) ) ) );
|
||||
}
|
||||
@@ -2296,8 +2301,6 @@ sub use_forward_chain($$) {
|
||||
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
|
||||
return 1 if @{$chainref->{rules}} && ( $config{OPTIMIZE} & OPTIMIZE_USE_FIRST );
|
||||
#
|
||||
# Use it if we already have jumps to it
|
||||
#
|
||||
@@ -2372,8 +2375,6 @@ sub use_input_chain($$) {
|
||||
my ( $interface, $chainref ) = @_;
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
|
||||
return 1 if @{$chainref->{rules}} && ( $config{OPTIMIZE} & OPTIMIZE_USE_FIRST );
|
||||
#
|
||||
# We must use the interfaces's chain if the interface is associated with multiple Zones
|
||||
#
|
||||
@@ -2453,8 +2454,6 @@ sub use_output_chain($$) {
|
||||
my ( $interface, $chainref) = @_;
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
|
||||
return 1 if @{$chainref->{rules}} && ( $config{OPTIMIZE} & OPTIMIZE_USE_FIRST );
|
||||
#
|
||||
# We must use the interfaces's chain if the interface is associated with multiple Zones
|
||||
#
|
||||
@@ -3177,6 +3176,8 @@ sub initialize_chain_table($) {
|
||||
new_builtin_chain 'nat', $chain, 'ACCEPT';
|
||||
}
|
||||
|
||||
new_builtin_chain 'nat', 'INPUT', 'ACCEPT' if have_capability('NAT_INPUT_CHAIN');
|
||||
|
||||
for my $chain ( qw(PREROUTING INPUT OUTPUT ) ) {
|
||||
new_builtin_chain 'mangle', $chain, 'ACCEPT';
|
||||
}
|
||||
@@ -3239,6 +3240,8 @@ sub initialize_chain_table($) {
|
||||
new_builtin_chain 'nat', $chain, 'ACCEPT';
|
||||
}
|
||||
|
||||
new_builtin_chain 'nat', 'INPUT', 'ACCEPT' if have_capability('NAT_INPUT_CHAIN');
|
||||
|
||||
for my $chain ( qw(PREROUTING INPUT OUTPUT FORWARD POSTROUTING ) ) {
|
||||
new_builtin_chain 'mangle', $chain, 'ACCEPT';
|
||||
}
|
||||
@@ -3264,7 +3267,7 @@ sub initialize_chain_table($) {
|
||||
$mangle_table->{POSTROUTING}{chainnumber} = POSTROUTING;
|
||||
}
|
||||
|
||||
if ( my $docker = $config{DOCKER} ) {
|
||||
if ( $config{DOCKER} ) {
|
||||
add_commands( $nat_table->{OUTPUT}, '[ -f ${VARDIR}/.nat_OUTPUT ] && cat ${VARDIR}/.nat_OUTPUT >&3' );
|
||||
add_commands( $nat_table->{POSTROUTING}, '[ -f ${VARDIR}/.nat_POSTROUTING ] && cat ${VARDIR}/.nat_POSTROUTING >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER' );
|
||||
@@ -3273,8 +3276,10 @@ sub initialize_chain_table($) {
|
||||
$chainref = new_nat_chain( 'DOCKER' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.nat_DOCKER ] && cat ${VARDIR}/.nat_DOCKER >&3' );
|
||||
$chainref = new_standard_chain( 'DOCKER-INGRESS' );
|
||||
$chainref = new_standard_chain( 'DOCKER-ISOLATION' );
|
||||
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-INGRESS ] && cat ${VARDIR}/.filter_DOCKER-INGRESS >&3' );
|
||||
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION >&3' );
|
||||
}
|
||||
|
||||
@@ -3372,15 +3377,43 @@ sub delete_references( $ ) {
|
||||
#
|
||||
# Calculate a digest for the passed chain and store it in the {digest} member.
|
||||
#
|
||||
# First, a lightweight version of format_rule()
|
||||
#
|
||||
sub irule_to_string( $ ) {
|
||||
my ( $ruleref ) = @_;
|
||||
|
||||
return $ruleref->{cmd} if exists $ruleref->{cmd};
|
||||
|
||||
my $string = '';
|
||||
|
||||
for ( grep ! ( get_opttype( $_, 0 ) & ( CONTROL | TARGET ) ), @{$ruleref->{matches}} ) {
|
||||
my $value = $ruleref->{$_};
|
||||
if ( reftype $value ) {
|
||||
$string .= "$_=" . join( ',', @$value ) . ' ';
|
||||
} else {
|
||||
$string .= "$_=$value ";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ruleref->{target} ) {
|
||||
$string .= join( ' ', " -$ruleref->{jump}", $ruleref->{target} );
|
||||
$string .= join( '', ' ', $ruleref->{targetopts} ) if $ruleref->{targetopts};
|
||||
}
|
||||
|
||||
$string .= join( '', ' -m comment --comment "', $ruleref->{comment}, '"' ) if $ruleref->{comment};
|
||||
|
||||
$string;
|
||||
}
|
||||
|
||||
sub calculate_digest( $ ) {
|
||||
my $chainref = shift;
|
||||
my $rules = '';
|
||||
|
||||
for ( @{$chainref->{rules}} ) {
|
||||
if ( $rules ) {
|
||||
$rules .= ' |' . format_rule( $chainref, $_, 1 );
|
||||
$rules .= ' |' . irule_to_string( $_ );
|
||||
} else {
|
||||
$rules = format_rule( $chainref, $_, 1 );
|
||||
$rules = irule_to_string( $_ );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3671,7 +3704,7 @@ sub optimize_level4( $$ ) {
|
||||
#
|
||||
delete_chain_and_references( $chainref );
|
||||
$progress = 1;
|
||||
} elsif ( $chainref->{builtin} || ! $globals{KLUDGEFREE} || $firstrule->{policy} ) {
|
||||
} elsif ( $chainref->{builtin} || ! $globals{KLUDGEFREE} ) {
|
||||
#
|
||||
# This case requires a new rule merging algorithm. Ignore this chain from
|
||||
# now on.
|
||||
@@ -3742,7 +3775,7 @@ sub optimize_level4( $$ ) {
|
||||
#
|
||||
# In this loop, we look for chains that end in an unconditional jump. The jump is replaced by
|
||||
# the target's rules, provided that the target chain is short (< 4 rules) or has only one
|
||||
# reference. This prevents multiple copies of long chains being created.
|
||||
# reference. This prevents multiple copies of long chains from being created.
|
||||
#
|
||||
$progress = 1;
|
||||
|
||||
@@ -3852,7 +3885,10 @@ sub optimize_level8( $$$ ) {
|
||||
%renamed = ();
|
||||
|
||||
while ( $progress ) {
|
||||
my @chains = ( sort { level8_compare($a, $b) } ( grep $_->{referenced} && ! $_->{builtin}, values %{$tableref} ) );
|
||||
my @chains = ( sort { level8_compare($a, $b) } ( grep $_->{referenced} &&
|
||||
@{$_->{rules}} &&
|
||||
! $_->{builtin},
|
||||
values %{$tableref} ) );
|
||||
my @chains1 = @chains;
|
||||
my $chains = @chains;
|
||||
my %rename;
|
||||
@@ -3872,12 +3908,11 @@ sub optimize_level8( $$$ ) {
|
||||
# Shift the current $chainref off of @chains1
|
||||
#
|
||||
shift @chains1;
|
||||
#
|
||||
# Skip empty chains
|
||||
#
|
||||
for my $chainref1 ( @chains1 ) {
|
||||
next unless @{$chainref1->{rules}};
|
||||
next if $chainref1->{optflags} & DONT_DELETE;
|
||||
|
||||
for my $chainref1 (grep ! ( $_->{optflags} & DONT_DELETE ), @chains1 ) {
|
||||
#
|
||||
# Chains identical?
|
||||
#
|
||||
if ( $chainref->{digest} eq $chainref1->{digest} ) {
|
||||
progress_message " Chain $chainref1->{name} combined with $chainref->{name}";
|
||||
$progress = 1;
|
||||
@@ -4307,7 +4342,7 @@ sub get_conntrack( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# Return an array of keys for the passed rule. 'conntrack', 'comment' & origin are omitted;
|
||||
# Return an array of keys for the passed rule. 'conntrack', 'comment' & 'origin' are omitted;
|
||||
#
|
||||
sub get_keys1( $ ) {
|
||||
my %skip = ( comment => 1, origin => 1 , 'conntrack --ctstate' => 1 );
|
||||
@@ -4778,6 +4813,7 @@ sub do_proto( $$$;$ )
|
||||
if ( $proto ne '' ) {
|
||||
|
||||
my $synonly = ( $proto =~ s/:(!)?syn$//i );
|
||||
my $all = ( $proto =~ s/:all$//i );
|
||||
my $notsyn = $1;
|
||||
my $invert = ( $proto =~ s/^!// ? '! ' : '' );
|
||||
my $protonum = resolve_proto $proto;
|
||||
@@ -4793,6 +4829,7 @@ sub do_proto( $$$;$ )
|
||||
# $proto now contains the protocol number and $pname contains the canonical name of the protocol
|
||||
#
|
||||
unless ( $synonly ) {
|
||||
fatal_error '":all" is only allowed with tcp' if $all && $proto != TCP;
|
||||
$output = "${invert}-p ${proto} ";
|
||||
} else {
|
||||
fatal_error '":syn" is only allowed with tcp' unless $proto == TCP && ! $invert;
|
||||
@@ -4932,6 +4969,8 @@ sub do_proto( $$$;$ )
|
||||
} else {
|
||||
fatal_error '":syn" is only allowed with tcp' if $synonly;
|
||||
|
||||
$proto = $proto . ':all' if $all;
|
||||
|
||||
if ( $proto =~ /^(ipp2p(:(tcp|udp|all))?)$/i ) {
|
||||
my $p = $2 ? lc $3 : 'tcp';
|
||||
require_capability( 'IPP2P_MATCH' , "PROTO = $proto" , 's' );
|
||||
@@ -4988,6 +5027,7 @@ sub do_iproto( $$$ )
|
||||
if ( $proto ne '' ) {
|
||||
|
||||
my $synonly = ( $proto =~ s/:syn$//i );
|
||||
my $all = ( $proto =~ s/:all$//i );
|
||||
my $invert = ( $proto =~ s/^!// ? '! ' : '' );
|
||||
my $protonum = resolve_proto $proto;
|
||||
|
||||
@@ -5002,6 +5042,7 @@ sub do_iproto( $$$ )
|
||||
# $proto now contains the protocol number and $pname contains the canonical name of the protocol
|
||||
#
|
||||
unless ( $synonly ) {
|
||||
fatal_error '":all" is only allowed with tcp' if $all && $proto != TCP;
|
||||
@output = ( p => "${invert}${proto}" );
|
||||
} else {
|
||||
fatal_error '":syn" is only allowed with tcp' unless $proto == TCP && ! $invert;
|
||||
@@ -5136,6 +5177,8 @@ sub do_iproto( $$$ )
|
||||
} else {
|
||||
fatal_error '":syn" is only allowed with tcp' if $synonly;
|
||||
|
||||
$proto = $proto . ':all' if $all;
|
||||
|
||||
if ( $proto =~ /^(ipp2p(:(tcp|udp|all))?)$/i ) {
|
||||
my $p = $2 ? lc $3 : 'tcp';
|
||||
require_capability( 'IPP2P_MATCH' , "PROTO = $proto" , 's' );
|
||||
@@ -7065,6 +7108,8 @@ sub interface_gateway( $ ) {
|
||||
sub get_interface_gateway ( $;$$ ) {
|
||||
my ( $logical, $protect, $provider ) = @_;
|
||||
|
||||
$provider = '' unless defined $provider;
|
||||
|
||||
my $interface = get_physical $logical;
|
||||
my $variable = interface_gateway( $interface );
|
||||
my $gateway = get_interface_option( $interface, 'gateway' );
|
||||
@@ -7078,9 +7123,9 @@ sub get_interface_gateway ( $;$$ ) {
|
||||
}
|
||||
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface));
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider));
|
||||
} else {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface)
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider)
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
|
||||
}
|
||||
|
||||
@@ -8184,19 +8229,8 @@ sub add_interface_options( $ ) {
|
||||
# Generate a digest for each chain
|
||||
#
|
||||
for my $chainref ( values %input_chains, values %forward_chains ) {
|
||||
my $digest = '';
|
||||
|
||||
assert( $chainref );
|
||||
|
||||
for ( @{$chainref->{rules}} ) {
|
||||
if ( $digest ) {
|
||||
$digest .= ' |' . format_rule( $chainref, $_, 1 );
|
||||
} else {
|
||||
$digest = format_rule( $chainref, $_, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
$chainref->{digest} = sha1_hex $digest;
|
||||
calculate_digest( $chainref );
|
||||
}
|
||||
#
|
||||
# Insert jumps to the interface chains into the rules chains
|
||||
@@ -8457,6 +8491,7 @@ sub save_docker_rules($) {
|
||||
qq( $tool -t nat -S OUTPUT | tail -n +2 | fgrep DOCKER > \${VARDIR}/.nat_OUTPUT),
|
||||
qq( $tool -t nat -S POSTROUTING | tail -n +2 | fgrep -v SHOREWALL > \${VARDIR}/.nat_POSTROUTING),
|
||||
qq( $tool -t filter -S DOCKER | tail -n +2 > \${VARDIR}/.filter_DOCKER),
|
||||
qq( [ -n "\$g_dockeringress" ] && $tool -t filter -S DOCKER-INGRESS | tail -n +2 > \${VARDIR}/.filter_DOCKER-INGRESS),
|
||||
qq( [ -n "\$g_dockernetwork" ] && $tool -t filter -S DOCKER-ISOLATION | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION)
|
||||
);
|
||||
|
||||
@@ -8472,6 +8507,7 @@ sub save_docker_rules($) {
|
||||
q( rm -f ${VARDIR}/.nat_OUTPUT),
|
||||
q( rm -f ${VARDIR}/.nat_POSTROUTING),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-INGRESS),
|
||||
q( rm -f ${VARDIR}/.filter_DOCKER-ISOLATION),
|
||||
q( rm -f ${VARDIR}/.filter_FORWARD),
|
||||
q(fi)
|
||||
@@ -8492,7 +8528,7 @@ sub save_dynamic_chains() {
|
||||
);
|
||||
|
||||
if ( have_capability 'IPTABLES_S' ) {
|
||||
emit <<"EOF";
|
||||
emithd <<"EOF";
|
||||
if chain_exists 'UPnP -t nat'; then
|
||||
$tool -t nat -S UPnP | tail -n +2 > \${VARDIR}/.UPnP
|
||||
else
|
||||
@@ -8513,6 +8549,7 @@ fi
|
||||
EOF
|
||||
if ( $config{MINIUPNPD} ) {
|
||||
emit << "EOF";
|
||||
|
||||
if chain_exists 'MINIUPNPD-POSTROUTING -t nat'; then
|
||||
$tool -t nat -S MINIUPNPD-POSTROUTING | tail -n +2 > \${VARDIR}/.MINIUPNPD-POSTROUTING
|
||||
else
|
||||
@@ -8521,7 +8558,7 @@ fi
|
||||
EOF
|
||||
}
|
||||
} else {
|
||||
emit <<"EOF";
|
||||
emithd <<"EOF";
|
||||
if chain_exists 'UPnP -t nat'; then
|
||||
$utility -t nat | grep '^-A UPnP ' > \${VARDIR}/.UPnP
|
||||
else
|
||||
@@ -8541,7 +8578,8 @@ else
|
||||
fi
|
||||
EOF
|
||||
if ( $config{MINIUPNPD} ) {
|
||||
emit << "EOF";
|
||||
emithd << "EOF";
|
||||
|
||||
if chain_exists 'MINIUPNPD-POSTROUTING -t nat'; then
|
||||
$utility -t nat | grep '^-A MINIUPNPD-POSTROUTING' > \${VARDIR}/.MINIUPNPD-POSTROUTING
|
||||
else
|
||||
@@ -8555,7 +8593,7 @@ EOF
|
||||
emit ( 'else' );
|
||||
push_indent;
|
||||
|
||||
emit <<"EOF";
|
||||
emithd <<"EOF";
|
||||
rm -f \${VARDIR}/.UPnP
|
||||
rm -f \${VARDIR}/.forwardUPnP
|
||||
EOF
|
||||
@@ -8592,7 +8630,7 @@ sub ensure_ipsets( @ ) {
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit( qq( fi\n) );
|
||||
emit( q( fi) );
|
||||
|
||||
}
|
||||
|
||||
@@ -8768,7 +8806,6 @@ sub create_load_ipsets() {
|
||||
' $IPSET flush $set' ,
|
||||
' $IPSET destroy $set' ,
|
||||
" done" ,
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
#
|
||||
@@ -8780,7 +8817,7 @@ sub create_load_ipsets() {
|
||||
' fi' );
|
||||
};
|
||||
|
||||
emit( '}' );
|
||||
emit( "}\n" );
|
||||
}
|
||||
#
|
||||
# Now generate load_ipsets()
|
||||
@@ -8849,20 +8886,17 @@ sub create_load_ipsets() {
|
||||
ensure_ipsets( @ipsets );
|
||||
|
||||
emit( 'elif [ "$COMMAND" = refresh ]; then' ); ################### Refresh Command ###################
|
||||
emit ( '' );
|
||||
ensure_ipsets( @ipsets );
|
||||
emit ( '' );
|
||||
};
|
||||
|
||||
emit ( 'fi' ,
|
||||
'' );
|
||||
emit ( 'fi' );
|
||||
} else {
|
||||
emit 'true';
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit '}';
|
||||
emit "}\n";
|
||||
}
|
||||
|
||||
#
|
||||
@@ -8983,6 +9017,10 @@ sub create_netfilter_load( $ ) {
|
||||
enter_cmd_mode;
|
||||
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode;
|
||||
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} else {
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
@@ -9031,7 +9069,7 @@ sub create_netfilter_load( $ ) {
|
||||
"cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux",
|
||||
'if [ $? != 0 ]; then',
|
||||
qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"),
|
||||
"fi\n"
|
||||
'fi'
|
||||
);
|
||||
|
||||
pop_indent;
|
||||
@@ -9087,6 +9125,11 @@ sub preview_netfilter_load() {
|
||||
print( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
print "\n";
|
||||
enter_cat_mode1;
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
print( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
print "\n";
|
||||
enter_cat_mode1;
|
||||
} else {
|
||||
enter_cmd_mode1 unless $mode == CMD_MODE;
|
||||
print( ":$name - [0:0]\n" );
|
||||
@@ -9324,6 +9367,10 @@ sub create_stop_load( $ ) {
|
||||
enter_cmd_mode;
|
||||
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} elsif ( $name eq 'DOCKER-INGRESS' ) {
|
||||
enter_cmd_mode;
|
||||
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
|
||||
enter_cat_mode;
|
||||
} else {
|
||||
emit_unindented ":$name - [0:0]";
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -59,7 +59,7 @@ our $have_arptables;
|
||||
# Initilize the package-globals in the other modules
|
||||
#
|
||||
sub initialize_package_globals( $$$ ) {
|
||||
Shorewall::Config::initialize($family, $_[1], $_[2]);
|
||||
Shorewall::Config::initialize($family, $export, $_[1], $_[2]);
|
||||
Shorewall::Chains::initialize ($family, 1, $export );
|
||||
Shorewall::Zones::initialize ($family, $_[0]);
|
||||
Shorewall::Nat::initialize($family);
|
||||
@@ -103,7 +103,7 @@ sub generate_script_1( $ ) {
|
||||
|
||||
copy2( $lib, $debug ) if -f $lib;
|
||||
|
||||
emit <<'EOF';
|
||||
emithd<<'EOF';
|
||||
################################################################################
|
||||
# Functions to execute the various user exits (extension scripts)
|
||||
################################################################################
|
||||
@@ -125,7 +125,7 @@ EOF
|
||||
emit '}';
|
||||
}
|
||||
|
||||
emit <<'EOF';
|
||||
emithd <<'EOF';
|
||||
################################################################################
|
||||
# End user exit functions
|
||||
################################################################################
|
||||
@@ -268,13 +268,13 @@ sub generate_script_2() {
|
||||
emit( '',
|
||||
'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes',
|
||||
);
|
||||
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes]' );
|
||||
emit( '' );
|
||||
emit( 'chain_exists DOCKER-INGRESS && g_dockeringress=Yes' );
|
||||
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes' );
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "\n}\n"; # End of initialize()
|
||||
emit "}\n"; # End of initialize()
|
||||
|
||||
emit( '' ,
|
||||
'#' ,
|
||||
@@ -311,10 +311,9 @@ sub generate_script_2() {
|
||||
push_indent;
|
||||
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
|
||||
verify_required_interfaces(0);
|
||||
set_global_variables(0, 0);
|
||||
|
||||
handle_optional_interfaces(0);
|
||||
handle_optional_interfaces;
|
||||
}
|
||||
|
||||
emit ';;';
|
||||
@@ -326,19 +325,19 @@ sub generate_script_2() {
|
||||
push_indent;
|
||||
}
|
||||
|
||||
verify_required_interfaces(1);
|
||||
set_global_variables(1,1);
|
||||
handle_optional_interfaces;
|
||||
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
handle_optional_interfaces(1);
|
||||
emit ';;';
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
emit ( 'esac' );
|
||||
} else {
|
||||
handle_optional_interfaces(1);
|
||||
}
|
||||
} else {
|
||||
emit( 'true' ) unless handle_optional_interfaces(1);
|
||||
verify_required_interfaces(1);
|
||||
emit( 'true' ) unless handle_optional_interfaces;
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
@@ -525,7 +524,7 @@ sub generate_script_3($) {
|
||||
|
||||
my $config_dir = $globals{CONFIGDIR};
|
||||
|
||||
emit<<"EOF";
|
||||
emithd <<"EOF";
|
||||
set_state Started $config_dir
|
||||
run_restored_exit
|
||||
elif [ \$COMMAND = refresh ]; then
|
||||
@@ -572,7 +571,7 @@ EOF
|
||||
' run_started_exit',
|
||||
"fi\n" );
|
||||
|
||||
emit<<'EOF';
|
||||
emithd<<'EOF';
|
||||
date > ${VARDIR}/restarted
|
||||
|
||||
case $COMMAND in
|
||||
@@ -691,6 +690,7 @@ sub compiler {
|
||||
set_timestamp( $timestamp );
|
||||
set_debug( $debug , $confess );
|
||||
#
|
||||
# S H O R E W A L L R C ,
|
||||
# S H O R E W A L L . C O N F A N D C A P A B I L I T I E S
|
||||
#
|
||||
get_configuration( $export , $update , $annotate , $inline );
|
||||
@@ -795,13 +795,10 @@ sub compiler {
|
||||
emit '}'; # End of setup_common_rules()
|
||||
}
|
||||
|
||||
disable_script;
|
||||
#
|
||||
# R O U T I N G _ A N D _ T R A F F I C _ S H A P I N G
|
||||
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
|
||||
#
|
||||
enable_script;
|
||||
#
|
||||
# Validate the TC files so that the providers will know what interfaces have TC
|
||||
#
|
||||
my $tcinterfaces = process_tc;
|
||||
@@ -900,7 +897,7 @@ sub compiler {
|
||||
|
||||
optimize_level0;
|
||||
|
||||
if ( ( my $optimize = $config{OPTIMIZE} ) & 0x1E ) {
|
||||
if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) {
|
||||
progress_message2 'Optimizing Ruleset...';
|
||||
#
|
||||
# Optimize Policy Chains
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Config.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Config.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -30,17 +30,97 @@
|
||||
# into those files (emitters) and finalizing those files (renaming
|
||||
# them to their final name and setting their mode appropriately).
|
||||
#
|
||||
# A significant portion of this module is dedicated to the preprocessor:
|
||||
#
|
||||
# process_compiler_directive() - processes compiler directives
|
||||
#
|
||||
# embedded_shell() - handles embedded shell scripting
|
||||
#
|
||||
# embedded_perl() - handles embedded perl scripting
|
||||
#
|
||||
# read_a_line() - Reads the next configuration file record to
|
||||
# be passed to the function processing the file.
|
||||
#
|
||||
# - Detects compiler directives and passes then to
|
||||
# process_compiler_directive() for handling.
|
||||
#
|
||||
# - Handles line continuation
|
||||
#
|
||||
# - Invokes a callback when the first (concatinated) non-directive
|
||||
# record is read from a file.
|
||||
#
|
||||
# - Conditionally expands variables.
|
||||
#
|
||||
# - Conditionally detects embedded Shell and Perl and passes them
|
||||
# off to embedded_shell() and embedded_perl() respectively.
|
||||
#
|
||||
# - Conditionally detects and handles [?}INCLUDE directives.
|
||||
#
|
||||
# - Conditionally detects and handles ?SECTION directives.
|
||||
# File processing functions can supply a callback to be
|
||||
# called during this processing.
|
||||
#
|
||||
# File processing routines may need to open a second (third, fourth, ...)
|
||||
# file while processing the main file (macro and/or action files). Two
|
||||
# functions are provided to make that possible:
|
||||
#
|
||||
# push_open() - open a file while leaving the current file open.
|
||||
#
|
||||
# pop_open() - close the current file, and make the previous
|
||||
# file (if any) the current one.
|
||||
#
|
||||
# Because this module expands variables, it must be aware of action
|
||||
# parameters.
|
||||
#
|
||||
# push_action_params() - populates the %actparams hash and
|
||||
# returns a reference to the previous
|
||||
# contents of that hash. The caller is
|
||||
# expected to store those contents locally.
|
||||
#
|
||||
# pop_action_params() - Restores the %actparams hash from
|
||||
# the reference returned by
|
||||
# push_action_params().
|
||||
#
|
||||
# The following routines are provided for INLINE PERL within
|
||||
# action bodies:
|
||||
#
|
||||
# default_action_params() - called to fill in omitted
|
||||
# arguments when a DEFAULTS
|
||||
# line is encountered.
|
||||
#
|
||||
# get_action_params() - returns an array of arguments.
|
||||
#
|
||||
# setup_audit_action() - helper for A_* actions.
|
||||
#
|
||||
# get_action_logging() - returns log level and tag
|
||||
# from the action's invocation.
|
||||
#
|
||||
# get_action_chain_name() - returns chain name.
|
||||
#
|
||||
# set_action_name_to_caller() - replace chain name
|
||||
# with that of invoking
|
||||
# chain for logging purposes.
|
||||
#
|
||||
# set_action_disposition() - set the current action
|
||||
# disposition for logging purposes.
|
||||
#
|
||||
# get_action_disposition() - get the current action disposition.
|
||||
#
|
||||
# set_action_param() - set the value of an argument.
|
||||
#
|
||||
package Shorewall::Config;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
use File::Temp qw/ tempfile tempdir /;
|
||||
use File::Glob ':globally';
|
||||
use Cwd qw(abs_path getcwd);
|
||||
use autouse 'Carp' => qw(longmess confess);
|
||||
use Scalar::Util 'reftype';
|
||||
use FindBin;
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
use Errno qw(:POSIX);
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
#
|
||||
@@ -109,6 +189,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
in_hex8
|
||||
in_hexp
|
||||
emit
|
||||
emithd
|
||||
emitstd
|
||||
emit_unindented
|
||||
save_progress_message
|
||||
@@ -222,10 +303,10 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
DO_SECTION
|
||||
NORMAL_READ
|
||||
|
||||
OPTIMIZE_MASK
|
||||
OPTIMIZE_POLICY_MASK
|
||||
OPTIMIZE_POLICY_MASK2n4
|
||||
OPTIMIZE_RULESET_MASK
|
||||
OPTIMIZE_USE_FIRST
|
||||
OPTIMIZE_ALL
|
||||
) , ] ,
|
||||
protocols => [ qw (
|
||||
@@ -315,7 +396,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
|
||||
#
|
||||
# Config options and global settings that are to be copied to output script
|
||||
#
|
||||
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
|
||||
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
|
||||
#
|
||||
# From parsing the capabilities file or detecting capabilities
|
||||
#
|
||||
@@ -416,6 +497,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
NFLOG_SIZE => '--nflog-size support',
|
||||
RESTORE_WAIT_OPTION
|
||||
=> 'iptables-restore --wait option',
|
||||
NAT_INPUT_CHAIN => 'INPUT chain in NAT table',
|
||||
AMANDA_HELPER => 'Amanda Helper',
|
||||
FTP_HELPER => 'FTP Helper',
|
||||
FTP0_HELPER => 'FTP-0 Helper',
|
||||
@@ -463,9 +545,8 @@ use constant {
|
||||
OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains()
|
||||
OPTIMIZE_POLICY_MASK2n4 => 0x06 ,
|
||||
OPTIMIZE_RULESET_MASK => 0x1C , # Call optimize_ruleset()
|
||||
OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1
|
||||
OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories.
|
||||
|
||||
OPTIMIZE_USE_FIRST => 0x1000 # Always use interface 'first' chains -- undocumented
|
||||
};
|
||||
|
||||
our %helpers = ( amanda => UDP,
|
||||
@@ -595,6 +676,7 @@ our $debug; # Global debugging flag
|
||||
our $confess; # If true, use Carp to report errors with stack trace.
|
||||
|
||||
our $family; # Protocol family (4 or 6)
|
||||
our $export; # True when compiling for export
|
||||
our $toolname; # Name of the tool to use (iptables or iptables6)
|
||||
our $toolNAME; # Tool name in CAPS
|
||||
our $product; # Name of product that will run the generated script
|
||||
@@ -627,8 +709,8 @@ our %validlevels; # Valid log levels.
|
||||
#
|
||||
# Deprecated options with their default values
|
||||
#
|
||||
our %deprecated = (
|
||||
LEGACY_RESTART => 'no'
|
||||
our %deprecated = ( LEGACY_RESTART => 'no' ,
|
||||
INLINE_MATCHES => 'no' ,
|
||||
);
|
||||
#
|
||||
# Deprecated options that are eliminated via update
|
||||
@@ -648,6 +730,7 @@ our %eliminated = ( LOGRATE => 1,
|
||||
HIGH_ROUTE_MARKS => 1,
|
||||
BLACKLISTNEWONLY => 1,
|
||||
CHAIN_SCRIPTS => 1,
|
||||
MODULE_SUFFIX => 1,
|
||||
);
|
||||
#
|
||||
# Variables involved in ?IF, ?ELSE ?ENDIF processing
|
||||
@@ -707,8 +790,8 @@ sub add_variables( \% );
|
||||
# 2. The compiler can run multiple times in the same process so it has to be
|
||||
# able to re-initialize its dependent modules' state.
|
||||
#
|
||||
sub initialize( $;$$) {
|
||||
( $family, my ( $shorewallrc, $shorewallrc1 ) ) = @_;
|
||||
sub initialize( $;$$$) {
|
||||
( $family, $export, my ( $shorewallrc, $shorewallrc1 ) ) = @_;
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
( $product, $Product, $toolname, $toolNAME ) = qw( shorewall Shorewall iptables IPTABLES );
|
||||
@@ -752,8 +835,8 @@ sub initialize( $;$$) {
|
||||
TC_SCRIPT => '',
|
||||
EXPORT => 0,
|
||||
KLUDGEFREE => '',
|
||||
VERSION => "5.1.5-RC1",
|
||||
CAPVERSION => 50106 ,
|
||||
VERSION => "5.1.12",
|
||||
CAPVERSION => 50112 ,
|
||||
BLACKLIST_LOG_TAG => '',
|
||||
RELATED_LOG_TAG => '',
|
||||
MACLIST_LOG_TAG => '',
|
||||
@@ -848,7 +931,6 @@ sub initialize( $;$$) {
|
||||
BLACKLIST => undef,
|
||||
BLACKLISTNEWONLY => undef,
|
||||
DELAYBLACKLISTLOAD => undef,
|
||||
MODULE_SUFFIX => undef,
|
||||
DISABLE_IPV6 => undef,
|
||||
DYNAMIC_ZONES => undef,
|
||||
PKTTYPE=> undef,
|
||||
@@ -1008,7 +1090,7 @@ sub initialize( $;$$) {
|
||||
CONNLIMIT_MATCH => undef,
|
||||
TIME_MATCH => undef,
|
||||
GOTO_TARGET => undef,
|
||||
LOG_TARGET => 1, # Assume that we have it.
|
||||
LOG_TARGET => undef,
|
||||
ULOG_TARGET => undef,
|
||||
NFLOG_TARGET => undef,
|
||||
LOGMARK_TARGET => undef,
|
||||
@@ -1048,6 +1130,7 @@ sub initialize( $;$$) {
|
||||
NETMAP_TARGET => undef,
|
||||
NFLOG_SIZE => undef,
|
||||
RESTORE_WAIT_OPTION => undef,
|
||||
NAT_INPUT_CHAIN => undef,
|
||||
|
||||
AMANDA_HELPER => undef,
|
||||
FTP_HELPER => undef,
|
||||
@@ -1607,6 +1690,7 @@ sub emit {
|
||||
$line =~ s/^\n// if $lastlineblank;
|
||||
$line =~ s/^/$indent/gm if $indent;
|
||||
$line =~ s/ /\t/gm;
|
||||
$line =~ s/[ \t]+\n/\n/gm;
|
||||
print $script "$line\n" if $script;
|
||||
$lastlineblank = ( substr( $line, -1, 1 ) eq "\n" );
|
||||
|
||||
@@ -1627,6 +1711,15 @@ sub emit {
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Used to emit a 'here documents' string without introducing an unwanted blank line at the end
|
||||
#
|
||||
sub emithd( $ ) {
|
||||
my ( $line ) = @_; #make writable
|
||||
chomp $line;
|
||||
emit $line;
|
||||
}
|
||||
|
||||
#
|
||||
# Version of emit() that writes to standard out unconditionally
|
||||
#
|
||||
@@ -1637,6 +1730,7 @@ sub emitstd {
|
||||
$line =~ s/^\n// if $lastlineblank;
|
||||
$line =~ s/^/$indent/gm if $indent;
|
||||
$line =~ s/ /\t/gm;
|
||||
$line =~ s/[ \t]+\n/\n/gm;
|
||||
print "$line\n";
|
||||
$lastlineblank = ( substr( $line, -1, 1 ) eq "\n" );
|
||||
} else {
|
||||
@@ -1992,6 +2086,7 @@ sub find_file($)
|
||||
for my $directory ( @config_path ) {
|
||||
my $file = "$directory$filename";
|
||||
return $file if -f $file;
|
||||
$!{ENOENT} || fatal_error "Unable to access $file: " . $!;
|
||||
}
|
||||
|
||||
"$config_path[0]$filename";
|
||||
@@ -2322,6 +2417,10 @@ sub split_line2( $$;$$$ ) {
|
||||
fatal_error "Only one set of double semicolons (';;') allowed on a line" if defined $rest;
|
||||
|
||||
$currline = $columns;
|
||||
#
|
||||
# Remove trailing white space
|
||||
#
|
||||
$currline =~ s/\s*$//;
|
||||
|
||||
$inline_matches = $pairs;
|
||||
#
|
||||
@@ -2344,6 +2443,8 @@ sub split_line2( $$;$$$ ) {
|
||||
if ( $inlinematches ) {
|
||||
fatal_error "The $description does not support inline matches (INLINE_MATCHES=Yes)" unless $inline;
|
||||
|
||||
warning_message "This entry needs to be changed (replace ';' with ';;') before the INLINE_MATCHES option is removed in Shorewall 5.2";
|
||||
|
||||
$inline_matches = $pairs;
|
||||
|
||||
if ( $columns =~ /^(\s*|.*[^&@%])\{(.*)\}\s*$/ ) {
|
||||
@@ -2362,6 +2463,8 @@ sub split_line2( $$;$$$ ) {
|
||||
if ( $currline =~ /^\s*INLINE(?:\(.*\)(:.*)?|:.*)?\s/ || $currline =~ /^\s*IP6?TABLES(?:\(.*\)|:.*)?\s/ ) {
|
||||
$inline_matches = $pairs;
|
||||
|
||||
warning_message "This entry needs to be changed before Shorewall 5.2 (replace ';' with ';;'). '$globals{PRODUCT} update' will do that for you";
|
||||
|
||||
if ( $columns =~ /^(\s*|.*[^&@%])\{(.*)\}\s*$/ ) {
|
||||
#
|
||||
# Pairs are enclosed in curly brackets.
|
||||
@@ -2574,7 +2677,7 @@ sub open_file( $;$$$$ ) {
|
||||
$max_format = supplied $mf ? $mf : 1;
|
||||
$comments_allowed = supplied $ca ? $ca : 0;
|
||||
$nocomment = $nc;
|
||||
do_open_file $fname;;
|
||||
do_open_file $fname;
|
||||
} else {
|
||||
$ifstack = @ifstack;
|
||||
'';
|
||||
@@ -4287,7 +4390,7 @@ sub which( $ ) {
|
||||
# Load the kernel modules defined in the 'modules' file.
|
||||
#
|
||||
sub load_kernel_modules( ) {
|
||||
my $moduleloader = which( 'modprobe' ) || ( which 'insmod' );
|
||||
my $moduleloader = which( 'modprobe' ) || which( 'insmod' );
|
||||
|
||||
my $modulesdir = $config{MODULESDIR};
|
||||
|
||||
@@ -4320,25 +4423,20 @@ sub load_kernel_modules( ) {
|
||||
|
||||
close LSMOD;
|
||||
|
||||
$config{MODULE_SUFFIX} = 'ko ko.gz ko.xz o o.gz o.xz gz xz' unless $config{MODULE_SUFFIX};
|
||||
|
||||
my @suffixes = split /\s+/ , $config{MODULE_SUFFIX};
|
||||
|
||||
MODULE:
|
||||
while ( read_a_line( NORMAL_READ ) ) {
|
||||
fatal_error "Invalid modules file entry" unless ( $currentline =~ /^loadmodule\s+([a-zA-Z]\w*)\s*(.*)$/ );
|
||||
my ( $module, $arguments ) = ( $1, $2 );
|
||||
unless ( $loadedmodules{ $module } ) {
|
||||
for my $directory ( @moduledirectories ) {
|
||||
for my $suffix ( @suffixes ) {
|
||||
my $modulefile = "$directory/$module.$suffix";
|
||||
if ( -f $modulefile ) {
|
||||
if ( $moduleloader eq 'insmod' ) {
|
||||
system ("insmod $modulefile $arguments" );
|
||||
} else {
|
||||
system( "modprobe $module $arguments" );
|
||||
}
|
||||
|
||||
if ( $moduleloader =~ /modprobe$/ ) {
|
||||
system( "modprobe -q $module $arguments" );
|
||||
$loadedmodules{ $module } = 1;
|
||||
} else {
|
||||
for my $directory ( @moduledirectories ) {
|
||||
for my $modulefile ( <$directory/$module.*> ) {
|
||||
system ("insmod $modulefile $arguments" );
|
||||
$loadedmodules{ $module } = 1;
|
||||
next MODULE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4369,6 +4467,12 @@ sub Nat_Enabled() {
|
||||
qt1( "$iptables $iptablesw -t nat -L -n" );
|
||||
}
|
||||
|
||||
sub Nat_Input_Chain {
|
||||
have_capability( 'NAT_ENABLED' ) || return '';
|
||||
|
||||
qt1( "$iptables $iptablesw -t nat -L INPUT -n" );
|
||||
}
|
||||
|
||||
sub Persistent_Snat() {
|
||||
have_capability( 'NAT_ENABLED' ) || return '';
|
||||
|
||||
@@ -5014,6 +5118,7 @@ our %detect_capability =
|
||||
MASQUERADE_TGT => \&Masquerade_Tgt,
|
||||
MULTIPORT => \&Multiport,
|
||||
NAT_ENABLED => \&Nat_Enabled,
|
||||
NAT_INPUT_CHAIN => \&Nat_Input_Chain,
|
||||
NETBIOS_NS_HELPER => \&Netbios_ns_Helper,
|
||||
NETMAP_TARGET => \&Netmap_Target,
|
||||
NEW_CONNTRACK_MATCH => \&New_Conntrack_Match,
|
||||
@@ -5113,6 +5218,7 @@ sub determine_capabilities() {
|
||||
#
|
||||
$capabilities{NAT_ENABLED} = detect_capability( 'NAT_ENABLED' );
|
||||
$capabilities{PERSISTENT_SNAT} = detect_capability( 'PERSISTENT_SNAT' );
|
||||
$capabilities{NAT_INPUT_CHAIN} = detect_capability( 'NAT_INPUT_CHAIN' );
|
||||
$capabilities{MANGLE_ENABLED} = detect_capability( 'MANGLE_ENABLED' );
|
||||
|
||||
if ( $capabilities{CONNTRACK_MATCH} = detect_capability( 'CONNTRACK_MATCH' ) ) {
|
||||
@@ -5252,7 +5358,13 @@ sub ensure_config_path() {
|
||||
fatal_error "CONFIG_PATH not found in $f" unless $config{CONFIG_PATH};
|
||||
}
|
||||
|
||||
@config_path = split /:/, $config{CONFIG_PATH};
|
||||
my $path = $config{CONFIG_PATH};
|
||||
|
||||
my $chop = ( $path =~ s/^:// );
|
||||
|
||||
@config_path = split /:/, $path;
|
||||
|
||||
shift @config_path if $chop && ( $export || $> != 0 );
|
||||
|
||||
#
|
||||
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
|
||||
@@ -5922,6 +6034,8 @@ sub export_params() {
|
||||
|
||||
#
|
||||
# Walk the CONFIG_PATH converting FORMAT and COMMENT lines to compiler directives
|
||||
# Convert single semicolons to double semicolons in lines beginning with 'INLINE',
|
||||
# IPTABLES or IP6TABLES
|
||||
#
|
||||
sub convert_to_directives() {
|
||||
my $sharedir = $shorewallrc{SHAREDIR};
|
||||
@@ -5934,7 +6048,7 @@ sub convert_to_directives() {
|
||||
|
||||
my $dirtest = qr|^$sharedir/+shorewall6?(?:/.*)?$|;
|
||||
|
||||
progress_message3 "Converting 'FORMAT', 'SECTION' and 'COMMENT' lines to compiler directives...";
|
||||
progress_message3 "Converting 'FORMAT', 'SECTION' and 'COMMENT' lines to compiler directives and replacing single semicolons in INLINE, IPTABLES and IP6TABLES rules...";
|
||||
|
||||
for my $dir ( @path ) {
|
||||
unless ( $dir =~ /$dirtest/ ) {
|
||||
@@ -5963,6 +6077,9 @@ sub convert_to_directives() {
|
||||
s/COMMENT/?COMMENT/;
|
||||
} elsif ( /^\\s*COMMENT\\s*\$/ ) {
|
||||
s/COMMENT/?COMMENT/;
|
||||
}
|
||||
if ( /^\\s*(?:INLINE|IP6?TABLES)/ ) {
|
||||
s/;/;;/ unless /;;/;
|
||||
}' $file
|
||||
EOF
|
||||
if ( $result == 0 ) {
|
||||
@@ -6255,7 +6372,7 @@ sub get_configuration( $$$$ ) {
|
||||
$config{LOG_VERBOSITY} = -1;
|
||||
}
|
||||
|
||||
default_yes_no 'ADD_IP_ALIASES' , 'Yes';
|
||||
default_yes_no 'ADD_IP_ALIASES' , $family == F_IPV4 ? 'Yes' : '';
|
||||
default_yes_no 'ADD_SNAT_ALIASES' , '';
|
||||
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
||||
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
||||
@@ -6408,7 +6525,7 @@ sub get_configuration( $$$$ ) {
|
||||
default_yes_no 'USE_DEFAULT_RT' , '';
|
||||
default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes';
|
||||
default_yes_no 'AUTOMAKE' , '';
|
||||
default_yes_no 'TRACK_PROVIDERS' , '';
|
||||
default_yes_no 'TRACK_PROVIDERS' , 'Yes';
|
||||
default_yes_no 'BALANCE_PROVIDERS' , $config{USE_DEFAULT_RT} ? 'Yes' : '';
|
||||
default_yes_no 'USE_NFLOG_SIZE' , '';
|
||||
|
||||
@@ -6784,7 +6901,7 @@ sub get_configuration( $$$$ ) {
|
||||
} else {
|
||||
$val = numeric_value $config{OPTIMIZE};
|
||||
|
||||
fatal_error "Invalid OPTIMIZE value ($config{OPTIMIZE})" unless supplied( $val ) && $val >= 0 && ( $val & ~OPTIMIZE_USE_FIRST ) <= OPTIMIZE_ALL;
|
||||
fatal_error "Invalid OPTIMIZE value ($config{OPTIMIZE})" unless supplied( $val ) && $val >= 0 && $val <= OPTIMIZE_ALL;
|
||||
}
|
||||
|
||||
require_capability 'XMULTIPORT', 'OPTIMIZE level 16', 's' if $val & 16;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/IPAddrs.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/IPAddrs.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Misc.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Misc.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -667,6 +667,7 @@ sub create_docker_rules() {
|
||||
|
||||
my $chainref = $filter_table->{FORWARD};
|
||||
|
||||
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
|
||||
add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', );
|
||||
|
||||
if ( my $dockerref = known_interface('docker0') ) {
|
||||
@@ -717,7 +718,7 @@ sub add_common_rules ( $ ) {
|
||||
|
||||
if ( $config{REJECT_ACTION} ) {
|
||||
process_reject_action;
|
||||
fatal_eror( "The REJECT_ACTION ($config{REJECT_ACTION}) is not terminating" ) unless terminating( $rejectref );
|
||||
fatal_error( "The REJECT_ACTION ($config{REJECT_ACTION}) is not terminating" ) unless terminating( $rejectref );
|
||||
} else {
|
||||
if ( have_capability( 'ADDRTYPE' ) ) {
|
||||
add_ijump $rejectref , j => 'DROP' , addrtype => '--src-type BROADCAST';
|
||||
@@ -2447,7 +2448,7 @@ sub setup_mss( ) {
|
||||
my $clampmss = $config{CLAMPMSS};
|
||||
my $option;
|
||||
my @match;
|
||||
my $chainref = $filter_table->{FORWARD};
|
||||
my $chainref = $mangle_table->{FORWARD};
|
||||
|
||||
if ( $clampmss ) {
|
||||
if ( "\L$clampmss" eq 'yes' ) {
|
||||
@@ -2645,7 +2646,6 @@ EOF
|
||||
|
||||
rm -f ${VARDIR}/proxyarp
|
||||
fi
|
||||
|
||||
EOF
|
||||
} else {
|
||||
emit <<'EOF';
|
||||
@@ -2659,7 +2659,6 @@ EOF
|
||||
|
||||
rm -f ${VARDIR}/proxyndp
|
||||
fi
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Nat.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Nat.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Providers.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Providers.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -125,7 +125,7 @@ sub initialize( $ ) {
|
||||
# Set up marking for 'tracked' interfaces.
|
||||
#
|
||||
sub setup_route_marking() {
|
||||
my $mask = in_hex( $globals{PROVIDER_MASK} );
|
||||
my $mask = in_hex( $globals{PROVIDER_MASK} );
|
||||
my $exmask = have_capability( 'EXMARK' ) ? "/$mask" : '';
|
||||
|
||||
require_capability( $_ , q(The provider 'track' option) , 's' ) for qw/CONNMARK_MATCH CONNMARK/;
|
||||
@@ -161,6 +161,15 @@ sub setup_route_marking() {
|
||||
add_ijump_extended $mangle_table->{PREROUTING} , j => $chainref, $origin, i => $physical, mark => "--mark 0/$mask";
|
||||
add_ijump_extended $mangle_table->{PREROUTING} , j => $chainref1, $origin, i => "! $physical", mark => "--mark $mark/$mask";
|
||||
add_ijump_extended $mangle_table->{OUTPUT} , j => $chainref2, $origin, mark => "--mark $mark/$mask";
|
||||
|
||||
if ( have_ipsec ) {
|
||||
if ( have_capability( 'MARK_ANYWHERE' ) ) {
|
||||
add_ijump_extended $filter_table->{forward_chain($interface)}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", , state_imatch('NEW'), policy => '--dir in --pol ipsec';
|
||||
} elsif ( have_capability( 'MANGLE_FORWARD' ) ) {
|
||||
add_ijump_extended $mangle_table->{FORWARD}, j => 'CONNMARK', $origin, targetopts => "--set-mark 0${exmask}", i => $physical, state_imatch('NEW'), policy => '--dir in --pol ipsec';
|
||||
}
|
||||
}
|
||||
|
||||
$marked_interfaces{$interface} = 1;
|
||||
}
|
||||
|
||||
@@ -329,22 +338,22 @@ sub balance_default_route( $$$$ ) {
|
||||
if ( $first_default_route ) {
|
||||
if ( $balanced_providers == 1 ) {
|
||||
if ( $gateway ) {
|
||||
emit "DEFAULT_ROUTE=\"via $gateway dev $interface $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="via $gateway dev $interface $realm");
|
||||
} else {
|
||||
emit "DEFAULT_ROUTE=\"dev $interface $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="dev $interface $realm");
|
||||
}
|
||||
} elsif ( $gateway ) {
|
||||
emit "DEFAULT_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="nexthop via $gateway dev $interface weight $weight $realm");
|
||||
} else {
|
||||
emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="nexthop dev $interface weight $weight $realm");
|
||||
}
|
||||
|
||||
$first_default_route = 0;
|
||||
} else {
|
||||
if ( $gateway ) {
|
||||
emit "DEFAULT_ROUTE=\"\$DEFAULT_ROUTE nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="\$DEFAULT_ROUTE nexthop via $gateway dev $interface weight $weight $realm");
|
||||
} else {
|
||||
emit "DEFAULT_ROUTE=\"\$DEFAULT_ROUTE nexthop dev $interface weight $weight $realm\"";
|
||||
emit qq(DEFAULT_ROUTE="\$DEFAULT_ROUTE nexthop dev $interface weight $weight $realm");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,22 +368,22 @@ sub balance_fallback_route( $$$$ ) {
|
||||
if ( $first_fallback_route ) {
|
||||
if ( $fallback_providers == 1 ) {
|
||||
if ( $gateway ) {
|
||||
emit "FALLBACK_ROUTE=\"via $gateway dev $interface $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="via $gateway dev $interface $realm");
|
||||
} else {
|
||||
emit "FALLBACK_ROUTE=\"dev $interface $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="dev $interface $realm");
|
||||
}
|
||||
} elsif ( $gateway ) {
|
||||
emit "FALLBACK_ROUTE=\"nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="nexthop via $gateway dev $interface weight $weight $realm");
|
||||
} else {
|
||||
emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="nexthop dev $interface weight $weight $realm");
|
||||
}
|
||||
|
||||
$first_fallback_route = 0;
|
||||
} else {
|
||||
if ( $gateway ) {
|
||||
emit "FALLBACK_ROUTE=\"\$FALLBACK_ROUTE nexthop via $gateway dev $interface weight $weight $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="\$FALLBACK_ROUTE nexthop via $gateway dev $interface weight $weight $realm");
|
||||
} else {
|
||||
emit "FALLBACK_ROUTE=\"\$FALLBACK_ROUTE nexthop dev $interface weight $weight $realm\"";
|
||||
emit qq(FALLBACK_ROUTE="\$FALLBACK_ROUTE nexthop dev $interface weight $weight $realm");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -502,7 +511,7 @@ sub process_a_provider( $ ) {
|
||||
|
||||
if ( ( $gw = lc $gateway ) eq 'detect' ) {
|
||||
fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared;
|
||||
$gateway = get_interface_gateway( $interface, undef, 1 );
|
||||
$gateway = get_interface_gateway( $interface, undef, $number );
|
||||
$gatewaycase = 'detect';
|
||||
set_interface_option( $interface, 'gateway', 'detect' );
|
||||
} elsif ( $gw eq 'none' ) {
|
||||
@@ -512,6 +521,9 @@ sub process_a_provider( $ ) {
|
||||
set_interface_option( $interface, 'gateway', 'none' );
|
||||
} elsif ( $gateway && $gateway ne '-' ) {
|
||||
( $gateway, $mac ) = split_host_list( $gateway, 0 );
|
||||
|
||||
$gateway = $1 if $family == F_IPV6 && $gateway =~ /^\[(.+)\]$/;
|
||||
|
||||
validate_address $gateway, 0;
|
||||
|
||||
if ( defined $mac ) {
|
||||
@@ -602,6 +614,7 @@ sub process_a_provider( $ ) {
|
||||
} elsif ( $option eq 'nohostroute' ) {
|
||||
$hostroute = 0;
|
||||
} elsif ( $option eq 'persistent' ) {
|
||||
warning_message "When RESTORE_DEFAULT_ROUTE=Yes, the 'persistent' option may not work as expected" if $config{RESTORE_DEFAULT_ROUTE};
|
||||
$persistent = 1;
|
||||
} else {
|
||||
fatal_error "Invalid option ($option)";
|
||||
@@ -688,7 +701,6 @@ sub process_a_provider( $ ) {
|
||||
|
||||
$pref = 10000 + $number - 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unless ( $loose || $pseudo ) {
|
||||
@@ -847,7 +859,7 @@ sub add_a_provider( $$ ) {
|
||||
if ( $tproxy ) {
|
||||
emit 'run_ip route add local ' . ALLIP . " dev $physical table $id";
|
||||
} else {
|
||||
emit "run_ip route add default dev $physical table $id";
|
||||
emit "run_ip route replace default dev $physical table $id";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,8 +875,8 @@ sub add_a_provider( $$ ) {
|
||||
emit qq(echo "\$IP route del $gateway src $address dev $physical ${mtu}table $id $realm > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
|
||||
}
|
||||
|
||||
emit( "run_ip route add default via $gateway src $address dev $physical ${mtu}table $id $realm" );
|
||||
emit( qq( echo "\$IP route del default via $gateway src $address dev $physical ${mtu}table $id $realm > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing) );
|
||||
emit( "run_ip route replace default via $gateway src $address dev $physical ${mtu}table $id $realm" );
|
||||
emit( qq(echo "\$IP route del default via $gateway src $address dev $physical ${mtu}table $id $realm > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing) );
|
||||
}
|
||||
|
||||
if ( ! $noautosrc ) {
|
||||
@@ -873,24 +885,25 @@ sub add_a_provider( $$ ) {
|
||||
emit( "run_ip rule add from $address pref 20000 table $id" ,
|
||||
"echo \"\$IP -$family rule del from $address pref 20000> /dev/null 2>&1\" >> \${VARDIR}/undo_${table}_routing" );
|
||||
} else {
|
||||
emit ( "find_interface_addresses $physical | while read address; do" );
|
||||
emit ( " qt \$IP -$family rule del from \$address" );
|
||||
emit ( " run_ip rule add from \$address pref 20000 table $id",
|
||||
emit ( '',
|
||||
"find_interface_addresses $physical | while read address; do",
|
||||
" qt \$IP -$family rule del from \$address",
|
||||
" run_ip rule add from \$address pref 20000 table $id",
|
||||
" echo \"\$IP -$family rule del from \$address pref 20000 > /dev/null 2>&1\" >> \${VARDIR}/undo_${table}_routing",
|
||||
' rulenum=$(($rulenum + 1))',
|
||||
'done'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( @{$providerref->{persistent_routes}} ) {
|
||||
emit '';
|
||||
emit $_ for @{$providers{$table}->{persistent_routes}};
|
||||
}
|
||||
if ( @{$providerref->{persistent_routes}} ) {
|
||||
emit '';
|
||||
emit $_ for @{$providers{$table}->{persistent_routes}};
|
||||
}
|
||||
|
||||
if ( @{$providerref->{persistent_rules}} ) {
|
||||
emit '';
|
||||
emit $_ for @{$providers{$table}->{persistent_rules}};
|
||||
}
|
||||
if ( @{$providerref->{persistent_rules}} ) {
|
||||
emit '';
|
||||
emit $_ for @{$providers{$table}->{persistent_rules}};
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
@@ -898,7 +911,6 @@ sub add_a_provider( $$ ) {
|
||||
emit( qq(fi\n),
|
||||
qq(echo 1 > \${VARDIR}/${physical}_disabled) );
|
||||
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit( "}\n" );
|
||||
@@ -924,7 +936,7 @@ sub add_a_provider( $$ ) {
|
||||
if ( $tproxy ) {
|
||||
emit 'run_ip route add local ' . ALLIP . " dev $physical table $id";
|
||||
} else {
|
||||
emit "run_ip route add default dev $physical table $id";
|
||||
emit "run_ip route replace default dev $physical table $id";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,7 +968,7 @@ CEOF
|
||||
my $hexmark = in_hex( $mark );
|
||||
my $mask = have_capability( 'FWMARK_RT_MASK' ) ? '/' . in_hex( $globals{ $tproxy && ! $local ? 'TPROXY_MARK' : 'PROVIDER_MASK' } ) : '';
|
||||
|
||||
emit ( "qt \$IP -$family rule del fwmark ${hexmark}${mask}" ) if $config{DELETE_THEN_ADD};
|
||||
emit ( "qt \$IP -$family rule del fwmark ${hexmark}${mask}" ) if $persistent || $config{DELETE_THEN_ADD};
|
||||
|
||||
emit ( "run_ip rule add fwmark ${hexmark}${mask} pref $pref table $id",
|
||||
"echo \"\$IP -$family rule del fwmark ${hexmark}${mask} > /dev/null 2>&1\" >> \${VARDIR}/undo_${table}_routing"
|
||||
@@ -985,7 +997,7 @@ CEOF
|
||||
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
|
||||
}
|
||||
|
||||
emit "run_ip route add default via $gateway src $address dev $physical ${mtu}table $id $realm";
|
||||
emit "run_ip route replace default via $gateway src $address dev $physical ${mtu}table $id $realm";
|
||||
}
|
||||
|
||||
if ( $balance ) {
|
||||
@@ -997,14 +1009,16 @@ CEOF
|
||||
emit '';
|
||||
if ( $gateway ) {
|
||||
emit qq(run_ip route replace $gateway/32 dev $physical table $id) if $hostroute;
|
||||
emit qq(run_ip route add default via $gateway src $address dev $physical table $id metric $number);
|
||||
emit qq(run_ip route replace default via $gateway src $address dev $physical table $id metric $number);
|
||||
emit qq(echo "\$IP -$family route del default via $gateway table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
|
||||
emit qq(echo "\$IP -4 route del $gateway/32 dev $physical table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing) if $family == F_IPV4;
|
||||
} else {
|
||||
emit qq(run_ip route add default table $id dev $physical metric $number);
|
||||
emit qq(run_ip route replace default table $id dev $physical metric $number);
|
||||
emit qq(echo "\$IP -$family route del default dev $physical table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing);
|
||||
}
|
||||
|
||||
emit( 'g_fallback=Yes' ) if $persistent;
|
||||
|
||||
$metrics = 1;
|
||||
}
|
||||
|
||||
@@ -1026,12 +1040,13 @@ CEOF
|
||||
} elsif ( ! $noautosrc ) {
|
||||
if ( $shared ) {
|
||||
if ( $persistent ) {
|
||||
emit( qq(if ! egrep -q "^2000:[[:space:]]+from $address lookup $id"; then),
|
||||
emit( qq(if ! egrep -q "^20000:[[:space:]]+from $address lookup $id"; then),
|
||||
qq( qt \$IP -$family rule del from $address pref 20000),
|
||||
qq( run_ip rule add from $address pref 20000 table $id),
|
||||
qq( echo "\$IP -$family rule del from $address pref 20000> /dev/null 2>&1" >> \${VARDIR}/undo_${table}_routing ),
|
||||
qq(fi) );
|
||||
} else {
|
||||
emit "qt \$IP -$family rule del from $address" if $config{DELETE_THEN_ADD};
|
||||
emit "qt \$IP -$family rule del from $address" if $persistent || $config{DELETE_THEN_ADD};
|
||||
emit( "run_ip rule add from $address pref 20000 table $id" ,
|
||||
"echo \"\$IP -$family rule del from $address pref 20000> /dev/null 2>&1\" >> \${VARDIR}/undo_${table}_routing" );
|
||||
}
|
||||
@@ -1092,6 +1107,17 @@ CEOF
|
||||
$pseudo ? "run_enabled_exit ${physical} ${interface}" : "run_enabled_exit ${physical} ${interface} ${table}"
|
||||
);
|
||||
|
||||
if ( ! $pseudo && $config{USE_DEFAULT_RT} && $config{RESTORE_DEFAULT_ROUTE} ) {
|
||||
emit ( '#',
|
||||
'# We now have a viable default route in the \'default\' table so delete any default routes in the main table',
|
||||
'#',
|
||||
'while qt \$IP -$family route del default table ' . MAIN_TABLE . '; do',
|
||||
' true',
|
||||
'done',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
emit_started_message( '', 2, $pseudo, $table, $number );
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) || get_interface_option( $interface, 'used_gateway_variable' ) ) {
|
||||
@@ -1225,7 +1251,7 @@ CEOF
|
||||
'if [ $COMMAND = disable ]; then',
|
||||
" do_persistent_${what}_${table}",
|
||||
"else",
|
||||
" echo 1 > \${VARDIR}/${physical}_disabled\n",
|
||||
" echo 1 > \${VARDIR}/${physical}_disabled",
|
||||
"fi\n",
|
||||
);
|
||||
}
|
||||
@@ -1241,9 +1267,9 @@ CEOF
|
||||
);
|
||||
|
||||
if ( $pseudo ) {
|
||||
emit( "progress_message2 \" Optional Interface $table stopped\"" );
|
||||
emit( "progress_message2 \"Optional Interface $table stopped\"" );
|
||||
} else {
|
||||
emit( "progress_message2 \" Provider $table ($number) stopped\"" );
|
||||
emit( "progress_message2 \"Provider $table ($number) stopped\"" );
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
@@ -1344,7 +1370,7 @@ sub add_an_rtrule1( $$$$$ ) {
|
||||
|
||||
$priority = "pref $priority";
|
||||
|
||||
push @{$providerref->{rules}}, "qt \$IP -$family rule del $source ${dest}${mark} $priority" if $config{DELETE_THEN_ADD};
|
||||
push @{$providerref->{rules}}, "qt \$IP -$family rule del $source ${dest}${mark} $priority" if $persistent || $config{DELETE_THEN_ADD};
|
||||
push @{$providerref->{rules}}, "run_ip rule add $source ${dest}${mark} $priority table $id";
|
||||
|
||||
if ( $persistent ) {
|
||||
@@ -1442,22 +1468,22 @@ sub add_a_route( ) {
|
||||
|
||||
if ( $gateway ne '-' ) {
|
||||
if ( $device ne '-' ) {
|
||||
push @$routes, qq(run_ip route add $dest via $gateway dev $physical table $id);
|
||||
push @$persistent_routes, qq(run_ip route add $dest via $gateway dev $physical table $id) if $persistent;
|
||||
push @$routes, qq(run_ip route replace $dest via $gateway dev $physical table $id);
|
||||
push @$persistent_routes, qq(run_ip route replace $dest via $gateway dev $physical table $id) if $persistent;
|
||||
push @$routes, q(echo "$IP ) . qq(-$family route del $dest via $gateway dev $physical table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${provider}_routing) if $number >= DEFAULT_TABLE;
|
||||
} elsif ( $null ) {
|
||||
push @$routes, qq(run_ip route add $null $dest table $id);
|
||||
push @$persistent_routes, qq(run_ip route add $null $dest table $id) if $persistent;
|
||||
push @$routes, qq(run_ip route replace $null $dest table $id);
|
||||
push @$persistent_routes, qq(run_ip route replace $null $dest table $id) if $persistent;
|
||||
push @$routes, q(echo "$IP ) . qq(-$family route del $null $dest table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${provider}_routing) if $number >= DEFAULT_TABLE;
|
||||
} else {
|
||||
push @$routes, qq(run_ip route add $dest via $gateway table $id);
|
||||
push @$persistent_routes, qq(run_ip route add $dest via $gateway table $id) if $persistent;
|
||||
push @$routes, qq(run_ip route replace $dest via $gateway table $id);
|
||||
push @$persistent_routes, qq(run_ip route replace $dest via $gateway table $id) if $persistent;
|
||||
push @$routes, q(echo "$IP ) . qq(-$family route del $dest via $gateway table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${provider}_routing) if $number >= DEFAULT_TABLE;
|
||||
}
|
||||
} else {
|
||||
fatal_error "You must specify a device for this route" unless $physical;
|
||||
push @$routes, qq(run_ip route add $dest dev $physical table $id);
|
||||
push @$persistent_routes, qq(run_ip route add $dest dev $physical table $id) if $persistent;
|
||||
push @$routes, qq(run_ip route replace $dest dev $physical table $id);
|
||||
push @$persistent_routes, qq(run_ip route replace $dest dev $physical table $id) if $persistent;
|
||||
push @$routes, q(echo "$IP ) . qq(-$family route del $dest dev $physical table $id > /dev/null 2>&1" >> \${VARDIR}/undo_${provider}_routing) if $number >= DEFAULT_TABLE;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1585,7 @@ sub finish_providers() {
|
||||
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",
|
||||
" while qt \$IP -6 route delete default table $table; do true; done",
|
||||
" run_ip route add default scope global table $table \$DEFAULT_ROUTE",
|
||||
' else',
|
||||
" run_ip route replace default scope global table $table \$DEFAULT_ROUTE",
|
||||
@@ -1568,7 +1594,8 @@ sub finish_providers() {
|
||||
}
|
||||
|
||||
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",
|
||||
' true',
|
||||
' done',
|
||||
''
|
||||
@@ -1580,7 +1607,7 @@ sub finish_providers() {
|
||||
' error_message "WARNING: No Default route added (all \'balance\' providers are down)"' );
|
||||
|
||||
if ( $config{RESTORE_DEFAULT_ROUTE} ) {
|
||||
emit qq( restore_default_route $config{USE_DEFAULT_RT} && error_message "NOTICE: Default route restored")
|
||||
emit qq( [ -z "\${FALLBACK_ROUTE}\${g_fallback}" ] && restore_default_route $config{USE_DEFAULT_RT} && error_message "NOTICE: Default route restored")
|
||||
} else {
|
||||
emit qq( qt \$IP -$family route del default table $table && error_message "WARNING: Default route deleted from table $table");
|
||||
}
|
||||
@@ -1607,7 +1634,7 @@ sub finish_providers() {
|
||||
}
|
||||
|
||||
emit ( '#',
|
||||
'# Delete any routes in the \'balance\' table',
|
||||
'# Delete any default routes with metric 0 in the \'balance\' table',
|
||||
'#',
|
||||
"while qt \$IP -$family route del default table $balance; do",
|
||||
' true',
|
||||
@@ -1622,7 +1649,7 @@ sub finish_providers() {
|
||||
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( " while qt \$IP -6 route delete default table $default; do true; done" );
|
||||
emit( " run_ip route add default scope global table $default \$FALLBACK_ROUTE" );
|
||||
}
|
||||
|
||||
@@ -1635,7 +1662,10 @@ sub finish_providers() {
|
||||
'fi',
|
||||
'' );
|
||||
} elsif ( $config{USE_DEFAULT_RT} ) {
|
||||
emit( "delete_default_routes $default",
|
||||
emit( '#',
|
||||
'# No balanced fallback routes - delete any routes with metric 0 from the \'default\' table',
|
||||
'#',
|
||||
"delete_default_routes $default",
|
||||
''
|
||||
);
|
||||
}
|
||||
@@ -1680,7 +1710,7 @@ sub process_providers( $ ) {
|
||||
}
|
||||
|
||||
if ( $providers ) {
|
||||
fatal_error q(Either all 'fallback' providers must specify a weight or non of them can specify a weight) if $fallback && $metrics;
|
||||
fatal_error q(Either all 'fallback' providers must specify a weight or none of them can specify a weight) if $fallback && $metrics;
|
||||
|
||||
my $fn = open_file( 'route_rules' );
|
||||
|
||||
@@ -1711,7 +1741,7 @@ sub process_providers( $ ) {
|
||||
|
||||
add_a_provider( $providers{$_}, $tcdevices ) for @providers;
|
||||
|
||||
emit << 'EOF';;
|
||||
emithd << 'EOF';;
|
||||
|
||||
#
|
||||
# Enable an optional provider
|
||||
@@ -1757,12 +1787,11 @@ EOF
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
|
||||
emit << 'EOF';;
|
||||
emithd << 'EOF';;
|
||||
*)
|
||||
startup_error "$g_interface is not an optional provider or interface"
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1866,20 +1895,19 @@ sub setup_providers() {
|
||||
|
||||
start_providers;
|
||||
|
||||
setup_null_routing if $config{NULL_ROUTE_RFC1918};
|
||||
setup_null_routing, emit '' if $config{NULL_ROUTE_RFC1918};
|
||||
|
||||
emit '';
|
||||
|
||||
emit "start_$providers{$_}->{what}_$_" for @providers;
|
||||
|
||||
emit '';
|
||||
if ( @providers ) {
|
||||
emit "start_$providers{$_}->{what}_$_" for @providers;
|
||||
emit '';
|
||||
}
|
||||
|
||||
finish_providers;
|
||||
|
||||
emit "\nrun_ip route flush cache";
|
||||
|
||||
pop_indent;
|
||||
emit "fi\n";
|
||||
emit 'fi';
|
||||
|
||||
setup_route_marking if @routemarked_interfaces || @load_interfaces;
|
||||
} else {
|
||||
@@ -1890,9 +1918,10 @@ sub setup_providers() {
|
||||
if ( $pseudoproviders ) {
|
||||
emit '';
|
||||
emit "start_$providers{$_}->{what}_$_" for @providers;
|
||||
emit '';
|
||||
}
|
||||
|
||||
emit "\nundo_routing";
|
||||
emit "undo_routing";
|
||||
emit "restore_default_route $config{USE_DEFAULT_RT}";
|
||||
|
||||
my $standard_routes = @{$providers{main}{routes}} || @{$providers{default}{routes}};
|
||||
@@ -1917,9 +1946,8 @@ sub setup_providers() {
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "fi\n";
|
||||
emit 'fi';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@@ -2168,17 +2196,13 @@ sub provider_realm( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# This function is called by the compiler when it is generating the detect_configuration() function.
|
||||
# The function calls Shorewall::Zones::verify_required_interfaces then emits code to set the
|
||||
# ..._IS_USABLE interface variables appropriately for the optional interfaces
|
||||
# Perform processing related to optional interfaces. Returns true if there are optional interfaces.
|
||||
|
||||
#
|
||||
# Returns true if there were required or optional interfaces
|
||||
#
|
||||
sub handle_optional_interfaces( $ ) {
|
||||
sub handle_optional_interfaces() {
|
||||
|
||||
my @interfaces;
|
||||
my $wildcards;
|
||||
|
||||
#
|
||||
# First do the provider interfacess. Those that are real providers will never have wildcard physical
|
||||
# names but they might derive from wildcard interface entries. Optional interfaces which do not have
|
||||
@@ -2202,10 +2226,6 @@ sub handle_optional_interfaces( $ ) {
|
||||
|
||||
if ( @interfaces ) {
|
||||
my $require = $config{REQUIRE_INTERFACE};
|
||||
my $gencase = shift;
|
||||
|
||||
verify_required_interfaces( $gencase );
|
||||
emit '' if $gencase;
|
||||
|
||||
emit( 'HAVE_INTERFACE=', '' ) if $require;
|
||||
#
|
||||
@@ -2369,8 +2389,6 @@ sub handle_optional_interfaces( $ ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
verify_required_interfaces( shift );
|
||||
}
|
||||
|
||||
#
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Proxyarp.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Proxyarp.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -96,6 +96,7 @@ sub setup_one_proxy_arp( $$$$$$$ ) {
|
||||
}
|
||||
|
||||
emit ( "run_ip neigh add proxy $address nud permanent dev $extphy" ,
|
||||
'' ,
|
||||
qq(progress_message " Host $address connected to $interface added to $proto on $extphy"\n) );
|
||||
|
||||
push @proxyarp, "$address $interface $external $haveroute";
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Raw.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Raw.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2009-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2009-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -91,7 +91,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
|
||||
my $disposition = $action;
|
||||
my $exception_rule = '';
|
||||
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_condition( $switch , $chainref->{name} );
|
||||
|
||||
my $level = '';
|
||||
|
||||
if ( $action =~ /^(?:NFLOG|ULOG)/ ) {
|
||||
@@ -138,6 +138,14 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
|
||||
require_capability 'CT_TARGET', 'CT entries in the conntrack file', '';
|
||||
|
||||
if ( $proto ne '-' ) {
|
||||
if ( $proto =~ s/:all$// ) {
|
||||
fatal_error '":all" may only be used with TCP' unless resolve_proto( $proto ) == TCP;
|
||||
} else {
|
||||
$proto = TCP . ':syn' if $proto !~ /:syn/ && resolve_proto( $proto ) == TCP;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $option eq 'notrack' ) {
|
||||
fatal_error "Invalid conntrack ACTION ( $action )" if supplied $args;
|
||||
$action = 'CT --notrack';
|
||||
@@ -199,7 +207,9 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
expand_rule( $chainref ,
|
||||
$restriction ,
|
||||
'',
|
||||
$rule,
|
||||
do_proto( $proto, $ports, $sports ) .
|
||||
do_user ( $user ) .
|
||||
do_condition( $switch , $chainref->{name} ),
|
||||
$source ,
|
||||
$dest ,
|
||||
'' ,
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/Shorewall/Tc.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Tc.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Traffic Control is from tc4shorewall Version 0.5
|
||||
# (c) 2005 Arne Bernin <arne@ucbering.de>
|
||||
@@ -225,11 +225,11 @@ sub handle_in_bandwidth( $$$ ) {
|
||||
if ( have_capability 'BASIC_FILTER' ) {
|
||||
if ( $in_rate ) {
|
||||
emit( "run_tc filter add dev $physical parent ffff: protocol all prio 10 basic \\",
|
||||
" police mpu 64 drop rate ${in_rate}kbit burst $in_burst\n" );
|
||||
" police mpu 64 rate ${in_rate}kbit burst $in_burst drop\n" );
|
||||
} else {
|
||||
emit( "run_tc filter add dev $physical parent ffff: protocol all prio 10 \\",
|
||||
" estimator $in_interval $in_decay basic \\",
|
||||
" police drop avrate ${in_avrate}kbit\n" );
|
||||
" police avrate ${in_avrate}kbit drop\n" );
|
||||
}
|
||||
} else {
|
||||
emit( "run_tc filter add dev $physical parent ffff: protocol all prio 10 \\" ,
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# Shorewall 4.4 -- /usr/share/shorewall/Shorewall/Zones.pm
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/Shorewall/Zones.pm
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009,2010,2011 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010,2011-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -90,7 +90,6 @@ our @EXPORT = ( qw( NOTHING
|
||||
interface_is_optional
|
||||
interface_is_required
|
||||
find_interfaces_by_option
|
||||
find_interfaces_by_option1
|
||||
get_interface_option
|
||||
get_interface_origin
|
||||
interface_has_option
|
||||
@@ -253,6 +252,17 @@ use constant { NO_UPDOWN => 1,
|
||||
|
||||
our %validinterfaceoptions;
|
||||
|
||||
our %procinterfaceoptions=( accept_ra => 1,
|
||||
arp_filter => 1,
|
||||
arp_ignore => 1,
|
||||
forward => 1,
|
||||
logmartians => 1,
|
||||
proxyarp => 1,
|
||||
proxyndp => 1,
|
||||
routefilter => 1,
|
||||
sourceroute => 1,
|
||||
);
|
||||
|
||||
our %prohibitunmanaged = (
|
||||
blacklist => 1,
|
||||
bridge => 1,
|
||||
@@ -317,7 +327,7 @@ sub initialize( $$ ) {
|
||||
%mapbase = ();
|
||||
%mapbase1 = ();
|
||||
$baseseq = 0;
|
||||
$minroot = 0;
|
||||
$minroot = undef;
|
||||
$loopback_interface = '';
|
||||
|
||||
%validzoneoptions = ( mss => NUMERIC,
|
||||
@@ -339,7 +349,7 @@ sub initialize( $$ ) {
|
||||
arp_ignore => ENUM_IF_OPTION,
|
||||
blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
bridge => SIMPLE_IF_OPTION,
|
||||
dbl => ENUM_IF_OPTION,
|
||||
dbl => ENUM_IF_OPTION + IF_OPTION_WILDOK,
|
||||
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
detectnets => OBSOLETE_IF_OPTION,
|
||||
dhcp => SIMPLE_IF_OPTION,
|
||||
@@ -363,9 +373,9 @@ sub initialize( $$ ) {
|
||||
upnp => SIMPLE_IF_OPTION,
|
||||
upnpclient => SIMPLE_IF_OPTION,
|
||||
mss => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST + IF_OPTION_WILDOK,
|
||||
unmanaged => SIMPLE_IF_OPTION,
|
||||
wait => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
wait => NUMERIC_IF_OPTION,
|
||||
);
|
||||
%validhostoptions = (
|
||||
blacklist => 1,
|
||||
@@ -390,7 +400,7 @@ sub initialize( $$ ) {
|
||||
%validinterfaceoptions = ( accept_ra => NUMERIC_IF_OPTION,
|
||||
blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
bridge => SIMPLE_IF_OPTION,
|
||||
dbl => ENUM_IF_OPTION,
|
||||
dbl => ENUM_IF_OPTION + IF_OPTION_WILDOK,
|
||||
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
dhcp => SIMPLE_IF_OPTION,
|
||||
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
@@ -402,18 +412,18 @@ sub initialize( $$ ) {
|
||||
optional => SIMPLE_IF_OPTION,
|
||||
proxyndp => BINARY_IF_OPTION,
|
||||
required => SIMPLE_IF_OPTION,
|
||||
routeback => BINARY_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER,
|
||||
routeback => BINARY_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER + IF_OPTION_WILDOK,
|
||||
rpfilter => SIMPLE_IF_OPTION,
|
||||
sfilter => IPLIST_IF_OPTION,
|
||||
sourceroute => BINARY_IF_OPTION,
|
||||
tcpflags => BINARY_IF_OPTION + IF_OPTION_HOST,
|
||||
mss => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
forward => BINARY_IF_OPTION,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST + IF_OPTION_WILDOK,
|
||||
unmanaged => SIMPLE_IF_OPTION,
|
||||
upnp => SIMPLE_IF_OPTION,
|
||||
upnpclient => SIMPLE_IF_OPTION,
|
||||
wait => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
wait => NUMERIC_IF_OPTION,
|
||||
);
|
||||
%validhostoptions = (
|
||||
blacklist => 1,
|
||||
@@ -714,7 +724,7 @@ sub interface_match( $$ ) {
|
||||
return 1 if $piface eq $cifaceref->{bridge};
|
||||
return 1 if $ciface eq $pifaceref->{bridge};
|
||||
|
||||
if ( $minroot ) {
|
||||
if ( defined $minroot ) {
|
||||
if ( $piface =~ /\+$/ ) {
|
||||
my $root = $pifaceref->{root};
|
||||
my $rlength = length( $root );
|
||||
@@ -1204,15 +1214,16 @@ sub process_interface( $$ ) {
|
||||
}
|
||||
|
||||
my $wildcard = 0;
|
||||
my $physwild = 0;
|
||||
my $root;
|
||||
|
||||
if ( $interface =~ /\+$/ ) {
|
||||
$wildcard = 1;
|
||||
$wildcard = $physwild = 1; # Default physical name is the logical name
|
||||
$root = substr( $interface, 0, -1 );
|
||||
$roots{$root} = $interface;
|
||||
my $len = length $root;
|
||||
|
||||
if ( $minroot ) {
|
||||
if ( defined $minroot ) {
|
||||
$minroot = $len if $minroot > $len;
|
||||
} else {
|
||||
$minroot = $len;
|
||||
@@ -1258,8 +1269,6 @@ sub process_interface( $$ ) {
|
||||
my %hostoptions = ( dynamic => 0 );
|
||||
|
||||
for my $option (split_list1 $options, 'option' ) {
|
||||
next if $option eq '-';
|
||||
|
||||
( $option, my $value ) = split /=/, $option;
|
||||
|
||||
fatal_error "Invalid Interface option ($option)" unless my $type = $validinterfaceoptions{$option};
|
||||
@@ -1296,7 +1305,6 @@ sub process_interface( $$ ) {
|
||||
} elsif ( $type == BINARY_IF_OPTION ) {
|
||||
$value = 1 unless defined $value;
|
||||
fatal_error "Option value for '$option' must be 0 or 1" unless ( $value eq '0' || $value eq '1' );
|
||||
fatal_error "The '$option' option may not be used with a wild-card interface name" if $wildcard && ! $type && IF_OPTION_WILDOK;
|
||||
$options{$option} = $value;
|
||||
$hostoptions{$option} = $value if $hostopt;
|
||||
} elsif ( $type == ENUM_IF_OPTION ) {
|
||||
@@ -1320,7 +1328,6 @@ sub process_interface( $$ ) {
|
||||
assert( 0 );
|
||||
}
|
||||
} elsif ( $type == NUMERIC_IF_OPTION ) {
|
||||
fatal_error "The '$option' option may not be specified on a wildcard interface" if $wildcard && ! $type && IF_OPTION_WILDOK;
|
||||
$value = $defaultinterfaceoptions{$option} unless defined $value;
|
||||
fatal_error "The '$option' option requires a value" unless defined $value;
|
||||
my $numval = numeric_value $value;
|
||||
@@ -1372,7 +1379,9 @@ sub process_interface( $$ ) {
|
||||
|
||||
fatal_error "Duplicate physical interface name ($value)" if ( $interfaces{$value} && ! $port );
|
||||
|
||||
fatal_error "The type of 'physical' name ($value) doesn't match the type of interface name ($interface)" if $wildcard && ! $value =~ /\+$/;
|
||||
$physwild = ( $value =~ /\+$/ );
|
||||
fatal_error "The type of 'physical' name ($value) doesn't match the type of interface name ($interface)" if $wildcard && ! $physwild;
|
||||
|
||||
$physical = $value;
|
||||
} else {
|
||||
assert(0);
|
||||
@@ -1400,6 +1409,14 @@ sub process_interface( $$ ) {
|
||||
$options{ignore} = 0;
|
||||
}
|
||||
|
||||
for my $option ( keys %options ) {
|
||||
if ( $root ) {
|
||||
warning_message( "The '$option' option is ignored when used with a wildcard physical name" ) if $physwild && $procinterfaceoptions{$option};
|
||||
} else {
|
||||
warning_message( "The '$option' option is ignored when used with interface name '+'" ) unless $validinterfaceoptions{$option} & IF_OPTION_WILDOK;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $netsref eq 'dynamic' ) {
|
||||
my $ipset = $family == F_IPV4 ? "${zone}" : "6_${zone}";
|
||||
$ipset = join( '_', $ipset, var_base1( $physical ) ) unless $zoneref->{options}{in_out}{dynamic_shared};
|
||||
@@ -1458,6 +1475,7 @@ sub process_interface( $$ ) {
|
||||
zones => {},
|
||||
origin => shortlineinfo( '' ),
|
||||
wildcard => $wildcard,
|
||||
physwild => $physwild, # Currently unused
|
||||
};
|
||||
|
||||
$interfaces{$physical} = $interfaceref if $physical ne $interface;
|
||||
@@ -1616,7 +1634,7 @@ sub known_interface($)
|
||||
|
||||
my $iface = $interface;
|
||||
|
||||
if ( $minroot ) {
|
||||
if ( defined $minroot ) {
|
||||
#
|
||||
# We have wildcard interfaces -- see if this interface matches one of their roots
|
||||
#
|
||||
@@ -1857,7 +1875,8 @@ sub find_interfaces_by_option( $;$ ) {
|
||||
for my $interface ( @interfaces ) {
|
||||
my $interfaceref = $interfaces{$interface};
|
||||
|
||||
next unless $interfaceref->{root};
|
||||
next unless $interfaceref->{root}; # Don't return '+' interface
|
||||
next if $procinterfaceoptions{$option} && $interfaceref->{physwild}; # Ignore /proc options on wildcard interface
|
||||
|
||||
my $optionsref = $interfaceref->{options};
|
||||
if ( $nonzero ) {
|
||||
@@ -1872,35 +1891,6 @@ sub find_interfaces_by_option( $;$ ) {
|
||||
\@ints;
|
||||
}
|
||||
|
||||
#
|
||||
# Returns reference to array of interfaces with the passed option. Unlike the preceding function, this one:
|
||||
#
|
||||
# - All entries in %interfaces are searched.
|
||||
# - Returns a two-element list; the second element indicates whether any members of the list have wildcard physical names
|
||||
#
|
||||
sub find_interfaces_by_option1( $ ) {
|
||||
my $option = $_[0];
|
||||
my @ints = ();
|
||||
my $wild = 0;
|
||||
|
||||
for my $interface ( @interfaces ) {
|
||||
my $interfaceref = $interfaces{$interface};
|
||||
|
||||
next unless defined $interfaceref->{physical};
|
||||
|
||||
my $optionsref = $interfaceref->{options};
|
||||
|
||||
if ( $optionsref && defined $optionsref->{$option} ) {
|
||||
$wild ||= $interfaceref->{wildcard};
|
||||
push @ints , $interface
|
||||
}
|
||||
}
|
||||
|
||||
return unless defined wantarray;
|
||||
|
||||
wantarray ? ( \@ints, $wild ) : \@ints;
|
||||
}
|
||||
|
||||
#
|
||||
# Return the value of an option for an interface
|
||||
#
|
||||
@@ -2031,6 +2021,7 @@ sub verify_required_interfaces( $ ) {
|
||||
|
||||
emit( "esac\n" );
|
||||
|
||||
$returnvalue = 1;
|
||||
}
|
||||
|
||||
$interfaces = find_interfaces_by_option( 'required' );
|
||||
@@ -2076,7 +2067,7 @@ sub verify_required_interfaces( $ ) {
|
||||
emit( ';;' );
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
emit( 'esac' );
|
||||
emit( "esac\n" );
|
||||
}
|
||||
|
||||
$returnvalue = 1;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# (c) 1999-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This program is part of Shorewall.
|
||||
#
|
||||
@@ -369,7 +369,7 @@ replace_default_route() # $1 = USE_DEFAULT_RT
|
||||
delete_default_routes() # $1 = table number
|
||||
{
|
||||
$IP -$g_family route ls table $1 | grep -F default | grep -vF metric | while read route; do
|
||||
qt $IP -$g_family route del $route
|
||||
qt $IP -$g_family route del $route table $1
|
||||
done
|
||||
}
|
||||
|
||||
@@ -899,7 +899,7 @@ detect_dynamic_gateway() { # $1 = interface
|
||||
#
|
||||
# Detect the gateway through an interface
|
||||
#
|
||||
detect_gateway() # $1 = interface
|
||||
detect_gateway() # $1 = interface $2 = table number
|
||||
{
|
||||
local interface
|
||||
interface=$1
|
||||
@@ -912,6 +912,8 @@ detect_gateway() # $1 = interface
|
||||
# Maybe there's a default route through this gateway already
|
||||
#
|
||||
[ -n "$gateway" ] || gateway=$(find_gateway $($IP -4 route list dev $interface | grep ^default))
|
||||
|
||||
[ -z "$gateway" -a -n "$2" ] && gateway=$(find_gateway $($IP -4 route list dev $interface table $2 | grep ^default))
|
||||
#
|
||||
# Last hope -- is there a load-balancing route through the interface?
|
||||
#
|
||||
@@ -1063,8 +1065,6 @@ clear_firewall() {
|
||||
run_iptables -F
|
||||
qt $IPTABLES -t raw -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
if [ -n "$DISABLE_IPV6" ]; then
|
||||
if [ -x $IP6TABLES ]; then
|
||||
$IP6TABLES -P INPUT ACCEPT 2> /dev/null
|
||||
@@ -1373,8 +1373,6 @@ clear_firewall() {
|
||||
run_iptables -F
|
||||
qt $IP6TABLES -t raw -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
|
||||
run_clear_exit
|
||||
|
||||
set_state "Cleared"
|
||||
|
@@ -1,5 +1,23 @@
|
||||
###############################################################################
|
||||
# Code imported from /usr/share/shorewall/prog.footer
|
||||
#
|
||||
# (c) 1999-2018 - Tom Eastep (teastep@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/>.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# Give Usage Information
|
||||
@@ -78,11 +96,13 @@ reload_command() {
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
[ $status -eq 0 ] && touch $SUBSYSLOCK || rm -f $SUBSYSLOCK
|
||||
fi
|
||||
|
||||
[ $status -eq 0 ] && progress_message3 "done."
|
||||
if [ $status -eq 0 ]; then
|
||||
[ -n "$SUBSYSLOCK" ] && touch $SUBSYSLOCK
|
||||
progress_message3 "done."
|
||||
else
|
||||
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -127,8 +147,10 @@ g_counters=
|
||||
g_compiled=
|
||||
g_file=
|
||||
g_docker=
|
||||
g_dockeringress=
|
||||
g_dockernetwork=
|
||||
g_forcereload=
|
||||
g_fallback=
|
||||
|
||||
[ -n "$SERVICEDIR" ] && SUBSYSLOCK=
|
||||
|
||||
@@ -264,8 +286,10 @@ case "$COMMAND" in
|
||||
error_message "$g_product is not running"
|
||||
status=2
|
||||
elif [ $# -eq 1 ]; then
|
||||
$g_tool -Z
|
||||
$g_tool -t mangle -Z
|
||||
for table in raw mangle nat filter; do
|
||||
qt $g_tool -t $table -Z
|
||||
done
|
||||
|
||||
date > ${VARDIR}/restarted
|
||||
status=0
|
||||
progress_message3 "$g_product Counters Reset"
|
||||
@@ -349,6 +373,7 @@ case "$COMMAND" in
|
||||
clear)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
progress_message3 "Clearing $g_product...."
|
||||
detect_configuration
|
||||
clear_firewall
|
||||
status=0
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
@@ -418,9 +443,12 @@ case "$COMMAND" in
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
COMMAND=disable
|
||||
detect_configuration $1
|
||||
COMMAND=enable disable_provider $1 Yes
|
||||
COMMAND=disable enable_provider $1 Yes
|
||||
disable_provider $1 Yes
|
||||
COMMAND=enable
|
||||
detect_configuration $1
|
||||
enable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
|
@@ -77,7 +77,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
|
||||
ARPTABLES=
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -183,7 +183,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -205,8 +205,6 @@ MINIUPNPD=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample Interfaces File for one-interface configuration.
|
||||
# Copyright (C) 2006-2015 by the Shorewall Team
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -14,4 +14,4 @@
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
net eth0 dhcp,tcpflags,logmartians,nosmurfs,sourceroute=0
|
||||
net NET_IF dhcp,tcpflags,logmartians,nosmurfs,sourceroute=0,physical=eth0
|
||||
|
@@ -88,7 +88,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
|
||||
ARPTABLES=
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -194,7 +194,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -216,8 +216,6 @@ MINIUPNPD=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample Interfaces File for three-interface configuration.
|
||||
# Copyright (C) 2006-2015 by the Shorewall Team
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -14,6 +14,6 @@
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
net eth0 tcpflags,dhcp,nosmurfs,routefilter,logmartians,sourceroute=0
|
||||
loc eth1 tcpflags,nosmurfs,routefilter,logmartians
|
||||
dmz eth2 tcpflags,nosmurfs,routefilter,logmartians
|
||||
net NET_IF tcpflags,dhcp,nosmurfs,routefilter,logmartians,sourceroute=0,physical=eth0
|
||||
loc LOC_IF tcpflags,nosmurfs,routefilter,logmartians,physical=eth1
|
||||
dmz DMZ_IF tcpflags,nosmurfs,routefilter,logmartians,physical=eth2
|
||||
|
@@ -85,7 +85,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
|
||||
ARPTABLES=
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -191,7 +191,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -213,8 +213,6 @@ MINIUPNPD=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample SNAT/Masqueradee File for three-interface configuration.
|
||||
# Copyright (C) 2006-2016 by the Shorewall Team
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,4 +20,4 @@
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
192.168.0.0/16 eth0
|
||||
192.168.0.0/16 NET_IF
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample Stoppedrules File for three-interface configuration.
|
||||
# Copyright (C) 2012-2015 by the Shorewall Team
|
||||
# Copyright (C) 2012-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -13,8 +13,8 @@
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE
|
||||
# PORT(S) PORT(S)
|
||||
ACCEPT eth1 -
|
||||
ACCEPT - eth1
|
||||
ACCEPT eth2 -
|
||||
ACCEPT - eth2
|
||||
ACCEPT LOC_IF -
|
||||
ACCEPT - LOC_IF
|
||||
ACCEPT DMZ_IF -
|
||||
ACCEPT - DMZ_IF
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample Interfaces File for two-interface configuration.
|
||||
# Copyright (C) 2006-2015 by the Shorewall Team
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -14,5 +14,5 @@
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
net eth0 dhcp,tcpflags,nosmurfs,routefilter,logmartians,sourceroute=0
|
||||
loc eth1 tcpflags,nosmurfs,routefilter,logmartians
|
||||
net NET_IF dhcp,tcpflags,nosmurfs,routefilter,logmartians,sourceroute=0,physical=eth0
|
||||
loc LOC_IF tcpflags,nosmurfs,routefilter,logmartians,physical=eth1
|
||||
|
@@ -88,7 +88,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
|
||||
ARPTABLES=
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -194,7 +194,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -216,8 +216,6 @@ MINIUPNPD=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample SNAT/Masqueradee File for two-interface configuration.
|
||||
# Copyright (C) 2006-2016 by the Shorewall Team
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,4 +20,4 @@
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
192.168.0.0/16 eth0
|
||||
192.168.0.0/16 NET_IF
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall - Sample Stoppedrules File for two-interface configuration.
|
||||
# Copyright (C) 2012-2015 by the Shorewall Team
|
||||
# Copyright (C) 2012-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -13,5 +13,5 @@
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE
|
||||
# PORT(S) PORT(S)
|
||||
ACCEPT eth1 -
|
||||
ACCEPT - eth1
|
||||
ACCEPT LOC_IF -
|
||||
ACCEPT - LOC_IF
|
||||
|
@@ -21,35 +21,46 @@ allowMcast inline # Silently Allow Multicast
|
||||
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
||||
AutoBLL noinline # Helper for AutoBL
|
||||
BLACKLIST logjump,section # Add sender to the dynamic blacklist
|
||||
?if __ADDRTYPE
|
||||
Broadcast inline,audit # Handles Broadcast/Anycast
|
||||
?else
|
||||
Broadcast noinline,audit # Handles Broadcast/Anycast
|
||||
DNSAmp # Matches one-question recursive DNS queries
|
||||
?endif
|
||||
DNSAmp proto=17 # Matches one-question recursive DNS queries
|
||||
Drop # Default Action for DROP policy (deprecated)
|
||||
dropBcast inline # Silently Drop Broadcast
|
||||
dropBcasts inline # Silently Drop Broadcast
|
||||
dropBcasts inline # Silently Drop Broadcast
|
||||
dropInvalid inline # Drops packets in the INVALID conntrack state
|
||||
dropMcast inline # Silently Drop Multicast
|
||||
dropNotSyn noinline # Silently Drop Non-syn TCP packets
|
||||
DropDNSrep inline # Drops DNS replies
|
||||
dropNotSyn noinline,proto=6 # Silently Drop Non-syn TCP packets
|
||||
DropDNSrep inline,proto=17 # Drops DNS replies
|
||||
DropSmurfs noinline # Drop smurf packets
|
||||
Established inline,\ # Handles packets in the ESTABLISHED state
|
||||
state=ESTABLISHED #
|
||||
FIN inline,audit # Handles ACK,FIN,PSH packets
|
||||
FIN inline,audit,\ # Handles ACK,FIN packets
|
||||
proto=6
|
||||
forwardUPnP noinline # Allow traffic that upnpd has redirected from 'upnp' interfaces.
|
||||
GlusterFS inline # Handles GlusterFS
|
||||
IfEvent noinline # Perform an action based on an event
|
||||
Invalid inline,audit,\ # Handles packets in the INVALID conntrack state
|
||||
state=INVALID #
|
||||
Limit noinline # Limit the rate of connections from each individual IP address
|
||||
?if __ADDRTYPE
|
||||
Multicast inline,audit # Handles Multicast
|
||||
?else
|
||||
Multicast noinline,audit # Handles Multicast
|
||||
?endif
|
||||
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
|
||||
rejNotSyn noinline # Silently Reject Non-syn TCP packets
|
||||
NotSyn inline,audit,\ # Handles TCP packets which do not have SYN=1 and ACK=0
|
||||
proto=6
|
||||
rejNotSyn noinline,proto=6 # Silently Reject Non-syn TCP packets
|
||||
Reject # Default Action for REJECT policy (deprecated)
|
||||
Related inline,\ # Handles packets in the RELATED conntrack state
|
||||
state=RELATED #
|
||||
ResetEvent inline # Reset an Event
|
||||
RST inline,audit # Handle packets with RST set
|
||||
RST inline,audit,\ # Handle packets with RST set
|
||||
proto=6
|
||||
SetEvent inline # Initialize an event
|
||||
TCPFlags # Handle bad flag combinations.
|
||||
TCPFlags proto=6 # Handle bad flag combinations.
|
||||
Untracked inline,\ # Handles packets in the UNTRACKED conntrack state
|
||||
state=UNTRACKED #
|
||||
|
@@ -77,7 +77,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
|
||||
ARPTABLES=
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -205,8 +205,6 @@ MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MINIUPNPD=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
@@ -243,7 +241,7 @@ TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
TRACK_PROVIDERS=No
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
TRACK_RULES=No
|
||||
|
||||
|
@@ -3,4 +3,4 @@
|
||||
#
|
||||
# /usr/share/shorewall/configpath
|
||||
#
|
||||
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Shorewall 5.0 -- /usr/share/shorewall/lib.cli-std.
|
||||
# Shorewall 5.1 -- /usr/share/shorewall/lib.cli-std.
|
||||
#
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -47,11 +47,10 @@ get_config() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
config=$(find_file ${PRODUCT}.conf)
|
||||
else
|
||||
[ -n "$g_shorewalldir" ] || fatal_error "Ordinary users may not $COMMAND the $CONFDIR/$PRODUCT configuration"
|
||||
if [ -n "$g_shorewalldir" ]; then
|
||||
config="$g_shorewalldir/$PRODUCT.conf"
|
||||
else
|
||||
config=$(find_file ${PRODUCT}.conf)
|
||||
fi
|
||||
|
||||
if [ -f $config ]; then
|
||||
@@ -211,30 +210,35 @@ get_config() {
|
||||
LOG_VERBOSITY=-1
|
||||
fi
|
||||
|
||||
if [ -n "$SHOREWALL_SHELL" -a -z "$g_export" ]; then
|
||||
if [ ! -x "$SHOREWALL_SHELL" ]; then
|
||||
echo " WARNING: The program specified in SHOREWALL_SHELL does not exist or is not executable; falling back to /bin/sh" >&2
|
||||
SHOREWALL_SHELL=/bin/sh
|
||||
if [ -z "${g_export}${g_test}" ]; then
|
||||
if [ -n "$SHOREWALL_SHELL" ]; then
|
||||
if [ ! -x "$SHOREWALL_SHELL" ]; then
|
||||
echo " WARNING: The program specified in SHOREWALL_SHELL does not exist or is not executable; falling back to /bin/sh" >&2
|
||||
SHOREWALL_SHELL=/bin/sh
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$IP" ]; then
|
||||
case "$IP" in
|
||||
*/*)
|
||||
if [ ! -x "$IP" ] ; then
|
||||
fatal_error "The program specified in IP ($IP) does not exist or is not executable"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
prog="$(mywhich $IP 2> /dev/null)"
|
||||
if [ -z "$prog" ] ; then
|
||||
fatal_error "Can't find $IP executable"
|
||||
fi
|
||||
IP=$prog
|
||||
;;
|
||||
esac
|
||||
if [ -n "$IP" ]; then
|
||||
case "$IP" in
|
||||
*/*)
|
||||
if [ ! -x "$IP" ] ; then
|
||||
fatal_error "The program specified in IP ($IP) does not exist or is not executable"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
prog="$(mywhich $IP 2> /dev/null)"
|
||||
if [ -z "$prog" ] ; then
|
||||
fatal_error "Can't find $IP executable"
|
||||
fi
|
||||
IP=$prog
|
||||
;;
|
||||
esac
|
||||
else
|
||||
IP='ip'
|
||||
fi
|
||||
else
|
||||
IP='ip'
|
||||
[ -n "$SHOREWALL_SHELL" ] || SHOREWALL_SHELL=/bin/sh
|
||||
[ -n "$IP" ] || IP='ip'
|
||||
fi
|
||||
|
||||
case $VERBOSITY in
|
||||
@@ -337,8 +341,12 @@ get_config() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$DYNAMIC_BLACKLIST" ]; then
|
||||
setup_dbl
|
||||
if [ -n "$DYNAMIC_BLACKLIST" -a "$(id -u)" = 0 ]; then
|
||||
case $COMMAND in
|
||||
blacklist|allow|drop|logdrop|reject)
|
||||
setup_dbl
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -z "$PERL_HASH_SEED" ]; then
|
||||
@@ -358,6 +366,17 @@ get_config() {
|
||||
[ -f $lib ] && . $lib
|
||||
}
|
||||
|
||||
#
|
||||
# Ensure that the effective UID is 0 or that we are dealing with a private configuration
|
||||
#
|
||||
ensure_root() {
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = $CONFDIR/$PRODUCT ]; then
|
||||
startup_error "Ordinary users may not $COMMAND the default $PRODUCT configuration"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if there are config files newer than the passed object
|
||||
#
|
||||
@@ -365,20 +384,27 @@ uptodate() {
|
||||
[ -x $1 ] || return 1
|
||||
|
||||
local dir
|
||||
local ifs
|
||||
local busybox
|
||||
local find
|
||||
|
||||
ifs="$IFS"
|
||||
IFS=':'
|
||||
find=$(mywhich find)
|
||||
|
||||
for dir in $g_shorewalldir $CONFIG_PATH; do
|
||||
if [ -n "$(find ${dir} -newer $1)" ]; then
|
||||
IFS="$ifs"
|
||||
[ -n "${find}" ] || return 1
|
||||
[ -h "${find}" ] && busybox=Yes
|
||||
|
||||
for dir in $g_shorewalldir $(split $CONFIG_PATH); do
|
||||
if [ -n "${busybox}" ]; then
|
||||
#
|
||||
# Busybox 'find' doesn't support -quit.
|
||||
#
|
||||
if [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
elif [ -n "$(${find} ${dir} -maxdepth 1 -type f -newer $1 -print -quit)" ]; then
|
||||
return 1;
|
||||
fi
|
||||
done
|
||||
|
||||
IFS="$ifs"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -408,11 +434,7 @@ compiler() {
|
||||
|
||||
pc=${LIBEXECDIR}/shorewall/compiler.pl
|
||||
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = $CONFDIR/$PRODUCT ]; then
|
||||
startup_error "Ordinary users may not $COMMAND the $CONFDIR/$PRODUCT configuration"
|
||||
fi
|
||||
fi
|
||||
ensure_root
|
||||
#
|
||||
# We've now set g_shorewalldir so recalculate CONFIG_PATH
|
||||
#
|
||||
@@ -770,6 +792,10 @@ check_command() {
|
||||
g_profile=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
t*)
|
||||
g_test=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
d*)
|
||||
g_debug=Yes;
|
||||
option=${option#d}
|
||||
@@ -854,6 +880,10 @@ update_command() {
|
||||
g_profile=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
t*)
|
||||
g_test=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
d*)
|
||||
g_debug=Yes;
|
||||
option=${option#d}
|
||||
@@ -1124,6 +1154,41 @@ refresh_command() {
|
||||
return $rc
|
||||
}
|
||||
|
||||
read_yesno_with_timeout() {
|
||||
local timeout
|
||||
timeout=${1:-60}
|
||||
|
||||
case $timeout in
|
||||
*s)
|
||||
;;
|
||||
*m)
|
||||
timeout=$((${timeout%m} * 60))
|
||||
;;
|
||||
*h)
|
||||
timeout=$((${timeout%h} * 3600))
|
||||
;;
|
||||
esac
|
||||
|
||||
read -t $timeout yn 2> /dev/null
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
# read doesn't support timeout
|
||||
test -x /bin/bash || return 2 # bash is not installed so the feature is not available
|
||||
/bin/bash -c "read -t $timeout yn ; if [ \"\$yn\" == \"y\" ] ; then exit 0 ; else exit 1 ; fi" # invoke bash and use its version of read
|
||||
return $?
|
||||
else
|
||||
# read supports timeout
|
||||
case "$yn" in
|
||||
y|Y)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Safe-start/safe-reload/safe-restart Command Executor
|
||||
#
|
||||
@@ -1527,6 +1592,8 @@ remote_reload_command() # $* = original arguments less the command.
|
||||
litedir="${VARDIR}-lite"
|
||||
fi
|
||||
|
||||
g_export=Yes
|
||||
|
||||
if [ -f $g_shorewalldir/${PRODUCT}.conf ]; then
|
||||
if [ -f $g_shorewalldir/params ]; then
|
||||
. $g_shorewalldir/params
|
||||
@@ -1556,18 +1623,16 @@ remote_reload_command() # $* = original arguments less the command.
|
||||
|
||||
progress_message "Getting Capabilities on system $system..."
|
||||
if [ $g_family -eq 4 ]; then
|
||||
if ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
|
||||
if ! rsh_command "MODULESDIR=$MODULESDIR IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
|
||||
fatal_error "Capturing capabilities on system $system failed"
|
||||
fi
|
||||
elif ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
|
||||
elif ! rsh_command "MODULESDIR=$MODULESDIR IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
|
||||
fatal_error "Capturing capabilities on system $system failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
file=$(resolve_file $g_shorewalldir/firewall)
|
||||
|
||||
g_export=Yes
|
||||
|
||||
program=$sbindir/${PRODUCT}-lite
|
||||
#
|
||||
# Handle nonstandard remote VARDIR
|
||||
@@ -1728,6 +1793,7 @@ compiler_command() {
|
||||
compile_command $@
|
||||
;;
|
||||
refresh)
|
||||
only_root
|
||||
get_config Yes Yes
|
||||
shift
|
||||
refresh_command $@
|
||||
@@ -1749,11 +1815,13 @@ compiler_command() {
|
||||
export_command $@
|
||||
;;
|
||||
try)
|
||||
only_root
|
||||
get_config Yes
|
||||
shift
|
||||
try_command $@
|
||||
;;
|
||||
safe-reload|safe-restart|safe-start)
|
||||
only_root
|
||||
get_config Yes
|
||||
shift
|
||||
safe_commands $@
|
||||
|
@@ -791,11 +791,7 @@
|
||||
<title>See ALSO</title>
|
||||
|
||||
<para><ulink
|
||||
url="/Accounting.html">http://www.shorewall.net/Accounting.html
|
||||
</ulink></para>
|
||||
|
||||
<para><ulink
|
||||
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink></para>
|
||||
url="shorewall-logging.htm">shorewall-logging(5)</ulink></para>
|
||||
|
||||
<para><ulink
|
||||
url="/configuration_file_basics.htm#Pairs">http://www.shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
|
||||
|
@@ -191,6 +191,27 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>proto</option>=<replaceable>protocol</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 5.1.10. Specifies that the action is
|
||||
only usable with the specified
|
||||
<replaceable>protocol</replaceable> (name or number). When the
|
||||
action is invoked with no protocol specified in the PROTO
|
||||
column, or if the action is used as a Policy Action, the named
|
||||
<replaceable>protocol</replaceable> will be assumed. If a
|
||||
protocol is specified in the PROTO column of an invocation,
|
||||
then it must match the named
|
||||
<replaceable>protocol</replaceable>.</para>
|
||||
|
||||
<para>The <option>proto</option> option has no effect if the
|
||||
<option>inline</option> or <option>builtin</option> option is
|
||||
specified. A warning is issued if <option>proto</option> is
|
||||
specified along with <option>builtin</option>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>section</option></term>
|
||||
|
||||
|
@@ -167,7 +167,7 @@
|
||||
<listitem>
|
||||
<para>queues matching packets to a back end logging daemon via
|
||||
a netlink socket then continues to the next rule. See <ulink
|
||||
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -258,7 +258,7 @@
|
||||
<para>You may also specify <emphasis role="bold">NFLOG</emphasis>
|
||||
(must be in upper case) as a log level.This will log to the NFLOG
|
||||
target for routing to a separate log through use of ulogd (<ulink
|
||||
url="http://www.netfilter.org/projects/ulogd/index.html">http://www.netfilter.org/projects/ulogd/index.html</ulink>).</para>
|
||||
url="shorewall-logging.html">shorewall-logging.htm</ulink>).</para>
|
||||
|
||||
<para>Actions specifying logging may be followed by a log tag (a
|
||||
string of alphanumeric characters) which is appended to the string
|
||||
|
@@ -84,7 +84,7 @@
|
||||
role="bold">CT</emphasis>:<emphasis
|
||||
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis
|
||||
role="bold">CT:ctevents:<replaceable>event</replaceable>[,...]|CT:expevents:new</emphasis><emphasis
|
||||
role="bold">|CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IPTABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
|
||||
role="bold">|CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IP[6]TABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>This column is only present when FORMAT >= 2. Values other
|
||||
@@ -272,9 +272,32 @@
|
||||
will also be logged at that level.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>IP6TABLES</option>(<replaceable>target</replaceable>)</para>
|
||||
|
||||
<para>IPv6 only.</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.0. Allows you to specify any
|
||||
iptables <replaceable>target</replaceable> with target options
|
||||
(e.g., "IP6TABLES(AUDIT --type drop)"). If the target is not one
|
||||
recognized by Shorewall, the following error message will be
|
||||
issued:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>ERROR: Unknown target
|
||||
(<replaceable>target</replaceable>)</member>
|
||||
</simplelist>
|
||||
|
||||
<para>This error message may be eliminated by adding
|
||||
<replaceable>target</replaceable> as a builtin action in <ulink
|
||||
url="/manpages/shorewall-actions.html">shorewall-actions</ulink>(5).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>IPTABLES</option>(<replaceable>target</replaceable>)</para>
|
||||
|
||||
<para>IPv4 only.</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.0. Allows you to specify any
|
||||
iptables <replaceable>target</replaceable> with target options
|
||||
(e.g., "IPTABLES(AUDIT --type drop)"). If the target is not one
|
||||
@@ -447,7 +470,7 @@
|
||||
|
||||
<listitem>
|
||||
<para>This form combines the preceding two and requires that
|
||||
both the incoming interace and source address match.</para>
|
||||
both the incoming interface and source address match.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -543,7 +566,7 @@
|
||||
|
||||
<listitem>
|
||||
<para>This form combines the preceding two and requires that
|
||||
both the outgoing interace and destination address
|
||||
both the outgoing interface and destination address
|
||||
match.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -579,14 +602,23 @@
|
||||
|
||||
<listitem>
|
||||
<para>A protocol name from <filename>/etc/protocols</filename> or a
|
||||
protocol number.</para>
|
||||
protocol number. tcp and 6 may be optionally followed by <emphasis
|
||||
role="bold">:syn </emphasis>to match only the SYN packet (first
|
||||
packet in the three-way handshake).</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.5.12, this column is labeled
|
||||
<emphasis role="bold">PROTOS</emphasis> and can accept a
|
||||
comma-separated list of protocols. Either <emphasis
|
||||
<para>Beginning with Shorewall 4.5.12, this column can accept a
|
||||
comma-separated list of protocols and either <emphasis
|
||||
role="bold">proto</emphasis> or <emphasis
|
||||
role="bold">protos</emphasis> is accepted in the alternate input
|
||||
format.</para>
|
||||
|
||||
<para>Beginning with Shorewall 5.1.11, when <emphasis
|
||||
role="bold">tcp</emphasis> or <emphasis role="bold">6</emphasis> is
|
||||
specified and the ACTION is <emphasis role="bold">CT</emphasis>, the
|
||||
compiler will default to <emphasis role="bold">:syn</emphasis>. If
|
||||
you wish the rule to match packets with any valid combination of TCP
|
||||
flags, you may specify <emphasis role="bold">tcp:all</emphasis> or
|
||||
<emphasis role="bold">6:all</emphasis>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -112,7 +112,10 @@ loc eth2 -</programlisting>
|
||||
url="/manpages/shorewall-nesting.html">shorewall-nesting</ulink>(5)
|
||||
for a discussion of this problem.</para>
|
||||
|
||||
<para>Shorewall allows '+' as an interface name.</para>
|
||||
<para>Shorewall allows '+' as an interface name, but that usage is
|
||||
deprecated. A better approach is to specify
|
||||
'<option>physical</option>=+' in the OPTIONS column (see
|
||||
below).</para>
|
||||
|
||||
<para>There is no need to define the loopback interface (lo) in this
|
||||
file.</para>
|
||||
@@ -193,6 +196,54 @@ loc eth2 -</programlisting>
|
||||
should have no embedded white-space.</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">accept_ra</emphasis>[={0|1|2}]</term>
|
||||
|
||||
<listitem>
|
||||
<para>IPv6 only; added in Shorewall 4.5.16. Values are:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>0</term>
|
||||
|
||||
<listitem>
|
||||
<para>Do not accept Router Advertisements.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>1</term>
|
||||
|
||||
<listitem>
|
||||
<para>Accept Route Advertisements if forwarding is
|
||||
disabled.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>2</term>
|
||||
|
||||
<listitem>
|
||||
<para>Overrule forwarding behavior. Accept Route
|
||||
Advertisements even if forwarding is enabled.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>If the option is specified without a value, then the
|
||||
value 1 is assumed.</para>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">arp_filter[={0|1}]</emphasis></term>
|
||||
|
||||
@@ -209,12 +260,12 @@ loc eth2 -</programlisting>
|
||||
changed; the value assigned to the setting will be the value
|
||||
specified (if any) or 1 if no value is given.</para>
|
||||
|
||||
<para/>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card
|
||||
<replaceable>interface</replaceable> name (e.g., eth0.+) in
|
||||
the INTERFACE column.</para>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -243,16 +294,14 @@ loc eth2 -</programlisting>
|
||||
|
||||
<para>8 - do not reply for all local addresses</para>
|
||||
|
||||
<para/>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card
|
||||
<replaceable>interface</replaceable> name (e.g., eth0.+) in
|
||||
the INTERFACE column.</para>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
|
||||
<para/>
|
||||
|
||||
<warning>
|
||||
<para>Do not specify <emphasis
|
||||
role="bold">arp_ignore</emphasis> for any interface involved
|
||||
@@ -430,6 +479,25 @@ loc eth2 -</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">forward</emphasis>[={0|1}]</term>
|
||||
|
||||
<listitem>
|
||||
<para>IPv6 only Sets the
|
||||
/proc/sys/net/ipv6/conf/interface/forwarding option to the
|
||||
specified value. If no value is supplied, then 1 is
|
||||
assumed.</para>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ignore[=1]</emphasis></term>
|
||||
|
||||
@@ -496,9 +564,11 @@ loc eth2 -</programlisting>
|
||||
<para/>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card
|
||||
<replaceable>interface</replaceable> name (e.g., eth0.+) in
|
||||
the INTERFACE column.</para>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
|
||||
<blockquote>
|
||||
@@ -625,7 +695,10 @@ loc eth2 -</programlisting>
|
||||
|
||||
<para>If the <emphasis>interface</emphasis> name is a wildcard
|
||||
name (ends with '+'), then the physical
|
||||
<emphasis>name</emphasis> must also end in '+'.</para>
|
||||
<emphasis>name</emphasis> must also end in '+'. The physical
|
||||
<replaceable>name</replaceable> may end in '+' (or be exactly
|
||||
'+') when the <replaceable>interface</replaceable> name is not
|
||||
a wildcard name.</para>
|
||||
|
||||
<para>If <option>physical</option> is not specified, then it's
|
||||
value defaults to the <emphasis>interface</emphasis>
|
||||
@@ -647,9 +720,13 @@ loc eth2 -</programlisting>
|
||||
url="http://tldp.org/HOWTO/Proxy-ARP-Subnet/index.html">http://tldp.org/HOWTO/Proxy-ARP-Subnet/index.html.
|
||||
</ulink></para>
|
||||
|
||||
<para><emphasis role="bold">Note</emphasis>: This option does
|
||||
not work with a wild-card <replaceable>interface</replaceable>
|
||||
name (e.g., eth0.+) in the INTERFACE column.</para>
|
||||
<note>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
|
||||
<para>Only those interfaces with the <option>proxyarp</option>
|
||||
option will have their setting changed; the value assigned to
|
||||
@@ -665,9 +742,13 @@ loc eth2 -</programlisting>
|
||||
<para>IPv6 only. Sets
|
||||
/proc/sys/net/ipv6/conf/<emphasis>interface</emphasis>/proxy_ndp.</para>
|
||||
|
||||
<para><emphasis role="bold">Note</emphasis>: This option does
|
||||
not work with a wild-card <replaceable>interface</replaceable>
|
||||
name (e.g., eth0.+) in the INTERFACE column.</para>
|
||||
<note>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
|
||||
<para>Only those interfaces with the <option>proxyndp</option>
|
||||
option will have their setting changed; the value assigned to
|
||||
@@ -731,9 +812,11 @@ loc eth2 -</programlisting>
|
||||
filtering.</para>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card
|
||||
<replaceable>interface</replaceable> name (e.g., eth0.+) in
|
||||
the INTERFACE column.</para>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
|
||||
<para>This option can also be enabled globally via the
|
||||
@@ -842,9 +925,11 @@ loc eth2 -</programlisting>
|
||||
specified (if any) or 1 if no value is given.</para>
|
||||
|
||||
<note>
|
||||
<para>This option does not work with a wild-card
|
||||
<replaceable>interface</replaceable> name (e.g., eth0.+) in
|
||||
the INTERFACE column.</para>
|
||||
<para>This option does not work with a wild-card <emphasis
|
||||
role="bold">physical</emphasis> name (e.g., eth0.+).
|
||||
Beginning with Shorewall 5.1.10, If this option is
|
||||
specified, a warning is issued and the option is
|
||||
ignored.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
385
Shorewall/manpages/shorewall-logging.xml
Normal file
385
Shorewall/manpages/shorewall-logging.xml
Normal file
@@ -0,0 +1,385 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||
<refentry>
|
||||
<refmeta>
|
||||
<refentrytitle>shorewall-logging</refentrytitle>
|
||||
|
||||
<manvolnum>5</manvolnum>
|
||||
|
||||
<refmiscinfo>Configuration Files</refmiscinfo>
|
||||
</refmeta>
|
||||
|
||||
<refnamediv>
|
||||
<refname>logging</refname>
|
||||
|
||||
<refpurpose>Shorewall logging</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command><replaceable>action</replaceable>:<replaceable>level</replaceable></command>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>NFLOG(<replaceable>nflog-parameters</replaceable>)</command>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>ULOG(<replaceable>ulog-parameters</replaceable>)</command>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para>The disposition of packets entering a Shorewall firewall is
|
||||
determined by one of a number of Shorewall facilities. Only some of these
|
||||
facilities permit logging.</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>The packet is part of an established connection. While the
|
||||
packet can be logged using LOG rules in the ESTABLISHED section of
|
||||
<ulink
|
||||
url="manpages/shorewall-rules.html">/etc/shorewall/rules</ulink>, that
|
||||
is not recommended because of the large amount of information that may
|
||||
be logged.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The packet represents a connection request that is related to an
|
||||
established connection (such as a <ulink url="FTP.html">data
|
||||
connection associated with an FTP control connection</ulink>). These
|
||||
packets may be logged using LOG rules in the RELATED section of <ulink
|
||||
url="manpages/shorewall-rules.html">shorewall-rules(5)</ulink>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The packet is rejected because of an option in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf</ulink>(5) or <ulink
|
||||
url="manpages/shorewall-interfaces.html">shorewall-interfaces(5)</ulink>.
|
||||
These packets can be logged by setting the appropriate logging-related
|
||||
option in <ulink
|
||||
url="manpages/shorewall.conf.html">/etc/shorewall/shorewall.conf</ulink>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The packet matches a rule in <ulink
|
||||
url="manpages/shorewall-rules.html">shorewall-rules</ulink>(5). By
|
||||
including a syslog level (see below) in the ACTION column of a rule
|
||||
(e.g., <quote>ACCEPT<emphasis role="bold">:info</emphasis> net $FW tcp
|
||||
22</quote>), the connection attempt will be logged at that
|
||||
level.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The packet doesn't match a rule so it is handled by a policy
|
||||
defined in <ulink
|
||||
url="manpages/shorewall-policy.html">shorewall-policy(5)</ulink>.
|
||||
These may be logged by specifying a syslog level in the LOG LEVEL
|
||||
column of the policy's entry (e.g., <quote>loc net ACCEPT <emphasis
|
||||
role="bold">info</emphasis></quote>).</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Default Logging</title>
|
||||
|
||||
<para>By default, Shorewall directs Netfilter to log using syslog (8).
|
||||
Syslog classifies log messages by a <emphasis>facility</emphasis> and a
|
||||
<emphasis>priority</emphasis> (using the notation
|
||||
<emphasis>facility.priority</emphasis>).</para>
|
||||
|
||||
<para>The facilities defined by syslog are <emphasis>auth, authpriv, cron,
|
||||
daemon, kern, lpr, mail, mark, news, syslog, user, uucp</emphasis> and
|
||||
<emphasis>local0</emphasis> through <emphasis>local7.</emphasis></para>
|
||||
|
||||
<para>Throughout the Shorewall documentation, the term
|
||||
<emphasis>level</emphasis> rather than <emphasis>priority is used,
|
||||
</emphasis>since <emphasis>level</emphasis> is the term used by Netfilter.
|
||||
The syslog documentation uses the term
|
||||
<emphasis>priority</emphasis>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Syslog Levels</title>
|
||||
|
||||
<para>Syslog levels are a method of describing to syslog (8) the
|
||||
importance of a message. A number of Shorewall parameters have a syslog
|
||||
level as their value.</para>
|
||||
|
||||
<para>Valid levels are:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>7 - <emphasis role="bold">debug</emphasis> (Debug-level
|
||||
messages)</member>
|
||||
|
||||
<member>6 - <emphasis role="bold">info</emphasis>
|
||||
(Informational)</member>
|
||||
|
||||
<member>5 - <emphasis role="bold">notice</emphasis> (Normal but
|
||||
significant Condition)</member>
|
||||
|
||||
<member>4 - <emphasis role="bold">warning</emphasis> (Warning
|
||||
Condition)</member>
|
||||
|
||||
<member>3 - <emphasis role="bold">err</emphasis> (Error
|
||||
Condition)</member>
|
||||
|
||||
<member>2 - <emphasis role="bold">crit</emphasis> (Critical
|
||||
Conditions)</member>
|
||||
|
||||
<member>1 - <emphasis role="bold">alert</emphasis> (must be handled
|
||||
immediately)</member>
|
||||
|
||||
<member>0 - <emphasis role="bold">emerg</emphasis> (System is
|
||||
unusable)</member>
|
||||
</simplelist>
|
||||
|
||||
<para>For most Shorewall logging, a level of 6 (info) is appropriate.
|
||||
Shorewall log messages are generated by Netfilter and are logged using the
|
||||
<emphasis>kern</emphasis> facility and the level that you specify. If you
|
||||
are unsure of the level to choose, 6 (info) is a safe bet. You may specify
|
||||
levels by name or by number.</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.5.5, the <replaceable>level</replaceable>
|
||||
name or number may be optionally followed by a comma-separated list of one
|
||||
or more<replaceable> log options</replaceable>. The list is enclosed in
|
||||
parentheses. Log options cause additional information to be included in
|
||||
each log message.</para>
|
||||
|
||||
<para>Valid log options are:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ip_options</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Log messages will include the option settings from the IP
|
||||
header.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">macdecode</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Decode the MAC address and protocol.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">tcp_sequence</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Include TCP sequence numbers.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">tcp_options</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Include options from the TCP header.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">uid</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Include the UID of the sending program; only valid for packets
|
||||
originating on the firewall itself.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">info(tcp_options,tcp_sequence)</emphasis></para>
|
||||
|
||||
<para>Syslogd writes log messages to files (typically in <filename
|
||||
class="directory">/var/log/</filename>*) based on their facility and
|
||||
level. The mapping of these facility/level pairs to log files is done in
|
||||
/etc/syslog.conf (5). If you make changes to this file, you must restart
|
||||
syslogd before the changes can take effect.</para>
|
||||
|
||||
<para>Syslog may also write to your system console. See <ulink
|
||||
url="FAQ.htm#faq16">Shorewall FAQ 16</ulink> for ways to avoid having
|
||||
Shorewall messages written to the console.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Configuring a Separate Log for Shorewall Messages (ulogd)</title>
|
||||
|
||||
<para>There are a couple of limitations to syslogd-based logging:</para>
|
||||
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>If you give, for example, kern.info its own log destination then
|
||||
that destination will also receive all kernel messages of levels 5
|
||||
(notice) through 0 (emerg).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>All kernel.info messages will go to that destination and not
|
||||
just those from Netfilter.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Netfilter (Shorewall) messages show up in
|
||||
<command>dmesg</command>.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>If your kernel has NFLOG target support (and most vendor-supplied
|
||||
kernels do), you may also specify a log level of NFLOG (must be all caps).
|
||||
When NFLOG is used, Shorewall will direct Netfilter to log the related
|
||||
messages via the NFLOG target which will send them to a process called
|
||||
<quote>ulogd</quote>. The ulogd program is included in most
|
||||
distributions.</para>
|
||||
|
||||
<note>
|
||||
<para>The NFLOG logging mechanism is <emphasis
|
||||
role="underline">completely separate</emphasis> from syslog. Once you
|
||||
switch to NFLOG, the settings in <filename>/etc/syslog.conf</filename>
|
||||
have absolutely no effect on your Shorewall logging (except for
|
||||
Shorewall status messages which still go to syslog).</para>
|
||||
</note>
|
||||
|
||||
<para>You will need to change all instances of log levels (usually
|
||||
<quote>info</quote>) in your Shorewall configuration files to
|
||||
<quote>NFLOG</quote> - this includes entries in the policy, rules and
|
||||
shorewall.conf files. If you initially installed using Shorewall 5.1.2 or
|
||||
later, you can simply change the setting of LOG_LEVEL in
|
||||
shorewall.conf.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Understanding the Contents of Shorewall Log Messages</title>
|
||||
|
||||
<para>For general information on the contents of Netfilter log messages,
|
||||
see <ulink
|
||||
url="http://logi.cc/en/2010/07/netfilter-log-format/">http://logi.cc/en/2010/07/netfilter-log-format/</ulink>.</para>
|
||||
|
||||
<para>For Shorewall-specific information, see <ulink
|
||||
url="/FAQ.htm#faq17">FAQ #17</ulink>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Customizing the Content of Shorewall Log Messages</title>
|
||||
|
||||
<para>In a Shorewall logging rule, the log level can be followed by a
|
||||
<firstterm>log tag</firstterm> as in "DROP:NFLOG:junk". The generated log
|
||||
message will include "<emphasis>chain-name</emphasis> junk DROP".</para>
|
||||
|
||||
<para>By setting the LOGTAGONLY option to Yes in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink> or <ulink
|
||||
url="/manpages6/shorewall6.conf.html">shorewall6.conf(5)</ulink>, the
|
||||
disposition ('DROP' in the above example) will be omitted. Consider the
|
||||
following rule:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO
|
||||
REJECT(icmp-proto-unreachable):notice:IPv6 loc net 41 # who's using IPv6 tunneling</programlisting>
|
||||
|
||||
<para>This rule generates the following warning at compile time:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>WARNING: Log Prefix shortened to "Shorewall:IPv6:REJECT(icmp-p "
|
||||
/etc/shorewall/rules (line 212)</member>
|
||||
</simplelist>
|
||||
|
||||
<para>and produces the rather ugly prefix "Shorewall:IPv6:REJECT(icmp-p
|
||||
".</para>
|
||||
|
||||
<para>Now consider this similar rule:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO
|
||||
REJECT(icmp-proto-unreachable):notice:IPv6,tunneling loc net 41 # who's using IPv6 tunneling</programlisting>
|
||||
|
||||
<para>With LOGTAGONLY=Yes, no warning is generated and the prefix becomes
|
||||
"Shorewall:IPv6:tunneling:"</para>
|
||||
|
||||
<para>See the <ulink url="shorewall.conf.html">shorewall[6].conf man
|
||||
page</ulink> for further information about how LOGTAGONLY=Yes can be
|
||||
used.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Log Backends</title>
|
||||
|
||||
<para>Netfilter logging allows configuration of multiple backends. Logging
|
||||
backends provide the The low-level forward of log messages. There are
|
||||
currently three backends:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>LOG (ipt_LOG and ip6t_LOG).</term>
|
||||
|
||||
<listitem>
|
||||
<para>Normal kernel-based logging to a syslog daemon.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>ULOG (ipt_ULOG)</term>
|
||||
|
||||
<listitem>
|
||||
<para>ULOG logging as described ablve. Only available for
|
||||
IPv4.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>netlink (nfnetlink_log)</term>
|
||||
|
||||
<listitem>
|
||||
<para>The logging backend behind NFLOG, defined above.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>The currently-available and currently-selected IPv4 and IPv6
|
||||
backends are shown in /proc/sys/net/netfilter/nf_log:</para>
|
||||
|
||||
<programlisting>cat /proc/net/netfilter/nf_log
|
||||
0 NONE (nfnetlink_log)
|
||||
1 NONE (nfnetlink_log)
|
||||
2 ipt_ULOG (ipt_ULOG,ipt_LOG,nfnetlink_log)
|
||||
3 NONE (nfnetlink_log)
|
||||
4 NONE (nfnetlink_log)
|
||||
5 NONE (nfnetlink_log)
|
||||
6 NONE (nfnetlink_log)
|
||||
7 NONE (nfnetlink_log)
|
||||
8 NONE (nfnetlink_log)
|
||||
9 NONE (nfnetlink_log)
|
||||
10 ip6t_LOG (ip6t_LOG,nfnetlink_log)
|
||||
11 NONE (nfnetlink_log)
|
||||
12 NONE (nfnetlink_log)</programlisting>
|
||||
|
||||
<para>The magic numbers (0-12) are Linux address family numbers (AF_INET
|
||||
is 2 and AF_INET6 is 10).</para>
|
||||
|
||||
<para>The name immediately following the number is the currently-selected
|
||||
backend, and the ones in parentheses are the ones that are available. You
|
||||
can change the currently selected backend by echoing it's name into
|
||||
/proc/net/netfilter/nf_log.<replaceable>number</replaceable>.</para>
|
||||
|
||||
<para>Example - change the IPv4 backend to LOG:</para>
|
||||
|
||||
<programlisting>sysctl net.netfilter.nf_log.2=ipt_LOG</programlisting>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.4, you can configure the backend using
|
||||
the LOG_BACKEND option in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf(5)</ulink> and <ulink
|
||||
url="manpages6/shorewall6.conf.html">shorewall6.conf(5)</ulink>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>SEE ALSO</title>
|
||||
|
||||
<para><ulink
|
||||
url="/shorewall_logging.htm">http://www.shorewall.net/shorewall_logging.html</ulink></para>
|
||||
</refsect1>
|
||||
</refentry>
|
@@ -374,7 +374,8 @@ DIVERTHA - - tcp</programlisting>
|
||||
|
||||
<listitem>
|
||||
<para>Allows you to place your own ip[6]tables matches at the
|
||||
end of the line following a semicolon (";"). If an
|
||||
end of the line following two semicolons (";;") (preferred) or
|
||||
a single semicolon (";") (deprecated). If an
|
||||
<replaceable>action</replaceable> is specified, the compiler
|
||||
proceeds as if that <replaceable>action</replaceable> had been
|
||||
specified in this column. If no action is specified, then you
|
||||
@@ -391,22 +392,10 @@ DIVERTHA - - tcp</programlisting>
|
||||
|
||||
<programlisting>2:P eth0 - tcp 22
|
||||
INLINE(MARK(2)):P eth0 - tcp 22
|
||||
INLINE(MARK(2)):P eth0 - ; -p tcp
|
||||
INLINE eth0 - tcp 22 ; -j MARK --set-mark 2
|
||||
INLINE eth0 - ; -p tcp -j MARK --set-mark 2
|
||||
INLINE(MARK(2)):P eth0 - ;; -p tcp
|
||||
INLINE eth0 - tcp 22 ;; -j MARK --set-mark 2
|
||||
INLINE eth0 - ;; -p tcp -j MARK --set-mark 2
|
||||
</programlisting>
|
||||
|
||||
<para>If INLINE_MATCHES=Yes in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall6.conf(5)</ulink>
|
||||
then the third rule above can be specified as follows:</para>
|
||||
|
||||
<programlisting>MARK(2):P eth0 - ; -p tcp</programlisting>
|
||||
|
||||
<para>Beginning with Shorewall 5.0.0, the rule may also be
|
||||
written this way, irrespective of the setting of
|
||||
INLINE_MATCHES:</para>
|
||||
|
||||
<programlisting>MARK(2):P eth0 - ;; -p tcp</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -518,12 +507,39 @@ INLINE eth0 - ; -p tcp -j MARK --set
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">IP6TABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>IPv6 only.</para>
|
||||
|
||||
<para>This action allows you to specify an iptables target
|
||||
with options (e.g., 'IP6TABLES(MARK --set-xmark 0x01/0xff)'.
|
||||
If the target is not one recognized by Shorewall, the
|
||||
following error message will be issued:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>ERROR: Unknown target
|
||||
(<replaceable>target</replaceable>)</member>
|
||||
</simplelist>
|
||||
|
||||
<para>This error message may be eliminated by adding the
|
||||
<replaceable>target</replaceable> as a builtin action in
|
||||
<ulink
|
||||
url="/manpages/shorewall-actions.html">shorewall-actions(5)</ulink>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">IPTABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>IPv4 only.</para>
|
||||
|
||||
<para>This action allows you to specify an iptables target
|
||||
with options (e.g., 'IPTABLES(MARK --set-xmark 0x01/0xff)'. If
|
||||
the target is not one recognized by Shorewall, the following
|
||||
@@ -674,6 +690,43 @@ SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">TCPMSS</emphasis>([<replaceable>mss</replaceable>[,<replaceable>ipsec</replaceable>]])</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 5.1.9. This target only applies to
|
||||
TCP traffic and alters the MSS value in SYN packets. It may be
|
||||
used in the FORWARD and POSTROUTING chains; the default is
|
||||
FORWARD.</para>
|
||||
|
||||
<para>The <replaceable>mss</replaceable> parameter may be
|
||||
either <option>pmtu</option> or an integer in the range
|
||||
500:65533. The value <option>pmtu</option> automatically
|
||||
clamps the MSS value to (path_MTU - 40 for IPv4; -60 for
|
||||
IPv6). This may not function as desired where asymmetric
|
||||
routes with differing path MTU exist — the kernel uses the
|
||||
path MTU which it would use to send packets from itself to the
|
||||
source and destination IP addresses. Prior to Linux 2.6.25,
|
||||
only the path MTU to the destination IP address was considered
|
||||
by this option; subsequent kernels also consider the path MTU
|
||||
to the source IP address. If an integer is given, the MSS
|
||||
option is set to the specified value. If the MSS of the packet
|
||||
is already lower than <replaceable>mss</replaceable>, it will
|
||||
not be increased (from Linux 2.6.25 onwards) to avoid more
|
||||
problems with hosts relying on a proper MSS. If
|
||||
<replaceable>mss</replaceable> is omitted,
|
||||
<option>pmtu</option> is assumed.</para>
|
||||
|
||||
<para>The <replaceable>ipsec</replaceable> parameter
|
||||
determines whether the rule applies to IPSEC traffic
|
||||
(<option>ipsec</option> is passed), non-IPSEC traffic
|
||||
(<option>none</option> is passed) or both
|
||||
(<option>all</option> is passed). If omitted,
|
||||
<option>all</option> is assumed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">TOS</emphasis>(<replaceable>tos</replaceable>[/<replaceable>mask</replaceable>])</term>
|
||||
@@ -710,7 +763,7 @@ Normal-Service => 0x00</programlisting>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">TPROXY</emphasis>([<replaceable>port</replaceable>][,<replaceable>address</replaceable>])</term>
|
||||
role="bold">TPROXY</emphasis>([<replaceable>port</replaceable>[,<replaceable>address</replaceable>]])</term>
|
||||
|
||||
<listitem>
|
||||
<para>Transparently redirects a packet without altering the IP
|
||||
|
@@ -51,7 +51,7 @@
|
||||
|
||||
<para>The <replaceable>modulename</replaceable> names a kernel module
|
||||
(without suffix). Shorewall will search for modules based on your
|
||||
MODULESDIR and MODULE_SUFFIX settings in <ulink
|
||||
MODULESDIR setting in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(8). The
|
||||
<replaceable>moduleoption</replaceable>s are passed to modprobe (if
|
||||
installed) or to insmod.</para>
|
||||
|
@@ -279,8 +279,8 @@
|
||||
separate log through use of ulogd (<ulink
|
||||
url="http://www.netfilter.org/projects/ulogd/index.html">http://www.netfilter.org/projects/ulogd/index.html</ulink>).</para>
|
||||
|
||||
<para>For a description of log levels, see <ulink
|
||||
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
|
||||
<para>For a description of logging, see <ulink
|
||||
url="/shorewall_logging.html">shorewall-logging(5)</ulink>.</para>
|
||||
|
||||
<para>If you don't want to log but need to specify the following
|
||||
column, place "-" here.</para>
|
||||
|
@@ -84,7 +84,7 @@
|
||||
|
||||
<para>If PROVIDER_OFFSET is non-zero in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>, then
|
||||
the value must be a mutiple of 2^^PROVIDER_OFFSET. In all cases, the
|
||||
the value must be a multiple of 2^^PROVIDER_OFFSET. In all cases, the
|
||||
number of significant bits may not exceed PROVIDER_OFFSET +
|
||||
PROVIDER_BITS.</para>
|
||||
</listitem>
|
||||
@@ -220,7 +220,7 @@
|
||||
<para>In IPV6, the <option>balance</option> option does not
|
||||
cause balanced default routes to be created; it rather
|
||||
causes a sequence of default routes with different metrics
|
||||
to be created. </para>
|
||||
to be created.</para>
|
||||
</caution>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -438,6 +438,14 @@
|
||||
<command>enable</command> and <command>reenable</command>
|
||||
commands can reenable the provider.</para>
|
||||
</note>
|
||||
|
||||
<important>
|
||||
<para>RESTORE_DEFAULT_OPTION=Yes in shorewall[6].conf is not
|
||||
recommended when the <option>persistent</option> option is
|
||||
used, as restoring default routes to the main routing table
|
||||
can prevent link status monitors such as foolsm from
|
||||
correctly detecting non-working providers.</para>
|
||||
</important>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@@ -67,7 +67,7 @@
|
||||
this section.</para>
|
||||
|
||||
<para>The only ACTIONs allowed in this section are ACCEPT, DROP,
|
||||
REJECT, LOG, NFQUEUE and QUEUE</para>
|
||||
REJECT, LOG, NFLOG, NFQUEUE and QUEUE</para>
|
||||
|
||||
<para>There is an implicit ACCEPT rule inserted at the end of this
|
||||
section.</para>
|
||||
@@ -82,7 +82,7 @@
|
||||
section.</para>
|
||||
|
||||
<para>The only ACTIONs allowed in this section are ACCEPT, DROP,
|
||||
REJECT, LOG, NFQUEUE and QUEUE</para>
|
||||
REJECT, LOG, NFLOG, NFQUEUE and QUEUE</para>
|
||||
|
||||
<para>There is an implicit rule added at the end of this section
|
||||
that invokes the RELATED_DISPOSITION (<ulink
|
||||
@@ -98,7 +98,7 @@
|
||||
processed by rules in this section.</para>
|
||||
|
||||
<para>The only Actions allowed in this section are ACCEPT, DROP,
|
||||
REJECT, LOG, NFQUEUE and QUEUE.</para>
|
||||
REJECT, LOG, NFLOG, NFQUEUE and QUEUE.</para>
|
||||
|
||||
<para>There is an implicit rule added at the end of this section
|
||||
that invokes the INVALID_DISPOSITION (<ulink
|
||||
@@ -114,7 +114,7 @@
|
||||
processed by rules in this section.</para>
|
||||
|
||||
<para>The only Actions allowed in this section are ACCEPT, DROP,
|
||||
REJECT, LOG, NFQUEUE and QUEUE.</para>
|
||||
REJECT, LOG, NFLOG, NFQUEUE and QUEUE.</para>
|
||||
|
||||
<para>There is an implicit rule added at the end of this section
|
||||
that invokes the UNTRACKED_DISPOSITION (<ulink
|
||||
@@ -461,12 +461,13 @@
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.16. This action allows you to
|
||||
construct most of the rule yourself using iptables syntax. The
|
||||
part that you specify must follow a semicolon (';') and is
|
||||
part that you specify must follow two semicolons (';;')
|
||||
(preferred) or a single semicolon (';') (deprecated) and is
|
||||
completely free-form. If the target of the rule (the part
|
||||
following 'j') is something that Shorewall supports in the
|
||||
ACTION column, then you may enclose it in parentheses (e.g.,
|
||||
INLINE(ACCEPT)). Otherwise, you can include it after the
|
||||
semicolon. In this case, you must declare the target as a
|
||||
semicolon(s). In this case, you must declare the target as a
|
||||
builtin action in <ulink
|
||||
url="/manpages/shorewall-actions.html">shorewall-actions</ulink>(5).</para>
|
||||
|
||||
@@ -489,7 +490,7 @@
|
||||
necessarily be at the end of the generated rule. For
|
||||
example, if addresses are specified in the SOURCE and/or
|
||||
DEST columns, their generated matches will appear after
|
||||
those specified using ';'.</para>
|
||||
those specified using ';;' or ';'.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
@@ -908,7 +909,7 @@
|
||||
<para>IPv4 only. Added in Shorewall 4.5.10. Queues matching
|
||||
packets to a back end logging daemon via a netlink socket then
|
||||
continues to the next rule. See <ulink
|
||||
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.</para>
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>.</para>
|
||||
|
||||
<para>Similar to<emphasis role="bold">
|
||||
LOG:ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)],
|
||||
@@ -956,7 +957,7 @@
|
||||
(IPv4 only) or <emphasis role="bold">NFLOG</emphasis> (must be in
|
||||
upper case) as a log level.This will log to the ULOG or NFLOG target
|
||||
for routing to a separate log through use of ulogd (<ulink
|
||||
url="http://www.netfilter.org/projects/ulogd/index.html">http://www.netfilter.org/projects/ulogd/index.html</ulink>).</para>
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>).</para>
|
||||
|
||||
<para>Actions specifying logging may be followed by a log tag (a
|
||||
string of alphanumeric characters) which is appended to the string
|
||||
@@ -2636,15 +2637,15 @@
|
||||
<refsect1>
|
||||
<title>See ALSO</title>
|
||||
|
||||
<para><ulink
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink></para>
|
||||
|
||||
<para><ulink
|
||||
url="/ipsets.html">http://www.shorewall.net/ipsets.html</ulink></para>
|
||||
|
||||
<para><ulink
|
||||
url="/configuration_file_basics.htm#Pairs">http://www.shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
|
||||
|
||||
<para><ulink
|
||||
url="/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink></para>
|
||||
|
||||
<para>shorewall(8)</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@@ -52,12 +52,52 @@
|
||||
<term><emphasis role="bold">ACTION</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Defines the type of rule to generate. Choices are:</para>
|
||||
<para>Defines the type of rule to generate. Beginning with Shorewall
|
||||
5.1.9, with the exception of NFLOG and ULOG, the action may be
|
||||
followed by a colon (":") and a <replaceable>log level</replaceable>
|
||||
(see <ulink
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>).</para>
|
||||
|
||||
<para>Choices for ACTION are:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">MASQUERADE[+]</emphasis>[([<replaceable>lowport</replaceable>-<replaceable>highport</replaceable>][<option>random</option>])]</term>
|
||||
role="bold"><replaceable>action</replaceable></emphasis>[+][(<replaceable>parameter</replaceable>,...)][:<replaceable>level</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>action</replaceable> is an action
|
||||
declared in <ulink
|
||||
url="/manpages/shorewall-actions.html">shorewall-actions(5)</ulink>
|
||||
with the <option>nat</option> option. See <ulink
|
||||
url="/Actions.html">www.shorewall.net/Actions.html</ulink> for
|
||||
further information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">CONTINUE</emphasis>[+]:<replaceable>level</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes matching packets to be exempted from any
|
||||
following rules in the file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">LOG:<replaceable>level</replaceable></emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 5.1.9. Simply log the packet and
|
||||
continue with the next rule.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">MASQUERADE[+]</emphasis>[([<replaceable>lowport</replaceable>[-<replaceable>highport</replaceable>]][<option>random</option>])][:<replaceable>level</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes matching outgoing packages to have their source
|
||||
@@ -65,20 +105,61 @@
|
||||
specified in the DEST column. if
|
||||
<replaceable>lowport</replaceable>-<replaceable>highport</replaceable>
|
||||
is given, that port range will be used to assign a source
|
||||
port. If option <option>random</option> is used then port
|
||||
mapping will be randomized. MASQUERADE should only be used
|
||||
when the DEST interface has a dynamic IP address. Otherwise,
|
||||
SNAT should be used and should specify the interface's static
|
||||
address.</para>
|
||||
port. If only <replaceable>lowport</replaceable> is given,
|
||||
that port will be assigned, if possible. If option
|
||||
<option>random</option> is used then port mapping will be
|
||||
randomized. MASQUERADE should only be used when the DEST
|
||||
interface has a dynamic IP address. Otherwise, SNAT should be
|
||||
used and should specify the interface's static address.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">NFLOG</emphasis>[(<replaceable>nflog-parameters</replaceable>)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 5.1.9. Queues matching packets to a
|
||||
back end logging daemon via a netlink socket then continues to
|
||||
the next rule. See <ulink
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>.</para>
|
||||
|
||||
<para>The <replaceable>nflog-parameters</replaceable> are a
|
||||
comma-separated list of up to 3 numbers:</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The first number specifies the netlink group
|
||||
(0-65535). If omitted (e.g., NFLOG(,0,10)) then a value of
|
||||
0 is assumed.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The second number specifies the maximum number of
|
||||
bytes to copy. If omitted, 0 (no limit) is assumed.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>The third number specifies the number of log
|
||||
messages that should be buffered in the kernel before they
|
||||
are sent to user space. The default is 1.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>NFLOG is similar to<emphasis role="bold">
|
||||
LOG:NFLOG</emphasis>[(<replaceable>nflog-parameters</replaceable>)],
|
||||
except that the log level is not changed when this ACTION is
|
||||
used in an action or macro body and the invocation of that
|
||||
action or macro specifies a log level.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">SNAT[+]</emphasis>([<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
||||
role="bold">[-</emphasis><emphasis>highport</emphasis>]][<emphasis
|
||||
role="bold">:random</emphasis>][:<option>persistent</option>]|<emphasis
|
||||
role="bold">detect</emphasis>|</term>
|
||||
role="bold">detect</emphasis>)[:<replaceable>level</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>If you specify an address here, matching packets will
|
||||
@@ -129,29 +210,27 @@
|
||||
|
||||
<programlisting> 192.0.2.4:5000-6000
|
||||
:4000-5000</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">CONTINUE</emphasis>[+]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes matching packets to be exempted from any
|
||||
following rules in the file.</para>
|
||||
<para>You may also specify a single port number, which will be
|
||||
assigned to the outgoing connection, if possible.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold"><replaceable>action</replaceable></emphasis>[+][(<replaceable>parameter</replaceable>,...)]</term>
|
||||
role="bold">ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>action</replaceable> is an action
|
||||
declared in <ulink
|
||||
url="/manpages/shorewall-actions.html">shorewall-actions(5)</ulink>
|
||||
with the <option>nat</option> option. See <ulink
|
||||
url="/Actions.html">www.shorewall.net/Actions.html</ulink> for
|
||||
further information.</para>
|
||||
<para>IPv4 only. Added in Shorewall 5.1.9. Queues matching
|
||||
packets to a back end logging daemon via a netlink socket then
|
||||
continues to the next rule. See <ulink
|
||||
url="shorewall-logging.html">shorewall-logging(5)</ulink>.</para>
|
||||
|
||||
<para>Similar to<emphasis role="bold">
|
||||
LOG:ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)],
|
||||
except that the log level is not changed when this ACTION is
|
||||
used in an action or macro body and the invocation of that
|
||||
action or macro specifies a log level.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
@@ -174,10 +253,10 @@
|
||||
<listitem>
|
||||
<para>Set of hosts that you wish to masquerade. You can specify this
|
||||
as an <emphasis>address</emphasis> (net or host) or as an
|
||||
<emphasis>interface</emphasis> (use of an
|
||||
<emphasis>interface</emphasis> is deprecated). If you give the name
|
||||
of an interface, the interface must be up before you start the
|
||||
firewall and the Shorewall rules compiler will warn you of that
|
||||
<emphasis>interface</emphasis>. Unless you want to perform SNAT in
|
||||
the INPUT chain (see DEST below), if you give the name of an
|
||||
interface (deprecated), the interface must be up before you start
|
||||
the firewall and the Shorewall rules compiler will warn you of that
|
||||
fact. (Shorewall will use your main routing table to determine the
|
||||
appropriate addresses to masquerade).</para>
|
||||
|
||||
@@ -188,15 +267,18 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">DEST</emphasis> - {[<emphasis
|
||||
role="bold">+</emphasis>]<emphasis>interface</emphasis>[<emphasis
|
||||
role="bold">:</emphasis>[<emphasis>digit</emphasis>]][<emphasis
|
||||
<term><emphasis role="bold">DEST</emphasis> -
|
||||
{<emphasis>interface</emphasis>[<emphasis
|
||||
role="bold">:</emphasis><emphasis>digit][,</emphasis><emphasis>interface</emphasis>[<emphasis
|
||||
role="bold">:</emphasis><emphasis>digit</emphasis>]]...|$FW}[<emphasis
|
||||
role="bold">:</emphasis>[<emphasis>dest-address</emphasis>[<emphasis
|
||||
role="bold">,</emphasis><emphasis>dest-address</emphasis>]...[<emphasis>exclusion</emphasis>]]}</term>
|
||||
role="bold">,</emphasis><emphasis>dest-address</emphasis>]...[<emphasis>exclusion</emphasis>]]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Outgoing <emphasis>interface</emphasis>. This is usually your
|
||||
internet interface. If ADD_SNAT_ALIASES=Yes in <ulink
|
||||
<para>Outgoing <emphasis>interface</emphasis>s and destination
|
||||
networks. Multiple interfaces may be listed when the ACTION is
|
||||
MASQUERADE, but this is usually just your internet interface. If
|
||||
ADD_SNAT_ALIASES=Yes in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5), you
|
||||
may add ":" and a <emphasis>digit</emphasis> to indicate that you
|
||||
want the alias added with that name (e.g., eth0:0). This will allow
|
||||
@@ -204,6 +286,10 @@
|
||||
is the only use for the alias name; it may not appear in any other
|
||||
place in your Shorewall configuration.</emphasis></para>
|
||||
|
||||
<para>Beginning with Shorewall 5.1.12, SNAT may be performed in the
|
||||
nat table's INPUT chain by specifying $FW rather than one or more
|
||||
interfaces. </para>
|
||||
|
||||
<para>Each interface must match an entry in <ulink
|
||||
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
||||
Shorewall allows loose matches to wildcard entries in <ulink
|
||||
@@ -673,7 +759,7 @@
|
||||
address changed to 206.124.146.177.</para>
|
||||
|
||||
<programlisting> #ACTION SOURCE DEST
|
||||
SNAT(206.124.146.177) - eth0+myset[dst]</programlisting>
|
||||
SNAT(206.124.146.177) - eth0:+myset[dst]</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -160,7 +160,9 @@
|
||||
how often the rate is estimated and how many samples are retained
|
||||
for estimating. Please see <ulink
|
||||
url="http://ace-host.stuart.id.au/russell/files/tc/doc/estimators.txt">http://ace-host.stuart.id.au/russell/files/tc/doc/estimators.txt</ulink>
|
||||
for details.</para>
|
||||
for details. If not specified, the default
|
||||
<replaceable>interval</replaceable> is 250ms and the default
|
||||
<replaceable>decay_interval</replaceable> is 4sec.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -172,7 +172,9 @@
|
||||
how often the rate is estimated and how many samples are retained
|
||||
for estimating. Please see <ulink
|
||||
url="http://ace-host.stuart.id.au/russell/files/tc/doc/estimators.txt">http://ace-host.stuart.id.au/russell/files/tc/doc/estimators.txt</ulink>
|
||||
for details.</para>
|
||||
for details. If not specified, the default
|
||||
<replaceable>interval</replaceable> is 250ms and the default
|
||||
<replaceable>decay_interval</replaceable> is 4sec.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -107,7 +107,7 @@
|
||||
<simplelist>
|
||||
<member>2 + 6 + 2*M + 1 = 29</member>
|
||||
|
||||
<member>2M = 29 - 2 + 6 + 1 = 20</member>
|
||||
<member>2M = 29 - 2 - 6 - 1 = 20</member>
|
||||
|
||||
<member>M = 10</member>
|
||||
</simplelist>
|
||||
|
@@ -565,13 +565,12 @@
|
||||
respectively and were added in Shorewall 4.4.20. They require
|
||||
AUDIT_TARGET in the kernel and iptables.</para>
|
||||
|
||||
<para>The BLACKLIST_DISPOSITION setting has no effect on entries in
|
||||
the BLACKLIST section of <ulink
|
||||
url="/manpages/shorewall-rules.html">shorewall-rules</ulink> (5). It
|
||||
determines the disposition of packets sent to the <emphasis
|
||||
role="bold">blacklog</emphasis> target of <ulink
|
||||
<para>The BLACKLIST_DISPOSITION setting determines the disposition
|
||||
of packets sent to the <emphasis role="bold">blacklog</emphasis>
|
||||
target of <ulink
|
||||
url="/manpages/shorewall-blrules.html">shorewall-blrules
|
||||
</ulink>(5).</para>
|
||||
</ulink>(5), but otherwise does not affect entries in that
|
||||
file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -673,7 +672,7 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">CONFIG_PATH</emphasis>=[<emphasis>directory</emphasis>[:<emphasis>directory</emphasis>]...]</term>
|
||||
role="bold">CONFIG_PATH</emphasis>=[[:]<emphasis>directory</emphasis>[:<emphasis>directory</emphasis>]...]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Specifies where configuration files other than
|
||||
@@ -701,6 +700,16 @@
|
||||
/etc/shorewall:/usr/share/shorewall but your particular distribution
|
||||
may set it differently. See the output of shorewall show config for
|
||||
the default on your system.</para>
|
||||
|
||||
<para>Beginning with Shorewall 5.1.10, the CONFIG_PATH setting may
|
||||
begin with a colon (":"), to signal that the first
|
||||
<replaceable>directory</replaceable> listed will be skipped if the
|
||||
user performing a compilation is not root or if the configuration is
|
||||
being compiled for export (-e option specified or if running one of
|
||||
the remote-* commands) . This prevents the compiler from looking in
|
||||
<filename>/etc/shorewall[6]</filename>/ when compilation is being
|
||||
done by a non-root user or if the generated script is to be sent to
|
||||
a remote firewall system.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -720,6 +729,14 @@
|
||||
and <command>restart</command> commands will succeed even if no DNS
|
||||
server is reachable (assuming that the configuration hasn't changed
|
||||
since the compiled script was last generated).</para>
|
||||
|
||||
<important>
|
||||
<para>When DEFER_DNS_RESOLUTION=No and AUTOMAKE=Yes and a DNS
|
||||
change makes it necessary to recompile an existing firewall
|
||||
script, the <option>-c</option> option must be used with the
|
||||
<command>reload</command> or <command>restart</command> command to
|
||||
force recompilation.</para>
|
||||
</important>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1566,10 +1583,9 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
log</emphasis>, and <emphasis role="bold">hits</emphasis> commands.
|
||||
If not assigned or if assigned an empty value, /var/log/messages is
|
||||
assumed. For further information, see <ulink
|
||||
url="/manpages/shorewall_logging.html">http://www.shorewall.net/shorewall_logging.html</ulink>.
|
||||
Beginning with Shorewall 5.0.10.1, you may specify
|
||||
<option>systemd</option> to use <command>journelctl -r</command> to
|
||||
read the log.</para>
|
||||
url="shorewall-logging.html">shorewall-logging(8)</ulink>. Beginning
|
||||
with Shorewall 5.0.10.1, you may specify <option>systemd</option> to
|
||||
use <command>journelctl -r</command> to read the log.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1892,18 +1908,6 @@ LOG:info:,bar net fw</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">MODULE_SUFFIX=</emphasis>[<emphasis
|
||||
role="bold">"</emphasis><emphasis>extension</emphasis> ...<emphasis
|
||||
role="bold">"</emphasis>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>The value of this option determines the possible file
|
||||
extensions of kernel modules. The default value is "ko ko.gz ko.xz o
|
||||
o.gz o.xz gz xz".</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">MODULESDIR=</emphasis>[[+]<emphasis>pathname</emphasis>[<emphasis
|
||||
@@ -2143,6 +2147,14 @@ LOG:info:,bar net fw</programlisting>
|
||||
<para>Optimization category 8 - Added in Shorewall 4.4.9. When
|
||||
set, causes chains with identical rules to be collapsed into a
|
||||
single chain.</para>
|
||||
|
||||
<warning>
|
||||
<para>While Optimization category 8 can significantly reduce
|
||||
the size of the generated iptables ruleset, it can also take
|
||||
significant system resources during compilation. If you find
|
||||
that compilation takes an unreasonably long time, try
|
||||
disabling this category by setting OPTIMIZE=23.</para>
|
||||
</warning>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
@@ -2215,7 +2227,8 @@ LOG:info:,bar net fw</programlisting>
|
||||
|
||||
<para>In versions prior to 5.1.0, the default value is zero which
|
||||
disables all optimizations. Beginning with Shorewall 5.1.0, the
|
||||
default value is All which enables all optimizations.</para>
|
||||
default value is <emphasis role="bold">All</emphasis> which enables
|
||||
all optimizations.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Script to back uninstall Shoreline Firewall
|
||||
#
|
||||
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000-2017 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
#
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#
|
||||
# On the target system (the system where the firewall program is to run):
|
||||
#
|
||||
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities
|
||||
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
|
||||
#
|
||||
# Now move the capabilities file to the compilation system. The file must
|
||||
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
|
||||
@@ -38,7 +38,6 @@
|
||||
#
|
||||
# IPTABLES - iptables
|
||||
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
|
||||
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
|
||||
#
|
||||
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
|
||||
# used during firewall compilation, then the generated firewall program will likewise not
|
||||
|
@@ -1,82 +0,0 @@
|
||||
# Shorewall6 Packet Filtering Firewall Export Directory Makefile - V4.2
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of Version 2 of the GNU General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# 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, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
################################################################################
|
||||
# Place this file in each export directory. Modify each copy to set HOST
|
||||
# to the name of the remote firewall corresponding to the directory.
|
||||
#
|
||||
# To make the 'firewall' script, type "make".
|
||||
#
|
||||
# Once the script is compiling correctly, you can install it by
|
||||
# typing "make install".
|
||||
#
|
||||
################################################################################
|
||||
# V A R I A B L E S
|
||||
#
|
||||
# Files in the export directory on which the firewall script does not depend
|
||||
#
|
||||
IGNOREFILES = firewall% Makefile% trace% %~
|
||||
#
|
||||
# Remote Firewall system
|
||||
#
|
||||
HOST = gateway
|
||||
#
|
||||
# Save some typing
|
||||
#
|
||||
LITEDIR = /var/lib/shorewall6-lite
|
||||
#
|
||||
# Set this if the remote system has a non-standard modules directory
|
||||
#
|
||||
MODULESDIR=
|
||||
#
|
||||
# Default target is the firewall script
|
||||
#
|
||||
################################################################################
|
||||
# T A R G E T S
|
||||
#
|
||||
all: firewall
|
||||
#
|
||||
# Only generate the capabilities file if it doesn't already exist
|
||||
#
|
||||
capabilities:
|
||||
ssh root@$(HOST) "MODULESDIR=$(MODULESDIR) /usr/share/shorewall6-lite/shorecap > $(LITEDIR)/capabilities"
|
||||
scp root@$(HOST):$(LITEDIR)/capabilities .
|
||||
#
|
||||
# Compile the firewall script. Using the 'wildcard' function causes "*" to be expanded so that
|
||||
# 'filter-out' will be presented with the list of files in this directory rather than "*"
|
||||
#
|
||||
firewall: $(filter-out $(IGNOREFILES) capabilities , $(wildcard *) ) capabilities
|
||||
shorewall6 compile -e . firewall
|
||||
#
|
||||
# Only reload on demand.
|
||||
#
|
||||
install: firewall
|
||||
scp firewall firewall.conf root@$(HOST):$(LITEDIR)
|
||||
ssh root@$(HOST) "/sbin/shorewall6-lite restart"
|
||||
#
|
||||
# Save running configuration
|
||||
#
|
||||
save:
|
||||
ssh root@$(HOST) "/sbin/shorewall6-lite save"
|
||||
#
|
||||
# Remove generated files
|
||||
#
|
||||
clean:
|
||||
rm -f capabilities firewall firewall.conf reload
|
@@ -11,5 +11,5 @@
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
- lo ignore
|
||||
net all dhcp,physical=+,routeback,sourceroute=0
|
||||
net all dhcp,physical=+,routeback
|
||||
|
||||
|
@@ -74,7 +74,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
|
||||
###############################################################################
|
||||
|
||||
CONFIG_PATH=${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall6:${SHAREDIR}/shorewall6:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -170,7 +170,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MINIUPNPD=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
OPTIMIZE=All
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall6 version 5 - Sample Interfaces File for one-interface configuration.
|
||||
# Copyright (C) 2006-2015 by the Shorewall Team
|
||||
# Shorewall6 - Sample Interfaces File for one-interface configuration.
|
||||
# Copyright (C) 2006-2017 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -14,4 +14,4 @@
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
net eth0 tcpflags
|
||||
net NET_IF tcpflags,physical=eth0
|
||||
|
@@ -75,7 +75,7 @@ UNTRACKED_LOG_LEVEL=
|
||||
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
|
||||
###############################################################################
|
||||
|
||||
CONFIG_PATH="${CONFDIR}/shorewall6:/usr/share/shorewall6:${SHAREDIR}/shorewall"
|
||||
CONFIG_PATH=":${CONFDIR}/shorewall6:/usr/share/shorewall6:${SHAREDIR}/shorewall"
|
||||
|
||||
GEOIPDIR=/usr/share/xt_geoip/LE
|
||||
|
||||
@@ -171,7 +171,7 @@ IGNOREUNKNOWNVARIABLES=No
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
@@ -191,8 +191,6 @@ MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MINIUPNPD=No
|
||||
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
OPTIMIZE=All
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user