forked from extern/shorewall_code
Compare commits
227 Commits
4.6.4.1
...
4.6.10-bas
Author | SHA1 | Date | |
---|---|---|---|
|
9a3c43b6d3 | ||
|
0a45c7a646 | ||
|
f227250959 | ||
|
29a0c92918 | ||
|
cfc6b7405f | ||
|
4edd6026f0 | ||
|
f629d574e6 | ||
|
18348ef6f1 | ||
|
93c7e2c2f7 | ||
|
602315938c | ||
|
f3d32e0023 | ||
|
19ab4472c9 | ||
|
425094de18 | ||
|
ca35f565e0 | ||
|
bbdbdf7c47 | ||
|
631ebdecb8 | ||
|
c851e03313 | ||
|
df4d6f1f92 | ||
|
c7ca3119ef | ||
|
ba7afcaeae | ||
|
809e56cef6 | ||
|
e3805b0ada | ||
|
f1b6e71e56 | ||
|
f77d649ac7 | ||
|
267637f139 | ||
|
acd921cd08 | ||
|
9329e7c36c | ||
|
86ef3d3e35 | ||
|
cccf6b4657 | ||
|
7195ee708e | ||
|
50d1a719f9 | ||
|
4b27c72c79 | ||
|
548c0558c1 | ||
|
7a9270136c | ||
|
a508bcf6d7 | ||
|
3bb1f74283 | ||
|
87eca92b10 | ||
|
b58aadad01 | ||
|
6dcd8174ee | ||
|
fe37844455 | ||
|
e248c0a3d7 | ||
|
3f17a8cf24 | ||
|
2cea78e6df | ||
|
0abd51c796 | ||
|
86e053be7a | ||
|
864dba2e62 | ||
|
75d18139f7 | ||
|
bebb41674a | ||
|
42f75f7ba2 | ||
|
2c9b7fbb07 | ||
|
119299421f | ||
|
aef019e16d | ||
|
3ae243b882 | ||
|
0fc58f81cc | ||
|
7db99832ca | ||
|
0e8b427778 | ||
|
ccccd847c8 | ||
|
6cb3004a39 | ||
|
f5aa0373cb | ||
|
057ad45fd9 | ||
|
ade24e6299 | ||
|
65394b9f8c | ||
|
b128c30813 | ||
|
194252afd3 | ||
|
3cb45f234e | ||
|
16e3cb1b43 | ||
|
27c1ffc5fb | ||
|
23137e5e8a | ||
|
0e54a86e82 | ||
|
4fd8aa692d | ||
|
8c3dda80a3 | ||
|
9f96f58a0d | ||
|
77165326f2 | ||
|
eb3a162560 | ||
|
a8026999a5 | ||
|
44142ed457 | ||
|
659e9d550c | ||
|
7442c2189d | ||
|
551be3ed39 | ||
|
468167f9e5 | ||
|
6921270c77 | ||
|
50bbf9499a | ||
|
b00a7af619 | ||
|
0c11870e46 | ||
|
fdc36747ad | ||
|
79d8d73e02 | ||
|
ecaae1f644 | ||
|
52e7efc666 | ||
|
c5ef3fd905 | ||
|
86d6d6900e | ||
|
9a5cc5e51c | ||
|
d7a1ca41f9 | ||
|
d3552346b0 | ||
|
1e6c266b51 | ||
|
d6f8cda2d5 | ||
|
4cc866cd81 | ||
|
095e523c9f | ||
|
2817060edb | ||
|
30e750608b | ||
|
a85fdc45ac | ||
|
79b6b7cf08 | ||
|
5f2a8dd9cb | ||
|
a28cd7371c | ||
|
e9bb447537 | ||
|
cdc2d52208 | ||
|
18c8f1f835 | ||
|
aff8623a44 | ||
|
361f5af3e0 | ||
|
b14e7c54f9 | ||
|
30a5f508be | ||
|
9ad0b297e2 | ||
|
40104d0c86 | ||
|
5d110616a5 | ||
|
a2b8069ee3 | ||
|
c7cd0060f0 | ||
|
e3b96862ef | ||
|
a060f683cc | ||
|
01220d58ea | ||
|
c2b6d974e7 | ||
|
7ab055e61e | ||
|
758f3cf955 | ||
|
08a184d95b | ||
|
50a0103e89 | ||
|
6f2308e0fa | ||
|
a7cacdfee3 | ||
|
28ac76bde4 | ||
|
83431514fb | ||
|
111c454193 | ||
|
b06ba536e9 | ||
|
3f32afe371 | ||
|
740e19968b | ||
|
97846e14de | ||
|
07c21b8968 | ||
|
668759edad | ||
|
0f1f54b57b | ||
|
60d5a177a3 | ||
|
3ed5ced581 | ||
|
086f8b6073 | ||
|
fa377df9dc | ||
|
7dd9ccd06b | ||
|
33e2e19193 | ||
|
4a4bfe77ce | ||
|
3890b8a884 | ||
|
551a16d18f | ||
|
d1b597394f | ||
|
15a2fd14f9 | ||
|
f96baca780 | ||
|
1b5f439609 | ||
|
1655054de2 | ||
|
89877ed3f7 | ||
|
9649107a8e | ||
|
33eb47a48a | ||
|
93285e2798 | ||
|
2430796495 | ||
|
06ef7596cd | ||
|
227db0cfa7 | ||
|
c0f7d0e65d | ||
|
ba806379f4 | ||
|
6a15cead52 | ||
|
f925358872 | ||
|
52d2e62274 | ||
|
56e8068f3d | ||
|
35fc7b34b8 | ||
|
fdf513fba6 | ||
|
79430673b8 | ||
|
695db284c0 | ||
|
807b9ca627 | ||
|
62f480897e | ||
|
685825a336 | ||
|
8edb86ccdd | ||
|
2d7025dcc3 | ||
|
23e869ad50 | ||
|
a833815b31 | ||
|
664e3bb0a8 | ||
|
3a64ef7d3a | ||
|
b746c9319f | ||
|
6f81bb5c8e | ||
|
9241552c52 | ||
|
16c1809ef2 | ||
|
ec0ff7f305 | ||
|
7100af5380 | ||
|
f9932d2b08 | ||
|
2bf80ee3d9 | ||
|
22ac37b51e | ||
|
c4171a92f6 | ||
|
a5b2886ae9 | ||
|
9a6047b3c4 | ||
|
6f5de7ef3f | ||
|
5b4e3bc07c | ||
|
dc3f163e71 | ||
|
2f545012a6 | ||
|
c97226c46c | ||
|
8c0c1bd1e0 | ||
|
8b825c4c4c | ||
|
4493b2ab6b | ||
|
9598ac6fad | ||
|
8fb73026c8 | ||
|
4546cbaff7 | ||
|
a83c146636 | ||
|
2ffc97867c | ||
|
f08803e293 | ||
|
b7ab82dba4 | ||
|
113f95c11e | ||
|
3454e10525 | ||
|
edc30fcc8d | ||
|
85e5669fc7 | ||
|
055fceb82f | ||
|
f5bdc9e7f4 | ||
|
54461a9a90 | ||
|
b60d6dd6e5 | ||
|
4bc91e89db | ||
|
2784e93307 | ||
|
90d1e41dcb | ||
|
20c8bf02b1 | ||
|
38d4b1c5a9 | ||
|
e3a332ec27 | ||
|
49218a4d28 | ||
|
3236cd2660 | ||
|
e3b10343a5 | ||
|
286bc50bb3 | ||
|
a5086f785f | ||
|
19482ac197 | ||
|
42363da458 | ||
|
c5074bddb2 | ||
|
4b9d8ad5f6 | ||
|
12458d111a | ||
|
815e93e80c |
6
Shorewall-core/configure
vendored
6
Shorewall-core/configure
vendored
@@ -195,6 +195,10 @@ elif [ -n "${options[VARDIR]}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${options[SERVICEDIR]}" ]; then
|
||||
options[SERVICEDIR]="${options[SYSTEMD]}"
|
||||
fi
|
||||
|
||||
for on in \
|
||||
HOST \
|
||||
PREFIX \
|
||||
@@ -209,7 +213,7 @@ for on in \
|
||||
INITFILE \
|
||||
AUXINITSOURCE \
|
||||
AUXINITFILE \
|
||||
SYSTEMD \
|
||||
SERVICEDIR \
|
||||
SERVICEFILE \
|
||||
SYSCONFFILE \
|
||||
SYSCONFDIR \
|
||||
|
@@ -154,6 +154,8 @@ if ( $options{VARLIB} ) {
|
||||
$options{VARDIR} = '${VARLIB}/${PRODUCT}';
|
||||
}
|
||||
|
||||
$options{SERVICEDIR}=$options{SYSTEMD} unless $options{SERVICEDIR};
|
||||
|
||||
for ( qw/ HOST
|
||||
PREFIX
|
||||
SHAREDIR
|
||||
@@ -167,8 +169,8 @@ for ( qw/ HOST
|
||||
INITFILE
|
||||
AUXINITSOURCE
|
||||
AUXINITFILE
|
||||
SYSTEMD
|
||||
SERVICEFILE
|
||||
SERVICEDIR
|
||||
SERVICEFILE
|
||||
SYSCONFFILE
|
||||
SYSCONFDIR
|
||||
SPARSE
|
||||
|
@@ -329,9 +329,13 @@ if [ -n "${SYSCONFDIR}" ]; then
|
||||
chmod 755 ${DESTDIR}${SYSCONFDIR}
|
||||
fi
|
||||
|
||||
if [ -n "${SYSTEMD}" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
chmod 755 ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "${SERVICEDIR}" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
chmod 755 ${DESTDIR}${SERVICEDIR}
|
||||
fi
|
||||
|
||||
mkdir -p ${DESTDIR}${SBINDIR}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
# loaded after this one and replaces some of the functions declared here.
|
||||
#
|
||||
|
||||
SHOREWALL_CAPVERSION=40600
|
||||
SHOREWALL_CAPVERSION=40609
|
||||
|
||||
[ -n "${g_program:=shorewall}" ]
|
||||
|
||||
@@ -42,16 +42,6 @@ fi
|
||||
|
||||
. ${SHAREDIR}/shorewall/lib.base
|
||||
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue an error message and die
|
||||
#
|
||||
@@ -375,7 +365,18 @@ savesets() {
|
||||
|
||||
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
|
||||
|
||||
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${g_restorepath}-ipsets
|
||||
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${g_restorepath}-ipsets
|
||||
}
|
||||
|
||||
#
|
||||
# Proactive save of the current ipset contents
|
||||
#
|
||||
savesets1() {
|
||||
local supported
|
||||
|
||||
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
|
||||
|
||||
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${VARDIR}/ipsets.save && progress_message3 "The ipsets have been saved to ${VARDIR}/ipsets.save"
|
||||
}
|
||||
|
||||
#
|
||||
@@ -387,7 +388,7 @@ do_save() {
|
||||
status=0
|
||||
|
||||
if [ -f ${VARDIR}/firewall ]; then
|
||||
if $iptables_save | iptablesbug > ${VARDIR}/restore-$$; then
|
||||
if $iptables_save | iptablesbug | grep -v -- '-A dynamic.* -j ACCEPT' > ${VARDIR}/restore-$$; then
|
||||
cp -f ${VARDIR}/firewall $g_restorepath
|
||||
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-iptables
|
||||
chmod +x $g_restorepath
|
||||
@@ -473,7 +474,7 @@ do_save() {
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
[Nn]o)
|
||||
[Nn]o|ipv4|ipv6)
|
||||
;;
|
||||
*)
|
||||
error_message "WARNING: Invalid value ($SAVE_IPSETS) for SAVE_IPSETS"
|
||||
@@ -493,6 +494,8 @@ save_config() {
|
||||
|
||||
[ -x $iptables_save ] || echo "$iptables-save does not exist or is not executable" >&2
|
||||
|
||||
[ -n "$g_counters" ] && iptables_save="$iptables_save --counters"
|
||||
|
||||
if product_is_started ; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
|
||||
@@ -1222,6 +1225,16 @@ show_command() {
|
||||
echo
|
||||
show_bl;
|
||||
;;
|
||||
opens)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$g_product $SHOREWALL_VERSION Temporarily opened connections at $g_hostname - $(date)"
|
||||
|
||||
if chain_exists dynamic; then
|
||||
g_ipt_options="$g_ipt_options --line-numbers"
|
||||
$g_tool -t filter -L dynamic $g_ipt_options | head -n2
|
||||
$g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
case "$g_program" in
|
||||
*-lite)
|
||||
@@ -1624,6 +1637,15 @@ restore_command() {
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -1651,7 +1673,7 @@ restore_command() {
|
||||
|
||||
if [ -z "$STARTUP_ENABLED" ]; then
|
||||
error_message "ERROR: Startup is disabled"
|
||||
exit 2
|
||||
exit 6
|
||||
fi
|
||||
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
@@ -1948,7 +1970,7 @@ add_command() {
|
||||
ipset=6_${zone}_${interface};
|
||||
fi
|
||||
|
||||
ipset=$(echo $ipset | sed 's/./_/g');
|
||||
ipset=$(echo $ipset | sed 's/\./_/g');
|
||||
|
||||
if ! qt $IPSET -L $ipset; then
|
||||
fatal_error "Zone $zone, interface $interface does not have a dynamic host list"
|
||||
@@ -2065,6 +2087,166 @@ delete_command() {
|
||||
fi
|
||||
}
|
||||
|
||||
open_close_command() {
|
||||
local command
|
||||
local desc
|
||||
local proto
|
||||
local icmptype
|
||||
|
||||
open_close_setup() {
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
if ! product_is_started ; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "The $COMMAND command requires the firewall to be running"
|
||||
fi
|
||||
|
||||
if ! chain_exists dynamic; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "The $COMMAND command requires DYNAMIC_BLACKLIST=Yes in the running configuration"
|
||||
fi
|
||||
}
|
||||
|
||||
[ $# -le 4 ] || fatal_error "Too many parameters"
|
||||
|
||||
if [ $COMMAND = open ]; then
|
||||
[ $# -ge 2 ] || fatal_error "Too few parameters"
|
||||
else
|
||||
[ $# -ge 1 ] || fatal_error "Too few parameters"
|
||||
fi
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
#
|
||||
# close <rule number>
|
||||
#
|
||||
case $1 in
|
||||
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]*)
|
||||
;;
|
||||
*)
|
||||
fatal_error "$1 is not a valid temporary open number"
|
||||
;;
|
||||
esac
|
||||
|
||||
open_close_setup #Conditionally acquires mutex
|
||||
|
||||
if $g_tool -L dynamic --line-numbers | grep -q "^$1 .* ACCEPT "; then
|
||||
if $g_tool -D dynamic $1; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Temporary open #$1 closed"
|
||||
return 0
|
||||
fi
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
return 2
|
||||
else
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "$1 is not a valid temporary open number"
|
||||
fi
|
||||
else
|
||||
if [ $1 = all ]; then
|
||||
command=dynamic
|
||||
else
|
||||
command="dynamic -s $1"
|
||||
fi
|
||||
|
||||
if [ $2 != all ]; then
|
||||
command="$command -d $2"
|
||||
fi
|
||||
|
||||
desc="from $1 to $2"
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
proto=$3
|
||||
|
||||
[ $proto = icmp -a $g_family -eq 6 ] && proto=58
|
||||
|
||||
command="$command -p $proto"
|
||||
|
||||
case $3 in
|
||||
[0-9]*)
|
||||
desc="$desc protocol $3"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $3"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $g_family -eq 4 ]; then
|
||||
if [ $proto = 6 -o $proto = icmp ]; then
|
||||
proto=icmp
|
||||
icmptype='--icmp-type'
|
||||
fi
|
||||
else
|
||||
if [ $proto = 58 -o $proto = ipv6-icmp ]; then
|
||||
proto=icmp
|
||||
icmptype='--icmpv6-type'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -eq 4 ]; then
|
||||
if [ $proto = icmp ]; then
|
||||
case $4 in
|
||||
*,*)
|
||||
fatal_error "Only a single ICMP type may be specified"
|
||||
;;
|
||||
[0-9]*)
|
||||
desc="$desc type $4"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $4"
|
||||
;;
|
||||
esac
|
||||
|
||||
command="$command $icmptype $4"
|
||||
else
|
||||
case $4 in
|
||||
*,*)
|
||||
command="$command -m multiport --dports $4"
|
||||
;;
|
||||
*)
|
||||
command="$command --dport $4"
|
||||
;;
|
||||
esac
|
||||
|
||||
case $4 in
|
||||
[0-9]*,)
|
||||
desc="$desc ports $4"
|
||||
;;
|
||||
[0-9]*)
|
||||
desc="$desc port $4"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $4"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
command="$command -j ACCEPT"
|
||||
|
||||
open_close_setup #Conditionally acquires mutex
|
||||
|
||||
if [ $COMMAND = open ]; then
|
||||
if $g_tool -I $command ; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Firewall dynamically opened for connections $desc"
|
||||
return 0
|
||||
fi
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
return 2
|
||||
fi
|
||||
|
||||
if $g_tool -D $command 2> /dev/null; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Firewall dynamically closed for connections $desc (may still be permitted by rules/policies)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "Connections $desc are not currently opened"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# 'hits' commmand executor
|
||||
#
|
||||
@@ -2283,6 +2465,7 @@ determine_capabilities() {
|
||||
local chain
|
||||
local chain1
|
||||
local arptables
|
||||
local helper
|
||||
|
||||
if [ -z "$g_tool" ]; then
|
||||
[ $g_family -eq 4 ] && tool=iptables || tool=ip6tables
|
||||
@@ -2381,6 +2564,9 @@ determine_capabilities() {
|
||||
MASQUERADE_TGT=
|
||||
UDPLITEREDIRECT=
|
||||
NEW_TOS_MATCH=
|
||||
TARPIT_TARGET=
|
||||
IFACE_MATCH=
|
||||
TCPMSS_TARGET=
|
||||
|
||||
AMANDA_HELPER=
|
||||
FTP_HELPER=
|
||||
@@ -2534,6 +2720,12 @@ determine_capabilities() {
|
||||
qt $NFACCT del $chain
|
||||
fi
|
||||
|
||||
qt $g_tool -A $chain -p tcp -j TARPIT && TARPIT_TARGET=Yes
|
||||
|
||||
qt $g_tool -A $chain -m iface --iface lo --loopback && IFACE_MATCH=Yes
|
||||
|
||||
qt $g_tool -A $chain -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu && TCPMSS_TARGET=Yes
|
||||
|
||||
if [ -n "$MANGLE_ENABLED" ]; then
|
||||
qt $g_tool -t mangle -N $chain
|
||||
|
||||
@@ -2575,21 +2767,44 @@ determine_capabilities() {
|
||||
if qt $g_tool -t raw -A $chain -j CT --notrack; then
|
||||
CT_TARGET=Yes;
|
||||
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 10080 -j CT --helper amanda && AMANDA_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp && FTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp-0 && FTP0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 1719 -j CT --helper RAS && H323_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc && IRC_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc-0 && IRC0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 137 -j CT --helper netbios-ns && NETBIOS_NS_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 1729 -j CT --helper pptp && PPTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane && SANE_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane-0 && SANE0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip && SIP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip-0 && SIP0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 161 -j CT --helper snmp && SNMP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp && TFTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp-0 && TFTP0_HELPER=Yes
|
||||
for helper in amanda ftp ftp0 h323 irc irc0 netbios_ns pptp sane sane0 sip sip0 snmp tftp tftp0; do
|
||||
eval ${helper}_ENABLED=''
|
||||
done
|
||||
|
||||
if [ -n "$HELPERS" ]; then
|
||||
for helper in $(split_list "$HELPERS"); do
|
||||
case $helper in
|
||||
none)
|
||||
;;
|
||||
amanda|ftp|ftp0|h323|irc|irc0|netbios_ns|pptp|sane|sane0|sip|sip0|snmp|tftp|tftp0)
|
||||
eval ${helper}_ENABLED=Yes
|
||||
;;
|
||||
*)
|
||||
error_message "WARNING: Invalid helper ($helper) ignored"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
for helper in amanda ftp ftp0 h323 irc irc0 netbios_ns pptp sane sane0 sip sip0 snmp tftp tftp0; do
|
||||
eval ${helper}_ENABLED=Yes
|
||||
done
|
||||
fi
|
||||
|
||||
[ -n "$amanda_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 10080 -j CT --helper amanda && AMANDA_HELPER=Yes
|
||||
[ -n "$ftp_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp && FTP_HELPER=Yes
|
||||
[ -n "$ftp0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp-0 && FTP0_HELPER=Yes
|
||||
[ -n "$h323_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 1719 -j CT --helper RAS && H323_HELPER=Yes
|
||||
[ -n "$irc_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc && IRC_HELPER=Yes
|
||||
[ -n "$irc0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc-0 && IRC0_HELPER=Yes
|
||||
[ -n "$netbios_ns_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 137 -j CT --helper netbios-ns && NETBIOS_NS_HELPER=Yes
|
||||
[ -n "$pptp_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 1729 -j CT --helper pptp && PPTP_HELPER=Yes
|
||||
[ -n "$sane_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane && SANE_HELPER=Yes
|
||||
[ -n "$sane0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane-0 && SANE0_HELPER=Yes
|
||||
[ -n "$sip_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip && SIP_HELPER=Yes
|
||||
[ -n "$sip0_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip-0 && SIP0_HELPER=Yes
|
||||
[ -n "$snmp_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 161 -j CT --helper snmp && SNMP_HELPER=Yes
|
||||
[ -n "$tftp_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp && TFTP_HELPER=Yes
|
||||
[ -n "$tftp0_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp-0 && TFTP0_HELPER=Yes
|
||||
fi
|
||||
|
||||
qt $g_tool -t raw -F $chain
|
||||
@@ -2803,14 +3018,17 @@ report_capabilities_unsorted() {
|
||||
report_capability "IMQ Target (IMQ_TARGET)" $IMQ_TARGET
|
||||
report_capability "DSCP Match (DSCP_MATCH)" $DSCP_MATCH
|
||||
report_capability "DSCP Target (DSCP_TARGET)" $DSCP_TARGET
|
||||
report_capability "Geo IP match" $GEOIP_MATCH
|
||||
report_capability "RPFilter match" $RPFILTER_MATCH
|
||||
report_capability "NFAcct match" $NFACCT_MATCH
|
||||
report_capability "Checksum Target" $CHECKSUM_TARGET
|
||||
report_capability "Arptables JF" $ARPTABLESJF
|
||||
report_capability "MASQUERADE Target" $MASQUERADE_TGT
|
||||
report_capability "UDPLITE Port Redirection" $UDPLITEREDIRECT
|
||||
report_capability "New tos Match" $NEW_TOS_MATCH
|
||||
report_capability "Geo IP Match (GEOIP_MATCH)" $GEOIP_MATCH
|
||||
report_capability "RPFilter Match (RPFILTER_MATCH)" $RPFILTER_MATCH
|
||||
report_capability "NFAcct Match" $NFACCT_MATCH
|
||||
report_capability "Checksum Target (CHECKSUM_TARGET)" $CHECKSUM_TARGET
|
||||
report_capability "Arptables JF (ARPTABLESJF)" $ARPTABLESJF
|
||||
report_capability "MASQUERADE Target (MASQUERADE_TGT)" $MASQUERADE_TGT
|
||||
report_capability "UDPLITE Port Redirection (UDPLITEREDIRECT)" $UDPLITEREDIRECT
|
||||
report_capability "New tos Match (NEW_TOS_MATCH)" $NEW_TOS_MATCH
|
||||
report_capability "TARPIT Target (TARPIT_TARGET)" $TARPIT_TARGET
|
||||
report_capability "Iface Match (IFACE_MATCH)" $IFACE_MATCH
|
||||
report_capability "TCPMSS Target (TCPMSS_TARGET)" $TCPMSS_TARGET
|
||||
|
||||
report_capability "Amanda Helper" $AMANDA_HELPER
|
||||
report_capability "FTP Helper" $FTP_HELPER
|
||||
@@ -2938,6 +3156,9 @@ report_capabilities_unsorted1() {
|
||||
report_capability1 MASQUERADE_TGT
|
||||
report_capability1 UDPLITEREDIRECT
|
||||
report_capability1 NEW_TOS_MATCH
|
||||
report_capability1 TARPIT_TARGET
|
||||
report_capability1 IFACE_MATCH
|
||||
report_capability1 TCPMSS_TARGET
|
||||
|
||||
report_capability1 AMANDA_HELPER
|
||||
report_capability1 FTP_HELPER
|
||||
@@ -3108,11 +3329,45 @@ reject_command() {
|
||||
}
|
||||
|
||||
save_command() {
|
||||
local finished
|
||||
finished=0
|
||||
|
||||
shift
|
||||
|
||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
option=$1
|
||||
case $option in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
-)
|
||||
finished=1
|
||||
option=
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
finished=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $# in
|
||||
1)
|
||||
0)
|
||||
;;
|
||||
2)
|
||||
RESTOREFILE="$2"
|
||||
1)
|
||||
RESTOREFILE="$1"
|
||||
validate_restorefile '<restore file>'
|
||||
;;
|
||||
*)
|
||||
@@ -3345,11 +3600,6 @@ get_config() {
|
||||
|
||||
g_hostname=$(hostname 2> /dev/null)
|
||||
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
if [ -z "$IP" ] ; then
|
||||
fatal_error "Can't find ip executable"
|
||||
fi
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
case "$IPSET" in
|
||||
*/*)
|
||||
@@ -3371,6 +3621,10 @@ get_config() {
|
||||
|
||||
TC=tc
|
||||
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
|
||||
g_loopback=$(find_loopback_interfaces)
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@@ -3407,12 +3661,16 @@ start_command() {
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${VARDIR}/firewall ]; then
|
||||
run_it ${VARDIR}/firewall $g_debugging start
|
||||
if [ -n "$g_fast" -a -x ${VARDIR}/${RESTOREFILE} -a ! ${VARDIR}/firewall -nt ${VARDIR}/${RESTOREFILE} ]; then
|
||||
run_it ${VARDIR}/${RESTOREFILE} $g_debugging restore
|
||||
else
|
||||
run_it ${VARDIR}/firewall $g_debugging start
|
||||
fi
|
||||
rc=$?
|
||||
else
|
||||
error_message "${VARDIR}/firewall is missing or is not executable"
|
||||
logger -p kern.err "ERROR:$g_product start failed"
|
||||
rc=2
|
||||
rc=6
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
@@ -3443,6 +3701,14 @@ start_command() {
|
||||
finished=1
|
||||
option=
|
||||
;;
|
||||
f*)
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
g_purge=Yes
|
||||
@@ -3504,6 +3770,10 @@ restart_command() {
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -3533,7 +3803,7 @@ restart_command() {
|
||||
else
|
||||
error_message "${VARDIR}/firewall is missing or is not executable"
|
||||
logger -p kern.err "ERROR:$g_product restart failed"
|
||||
rc=2
|
||||
rc=6
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
@@ -3558,6 +3828,7 @@ usage() # $1 = exit status
|
||||
echo " add <interface>[:<host-list>] ... <zone>"
|
||||
echo " allow <address> ..."
|
||||
echo " clear"
|
||||
echo " close <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " delete <interface>[:<host-list>] ... <zone>"
|
||||
echo " disable <interface>"
|
||||
echo " drop <address> ..."
|
||||
@@ -3575,12 +3846,15 @@ usage() # $1 = exit status
|
||||
echo " logdrop <address> ..."
|
||||
echo " logreject <address> ..."
|
||||
echo " logwatch [<refresh interval>]"
|
||||
echo " open <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " reject <address> ..."
|
||||
echo " reenable <interface>"
|
||||
echo " reset [ <chain> ... ]"
|
||||
echo " restart [ -n ] [ -p ] [ -f ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ <file name> ]"
|
||||
echo " restart [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]"
|
||||
echo " run <command> [ <parameter> ... ]"
|
||||
echo " save [ <file name> ]"
|
||||
echo " save [ -C ] [ <file name> ]"
|
||||
echo " savesets"
|
||||
echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
|
||||
echo " [ show | list | ls ] [ -f ] capabilities"
|
||||
echo " [ show | list | ls ] arptables"
|
||||
@@ -3600,12 +3874,13 @@ usage() # $1 = exit status
|
||||
echo " [ show | list | ls ] [ -m ] log [<regex>]"
|
||||
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost"
|
||||
echo " [ show | list | ls ] nfacct"
|
||||
echo " [ show | list | ls ] opens"
|
||||
echo " [ show | list | ls ] policies"
|
||||
echo " [ show | list | ls ] routing"
|
||||
echo " [ show | list | ls ] tc [ device ]"
|
||||
echo " [ show | list | ls ] vardir"
|
||||
echo " [ show | list | ls ] zones"
|
||||
echo " start [ -f ] [ -p ] [ <directory> ]"
|
||||
echo " start [ -f ] [ -p ] [ -C ] [ <directory> ]"
|
||||
echo " stop"
|
||||
echo " status [ -i ]"
|
||||
echo " version [ -a ]"
|
||||
@@ -3657,6 +3932,8 @@ shorewall_cli() {
|
||||
g_directives=
|
||||
g_inline=
|
||||
g_tcrules=
|
||||
g_counters=
|
||||
g_loopback=
|
||||
|
||||
VERBOSE=
|
||||
VERBOSITY=1
|
||||
@@ -3778,10 +4055,6 @@ shorewall_cli() {
|
||||
|
||||
[ -n "${VARDIR:=/var/lib/$g_program}" ]
|
||||
|
||||
if [ ! -f ${VARDIR}/firewall ]; then
|
||||
[ -f ${VARDIR}/.restore ] && cp -f ${VARDIR}/.rstore ${VARDIR}/firewall
|
||||
fi
|
||||
|
||||
g_firewall=${VARDIR}/firewall
|
||||
|
||||
version_file=${g_sharedir}/version
|
||||
@@ -3844,7 +4117,7 @@ shorewall_cli() {
|
||||
shift
|
||||
restart_command $@
|
||||
;;
|
||||
disable|enable)
|
||||
disable|enable|reenable)
|
||||
get_config Yes
|
||||
if product_is_started; then
|
||||
run_it ${VARDIR}/firewall $g_debugging $@
|
||||
@@ -3907,6 +4180,11 @@ shorewall_cli() {
|
||||
[ $# -eq 1 ] && usage 1
|
||||
reject_command $@
|
||||
;;
|
||||
open|close)
|
||||
get_config
|
||||
shift
|
||||
open_close_command $@
|
||||
;;
|
||||
allow)
|
||||
get_config
|
||||
allow_command $@
|
||||
@@ -3951,10 +4229,29 @@ shorewall_cli() {
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
#
|
||||
# Undocumented way to call functions in the libraries directly
|
||||
# Way to call functions in the libraries directly
|
||||
#
|
||||
shift
|
||||
$@
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# First look for it here
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
#
|
||||
# It isn't a function visible to this script -- try
|
||||
# the compiled firewall
|
||||
#
|
||||
run_it $g_firewall $g_debugging call $@
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
help)
|
||||
shift
|
||||
@@ -3970,6 +4267,12 @@ shorewall_cli() {
|
||||
shift
|
||||
noiptrace_command $@
|
||||
;;
|
||||
savesets)
|
||||
[ $# -eq 1 ] || usage 1
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
savesets1
|
||||
;;
|
||||
*)
|
||||
if [ -z "$g_lite" ]; then
|
||||
compiler_command $@
|
||||
|
@@ -70,6 +70,15 @@ startup_error() # $* = Error Message
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Get the Shorewall version of the passed script
|
||||
#
|
||||
@@ -157,6 +166,7 @@ run_it() {
|
||||
[ -n "$g_timestamp" ] && options=${options}t
|
||||
[ -n "$g_purge" ] && options=${options}p
|
||||
[ -n "$g_recovering" ] && options=${options}r
|
||||
[ -n "$g_counters" ] && options=${options}c
|
||||
|
||||
options="${options}V $VERBOSITY"
|
||||
|
||||
@@ -210,6 +220,17 @@ split() {
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Split a comma-separated list into a space-separated list
|
||||
#
|
||||
split_list() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=,
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
@@ -373,7 +394,7 @@ reload_kernel_modules() {
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=ko ko.gz o o.gz gz}" ]
|
||||
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
@@ -412,7 +433,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
@@ -644,6 +665,24 @@ find_first_interface_address_if_any() # $1 = interface
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
#Determines if the passed interface is a loopback interface
|
||||
#
|
||||
loopback_interface() { #$1 = Interface name
|
||||
[ "$1" = lo ] || $IP link show $1 | fgrep -q LOOPBACK
|
||||
}
|
||||
|
||||
#
|
||||
# Find Loopback Interfaces
|
||||
#
|
||||
find_loopback_interfaces() {
|
||||
local interfaces
|
||||
|
||||
[ -x "$IP" ] && interfaces=$($IP link show | fgrep LOOPBACK | sed 's/://g' | cut -d ' ' -f 2)
|
||||
|
||||
[ -n "$interfaces" ] && echo $interfaces || echo lo
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
|
@@ -14,7 +14,7 @@ INITDIR= #Unused on OS X
|
||||
INITFILE= #Unused on OS X
|
||||
INITSOURCE= #Unused on OS X
|
||||
ANNOTATED= #Unused on OS X
|
||||
SYSTEMD= #Unused on OS X
|
||||
SERVICEDIR= #Unused on OS X
|
||||
SERVICEFILE= #Unused on OS X
|
||||
SYSCONFDIR= #Unused on OS X
|
||||
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
|
||||
|
@@ -8,14 +8,14 @@ SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
|
||||
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.
|
||||
PERLLIBDIR=${PREFIX}/share/shorewall #Directory to install Shorewall Perl module directory
|
||||
CONFDIR=/etc #Directory where subsystem configurations are installed
|
||||
SBINDIR=/usr/sbin #Directory where system administration programs are installed
|
||||
SBINDIR=/usr/bin #Directory where system administration programs are installed
|
||||
MANDIR=${SHAREDIR}/man #Directory where manpages are installed.
|
||||
INITDIR= #Directory where SysV init scripts are installed.
|
||||
INITFILE= #Name of the product's installed SysV init script
|
||||
INITSOURCE= #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSCONFDIR= #Directory where SysV init parameter files are installed
|
||||
SYSTEMD=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
|
||||
VARLIB=/var/lib #Directory where product variable data is stored.
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Unused on Cygwin
|
||||
INITFILE= #Unused on Cygwin
|
||||
INITSOURCE= #Unused on Cygwin
|
||||
ANNOTATED= #Unused on Cygwin
|
||||
SYSTEMD= #Unused on Cygwin
|
||||
SERVICEDIR= #Unused on Cygwin
|
||||
SERVICEFILE= #Unused on Cygwin
|
||||
SYSCONFDIR= #Unused on Cygwin
|
||||
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
|
||||
|
@@ -17,7 +17,7 @@ ANNOTATED= #If non-zero, annotated configuration fi
|
||||
SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
|
||||
VARLIB=/var/lib #Directory where product variable data is stored.
|
||||
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Directory where SysV init scripts are i
|
||||
INITFILE=$PRODUCT #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR= #Directory where SysV init parameter files are installed
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/rc.d/init.d #Directory where SysV init scripts are i
|
||||
INITFILE=$PRODUCT #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.fedora.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
|
||||
|
@@ -15,7 +15,7 @@ AUXINITSOURCE=init.slackware.firewall.sh #Name of the distributed file to be i
|
||||
AUXINITFILE=rc.firewall #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script
|
||||
INITFILE=rc.$PRODUCT #Name of the product's installed second init script
|
||||
SYSTEMD= #Name of the directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Name of the directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR= #Name of the directory where SysV init parameter files are installed.
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Directory where SysV init
|
||||
INITFILE=$PRODUCT #Name of the product's SysV init script
|
||||
INITSOURCE=init.suse.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE=sysconfig #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
|
||||
|
@@ -35,6 +35,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
|
@@ -28,7 +28,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
|
@@ -31,7 +31,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x "$STATEDIR/firewall" ]; then
|
||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
||||
|
@@ -28,7 +28,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
|
@@ -71,10 +71,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || echo_notdone
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -103,21 +105,17 @@ shorewall_start () {
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
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 || echo_notdone
|
||||
else
|
||||
echo_notdone
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo_notdone
|
||||
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
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -144,10 +142,10 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || echo_notdone
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -42,7 +42,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT $OPTIONS compile -c
|
||||
|
@@ -67,12 +67,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
||||
fi
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ shorewall_start () {
|
||||
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop || exit 1
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -106,10 +106,10 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || exit 1
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -77,10 +77,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -91,14 +93,12 @@ shorewall_start () {
|
||||
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x $STATEDIR/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop || exit
|
||||
if setstatedir; then
|
||||
if [ -x $STATEDIR/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit 6
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -114,12 +114,10 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || exit
|
||||
else
|
||||
exit 6
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -188,6 +188,8 @@ done
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
|
||||
[ $configure -eq 1 ] && ETC=/etc || ETC="${CONFDIR}"
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
case $(uname) in
|
||||
cygwin*)
|
||||
@@ -330,12 +332,16 @@ fi
|
||||
#
|
||||
# Install the .service file
|
||||
#
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service"
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
||||
if [ -n "$DESTDIR" -o $configure -eq 0 ]; then
|
||||
mkdir -p ${DESTDIR}${SBINDIR}
|
||||
chmod 755 ${DESTDIR}${SBINDIR}
|
||||
@@ -368,8 +374,6 @@ chmod 644 ${DESTDIR}${SHAREDIR}/shorewall-init/version
|
||||
#
|
||||
# Remove and create the symbolic link to the init script
|
||||
#
|
||||
echo CONFDIR is $CONFDIR
|
||||
|
||||
if [ -z "$DESTDIR" ]; then
|
||||
rm -f ${SHAREDIR}/shorewall-init/init
|
||||
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/shorewall-init/init
|
||||
@@ -377,9 +381,9 @@ fi
|
||||
|
||||
if [ $HOST = debian ]; then
|
||||
if [ -n "${DESTDIR}" ]; then
|
||||
mkdir -p ${DESTDIR}/etc/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}/etc/network/if-down.d/
|
||||
mkdir -p ${DESTDIR}/etc/network/if-post-down.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-down.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-post-down.d/
|
||||
elif [ $configure -eq 0 ]; then
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/network/if-down.d/
|
||||
@@ -388,15 +392,11 @@ if [ $HOST = debian ]; then
|
||||
|
||||
if [ ! -f ${DESTDIR}${CONFDIR}/default/shorewall-init ]; then
|
||||
if [ -n "${DESTDIR}" ]; then
|
||||
mkdir ${DESTDIR}/etc/default
|
||||
mkdir ${DESTDIR}${ETC}/default
|
||||
fi
|
||||
|
||||
if [ $configure -eq 1 ]; then
|
||||
install_file sysconfig ${DESTDIR}/etc/default/shorewall-init 0644
|
||||
else
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/default
|
||||
install_file sysconfig ${DESTDIR}${CONFDIR}/default/shorewall-init 0644
|
||||
fi
|
||||
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/default
|
||||
install_file sysconfig ${DESTDIR}${ETC}/default/shorewall-init 0644
|
||||
fi
|
||||
|
||||
IFUPDOWN=ifupdown.debian.sh
|
||||
@@ -406,13 +406,13 @@ else
|
||||
|
||||
if [ -z "$RPM" ]; then
|
||||
if [ $HOST = suse ]; then
|
||||
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-up.d
|
||||
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-down.d
|
||||
mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-up.d
|
||||
mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-down.d
|
||||
elif [ $HOST = gentoo ]; then
|
||||
# Gentoo does not support if-{up,down}.d
|
||||
/bin/true
|
||||
else
|
||||
mkdir -p ${DESTDIR}/etc/NetworkManager/dispatcher.d
|
||||
mkdir -p ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -438,12 +438,8 @@ mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init
|
||||
install_file ifupdown ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown 0544
|
||||
|
||||
if [ -d ${DESTDIR}/etc/NetworkManager ]; then
|
||||
if [ $configure -eq 1 ]; then
|
||||
install_file ifupdown ${DESTDIR}/etc/NetworkManager/dispatcher.d/01-shorewall 0544
|
||||
else
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/
|
||||
install_file ifupdown ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/01-shorewall 0544
|
||||
fi
|
||||
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/
|
||||
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
|
||||
fi
|
||||
|
||||
case $HOST in
|
||||
@@ -515,7 +511,7 @@ if [ -z "$DESTDIR" ]; then
|
||||
# not by the installer
|
||||
/bin/true
|
||||
else
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
if systemctl enable shorewall-init.service; then
|
||||
echo "Shorewall Init will start automatically at boot"
|
||||
fi
|
||||
|
@@ -30,7 +30,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit 1
|
||||
|
@@ -4,17 +4,17 @@
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall (bootup security)
|
||||
Description=Shorewall firewall (bootup security)
|
||||
Before=network.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
Conflicts=iptables.service ip6tables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-init
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-init $OPTIONS start
|
||||
ExecStop=/sbin/shorewall-init $OPTIONS stop
|
||||
ExecStart=/sbin/shorewall-init start
|
||||
ExecStop=/sbin/shorewall-init stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
|
21
Shorewall-init/shorewall-init.service.214
Normal file
21
Shorewall-init/shorewall-init.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall firewall (bootup security)
|
||||
Before=network-pre.target
|
||||
Wants=network-pre.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-init
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-init start
|
||||
ExecStop=/sbin/shorewall-init stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -35,6 +35,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
|
@@ -39,7 +39,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting Shorewall: "
|
||||
$shorewall $OPTIONS start 2>&1 | $logger
|
||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
@@ -69,7 +69,7 @@ restart() {
|
||||
# Note that we don't simply stop and start since shorewall has a built in
|
||||
# restart which stops the firewall if running and then starts it.
|
||||
echo -n $"Restarting Shorewall: "
|
||||
$shorewall $OPTIONS restart 2>&1 | $logger
|
||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
|
@@ -381,7 +381,7 @@ fi
|
||||
|
||||
if [ -n "$INITFILE" ]; then
|
||||
if [ -f "${INITSOURCE}" ]; then
|
||||
initfile="${DESTDIR}/${INITDIR}/${INITFILE}"
|
||||
initfile="${DESTDIR}${INITDIR}/${INITFILE}"
|
||||
install_file ${INITSOURCE} "$initfile" 0544
|
||||
|
||||
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
|
||||
@@ -392,12 +392,16 @@ fi
|
||||
#
|
||||
# Install the .service file
|
||||
#
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service"
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
||||
fi
|
||||
#
|
||||
# Install the config file
|
||||
@@ -539,7 +543,7 @@ if [ ${SHAREDIR} != /usr/share ]; then
|
||||
fi
|
||||
|
||||
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
if systemctl enable ${PRODUCT}.service; then
|
||||
echo "$Product will start automatically at boot"
|
||||
fi
|
||||
|
@@ -47,6 +47,19 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>allow</option></arg>
|
||||
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -59,6 +72,21 @@
|
||||
choice="plain"><option>clear</option><arg><option>-f</option></arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>close</option><arg choice="req">
|
||||
<replaceable>open-number</replaceable> |
|
||||
<replaceable>source</replaceable><replaceable>dest</replaceable><arg><replaceable>protocol</replaceable><arg>
|
||||
<replaceable>port</replaceable> </arg></arg></arg><replaceable>
|
||||
</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -116,6 +144,8 @@
|
||||
<arg><option>-l</option></arg>
|
||||
|
||||
<arg><option>-m</option></arg>
|
||||
|
||||
<arg><option>-c</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -263,6 +293,29 @@
|
||||
expression</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg choice="plain"><option>open</option><replaceable>
|
||||
source</replaceable><replaceable> dest</replaceable><arg>
|
||||
<replaceable>protocol</replaceable><arg> <replaceable>port</replaceable>
|
||||
</arg> </arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>reenable</option></arg>
|
||||
|
||||
<arg choice="plain">{ <replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -299,9 +352,7 @@
|
||||
|
||||
<arg><option>-n</option></arg>
|
||||
|
||||
<arg><option>-p</option></arg>
|
||||
|
||||
<arg><replaceable>directory</replaceable></arg>
|
||||
<arg><option>-p</option><arg><option>-C</option></arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -314,6 +365,8 @@
|
||||
|
||||
<arg choice="plain"><option>restore</option></arg>
|
||||
|
||||
<arg><option>-C</option></arg>
|
||||
|
||||
<arg><replaceable>filename</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
@@ -340,11 +393,23 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>save</option></arg>
|
||||
<arg
|
||||
choice="plain"><option>save</option><arg><option>-C</option></arg></arg>
|
||||
|
||||
<arg choice="opt"><replaceable>filename</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>savesets</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -352,7 +417,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-b</option></arg>
|
||||
|
||||
@@ -374,7 +439,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
|
||||
@@ -388,7 +453,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-f</option></arg>
|
||||
|
||||
@@ -402,7 +467,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg
|
||||
choice="req"><option>classifiers|connections|config|events|filters|ip|ipa|zones|policies|marks</option></arg>
|
||||
@@ -415,7 +480,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg choice="plain"><option>event</option><arg
|
||||
choice="plain"><replaceable>event</replaceable></arg></arg>
|
||||
@@ -428,11 +493,11 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
<arg><option>-c</option></arg>
|
||||
|
||||
<arg choice="req"><option>mangle|nat|routing|raw|rawpost</option></arg>
|
||||
<arg choice="plain"><option>routing</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -442,7 +507,21 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
|
||||
<arg choice="req"><option>mangle|nat|raw|rawpost</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg choice="plain"><option>tc</option></arg>
|
||||
</cmdsynopsis>
|
||||
@@ -454,7 +533,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-m</option></arg>
|
||||
|
||||
@@ -474,6 +553,10 @@
|
||||
<arg><option>-n</option></arg>
|
||||
|
||||
<arg><option>-p</option></arg>
|
||||
|
||||
<arg><option>-f</option></arg>
|
||||
|
||||
<arg><option>-C</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -526,8 +609,9 @@
|
||||
|
||||
<para>The nolock <option>option</option> prevents the command from
|
||||
attempting to acquire the Shorewall-lite lockfile. It is useful if you
|
||||
need to include <command>shorewall</command> commands in
|
||||
<filename>/etc/shorewall/started</filename>.</para>
|
||||
need to include <command>shorewall</command> commands in the
|
||||
<filename>started</filename> <ulink
|
||||
url="../shorewall_extension_scripts.html">extension script</ulink>.</para>
|
||||
|
||||
<para>The <emphasis>options</emphasis> control the amount of output that
|
||||
the command produces. They consist of a sequence of the letters <emphasis
|
||||
@@ -538,8 +622,8 @@
|
||||
role="bold">v</emphasis> adds one to the effective verbosity and each
|
||||
<emphasis role="bold">q</emphasis> subtracts one from the effective
|
||||
VERBOSITY. Alternately, <emphasis role="bold">v</emphasis> may be followed
|
||||
immediately with one of -1,0,1,2 to specify a specify VERBOSITY. There may
|
||||
be no white-space between <emphasis role="bold">v</emphasis> and the
|
||||
immediately with one of -1,0,1,2 to specify VERBOSITY. There may be no
|
||||
white-space between <emphasis role="bold">v</emphasis> and the
|
||||
VERBOSITY.</para>
|
||||
|
||||
<para>The <emphasis>options</emphasis> may also include the letter
|
||||
@@ -554,7 +638,10 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">add</emphasis></term>
|
||||
<term><emphasis role="bold">add </emphasis>{
|
||||
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
|
||||
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
|
||||
<replaceable>host-list</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Adds a list of hosts or subnets to a dynamic zone usually used
|
||||
@@ -579,7 +666,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">allow</emphasis></term>
|
||||
<term><emphasis role="bold">allow
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Re-enables receipt of packets from hosts previously
|
||||
@@ -591,7 +679,25 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear</emphasis></term>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename> and
|
||||
<filename>lib.cli</filename>. If it is not found, the call command
|
||||
is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear
|
||||
</emphasis>[-<option>f</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Clear will remove all rules and chains installed by
|
||||
@@ -608,7 +714,31 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">delete</emphasis></term>
|
||||
<term><emphasis role="bold">close</emphasis> {
|
||||
<replaceable>open-number</replaceable> |
|
||||
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
|
||||
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
|
||||
] ] }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.8. This command closes a temporary open
|
||||
created by the <command>open</command> command. In the first form,
|
||||
an <replaceable>open-number</replaceable> specifies the open to be
|
||||
closed. Open numbers are displayed in the <emphasis
|
||||
role="bold">num</emphasis> column of the output of the
|
||||
<command>shorewall-lite show opens </command>command.</para>
|
||||
|
||||
<para>When the second form of the command is used, the parameters
|
||||
must match those given in the earlier <command>open</command>
|
||||
command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">delete </emphasis>{
|
||||
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
|
||||
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
|
||||
<replaceable>host-list</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>The delete command reverses the effect of an earlier <emphasis
|
||||
@@ -623,7 +753,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">disable</emphasis></term>
|
||||
<term><emphasis role="bold">disable </emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.4.26. Disables the optional provider
|
||||
@@ -635,7 +767,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">drop</emphasis></term>
|
||||
<term><emphasis role="bold">drop
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -644,7 +777,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">dump</emphasis></term>
|
||||
<term><emphasis role="bold">dump </emphasis>[-<option>x</option>]
|
||||
[-<option>l</option>] [-<option>m</option>]
|
||||
[-<option>c</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Produces a verbose report about the firewall configuration for
|
||||
@@ -658,11 +793,16 @@
|
||||
|
||||
<para>The <emphasis role="bold">-l</emphasis> option causes the rule
|
||||
number for each Netfilter rule to be displayed.</para>
|
||||
|
||||
<para>The <option>-c</option> option causes the route cache to be
|
||||
dumped in addition to the other routing information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">enable</emphasis></term>
|
||||
<term><emphasis role="bold">enable </emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.4.26. Enables the optional provider
|
||||
@@ -674,7 +814,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">forget</emphasis></term>
|
||||
<term><emphasis role="bold">forget </emphasis>[
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Deletes /var/lib/shorewall-lite/<emphasis>filename</emphasis>
|
||||
@@ -695,7 +836,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">hits</emphasis></term>
|
||||
<term><emphasis role="bold">hits </emphasis>
|
||||
[-<option>t</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Generates several reports from Shorewall-lite log messages in
|
||||
@@ -705,7 +847,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ipcalc</emphasis></term>
|
||||
<term><emphasis role="bold">ipcalc </emphasis>{ address mask |
|
||||
address/vlsm }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Ipcalc displays the network address, broadcast address,
|
||||
@@ -715,7 +858,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">iprange</emphasis></term>
|
||||
<term><emphasis role="bold">iprange
|
||||
</emphasis><replaceable>address1</replaceable>-<replaceable>address2</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Iprange decomposes the specified range of IP addresses into
|
||||
@@ -724,7 +868,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">iptrace</emphasis></term>
|
||||
<term><emphasis role="bold">iptrace </emphasis><replaceable>iptables
|
||||
match expression</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This is a low-level debugging command that causes iptables
|
||||
@@ -743,7 +888,17 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logdrop</emphasis></term>
|
||||
<term><emphasis role="bold">list</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para><command>list</command> is a synonym for
|
||||
<command>show</command> -- please see below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logdrop
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -754,7 +909,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logwatch</emphasis></term>
|
||||
<term><emphasis role="bold">logwatch </emphasis>[-<option>m</option>]
|
||||
[<replaceable>refresh-interval</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Monitors the log file specified by the LOGFILE option in
|
||||
@@ -773,7 +929,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logreject</emphasis></term>
|
||||
<term><emphasis role="bold">logreject
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -784,7 +941,17 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">noiptrace</emphasis></term>
|
||||
<term><emphasis role="bold">ls</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para><command>ls</command> is a synonym for <command>show</command>
|
||||
-- please see below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">noiptrace </emphasis><replaceable>iptables
|
||||
match expression</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This is a low-level debugging command that cancels a trace
|
||||
@@ -797,16 +964,83 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reset</emphasis></term>
|
||||
<term><emphasis role="bold">open</emphasis>
|
||||
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
|
||||
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
|
||||
] ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>All the packet and byte counters in the firewall are
|
||||
reset.</para>
|
||||
<para>Added in Shorewall 4.6.8. This command requires that the
|
||||
firewall be in the started state and that DYNAMIC_BLACKLIST=Yes in
|
||||
<ulink url="/manpages/shorewall.conf.html">shorewall.conf
|
||||
(5)</ulink>. The effect of the command is to temporarily open the
|
||||
firewall for connections matching the parameters.</para>
|
||||
|
||||
<para>The <replaceable>source</replaceable> and
|
||||
<replaceable>dest</replaceable> parameters may each be specified as
|
||||
<emphasis role="bold">all</emphasis> if you don't wish to restrict
|
||||
the connection source or destination respectively. Otherwise, each
|
||||
must contain a host or network address or a valid DNS name.</para>
|
||||
|
||||
<para>The <replaceable>protocol</replaceable> may be specified
|
||||
either as a number or as a name listed in /etc/protocols. The
|
||||
<replaceable>port</replaceable> may be specified numerically or as a
|
||||
name listed in /etc/services.</para>
|
||||
|
||||
<para>To reverse the effect of a successful <command>open</command>
|
||||
command, use the <command>close</command> command with the same
|
||||
parameters or simply restart the firewall.</para>
|
||||
|
||||
<para>Example: To open the firewall for SSH connections to address
|
||||
192.168.1.1, the command would be:</para>
|
||||
|
||||
<programlisting> shorewall-lite open all 192.168.1.1 tcp 22</programlisting>
|
||||
|
||||
<para>To reverse that command, use:</para>
|
||||
|
||||
<screen> shorewall-lite close all 192.168.1.1 tcp 22</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restart</emphasis></term>
|
||||
<term><emphasis role="bold">reenable</emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.9. This is equivalent to a
|
||||
<command>disable</command> command followed by an
|
||||
<command>enable</command> command on the specified
|
||||
<replaceable>interface</replaceable> or
|
||||
<replaceable>provider</replaceable>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reject</emphasis><replaceable>
|
||||
address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
to be silently rejected.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reset [<replaceable>chain</replaceable>,
|
||||
...]</emphasis><acronym/></term>
|
||||
|
||||
<listitem>
|
||||
<para>Resets the packet and byte counters in the specified
|
||||
<replaceable>chain</replaceable>(s). If no
|
||||
<replaceable>chain</replaceable> is specified, all the packet and
|
||||
byte counters in the firewall are reset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restart </emphasis>[-n] [-p]
|
||||
[-<option>C</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restart is similar to <emphasis role="bold">shorewall-lite
|
||||
@@ -819,11 +1053,19 @@
|
||||
<para>The <option>-p</option> option causes the connection tracking
|
||||
table to be flushed; the <command>conntrack</command> utility must
|
||||
be installed to use this option.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
|
||||
If the specified (or implicit) firewall script is the one that
|
||||
generated the current running configuration, then the running
|
||||
netfilter configuration will be reloaded as is so as to preserve the
|
||||
iptables packet and byte counters.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restore</emphasis></term>
|
||||
<term><emphasis role="bold">restore </emphasis>[-<option>n</option>]
|
||||
[-<option>p</option>] [-<option>C</option>] [
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restore Shorewall-lite to a state saved using the <emphasis
|
||||
@@ -834,11 +1076,34 @@
|
||||
<emphasis>filename</emphasis> is given then Shorewall-lite will be
|
||||
restored from the file specified by the RESTOREFILE option in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
|
||||
|
||||
<caution>
|
||||
<para>If your iptables ruleset depends on variables that are
|
||||
detected at run-time, either in your params file or by
|
||||
Shorewall-generated code, <command>restore</command> will use the
|
||||
values that were current when the ruleset was saved, which may be
|
||||
different from the current values.</para>
|
||||
</caution>
|
||||
|
||||
<para>The <option>-n</option> option causes Shorewall to avoid
|
||||
updating the routing table(s).</para>
|
||||
|
||||
<para>The <option>-p</option> option, added in Shorewall 4.6.5,
|
||||
causes the connection tracking table to be flushed; the
|
||||
<command>conntrack</command> utility must be installed to use this
|
||||
option.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
|
||||
If the <option>-C</option> option was specified during <emphasis
|
||||
role="bold">shorewall save</emphasis>, then the counters saved by
|
||||
that operation will be restored.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">run</emphasis></term>
|
||||
<term><emphasis role="bold">run
|
||||
</emphasis><replaceable>command</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.3. Executes
|
||||
@@ -855,7 +1120,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">save</emphasis></term>
|
||||
<term><emphasis role="bold">save </emphasis>[-<option>C</option>] [
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>The dynamic blacklist is stored in
|
||||
@@ -865,6 +1131,24 @@
|
||||
<emphasis>filename</emphasis> is not given then the state is saved
|
||||
in the file specified by the RESTOREFILE option in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
|
||||
|
||||
<para>The <option>-C</option> option, added in Shorewall 4.6.5,
|
||||
causes the iptables packet and byte counters to be saved along with
|
||||
the chains and rules.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">savesets</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in shorewall 4.6.8. Performs the same action as the
|
||||
<command>stop</command> command with respect to saving ipsets (see
|
||||
the SAVE_IPSETS option in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).
|
||||
This command may be used to proactively save your ipset contents in
|
||||
the event that a system failure occurs prior to issuing a
|
||||
<command>stop</command> command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -877,7 +1161,8 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">bl|blacklists</emphasis></term>
|
||||
<term><emphasis role="bold">bl|blacklists
|
||||
</emphasis>[-<option>x</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.2. Displays the dynamic chain
|
||||
@@ -890,7 +1175,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">capabilities</emphasis></term>
|
||||
<term>[-<option>f</option>] <emphasis
|
||||
role="bold">capabilities</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays your kernel/iptables capabilities. The
|
||||
@@ -901,8 +1187,10 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>[ [ <option>chain</option> ] <emphasis>chain</emphasis>...
|
||||
]</term>
|
||||
<term>[-<option>b</option>] [-<option>x</option>]
|
||||
[-<option>l</option>] [-<option>t</option>
|
||||
{<option>filter</option>|<option>mangle</option>|<option>nat</option>|<option>raw</option>|<option>rawpost</option>}]
|
||||
[ <emphasis>chain</emphasis>... ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>The rules in each <emphasis>chain</emphasis> are
|
||||
@@ -1001,7 +1289,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">log</emphasis></term>
|
||||
<term>[-<option>m</option>] <emphasis
|
||||
role="bold">log</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the last 20 Shorewall-lite messages from the
|
||||
@@ -1013,6 +1302,20 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>[-<option>x</option>] <emphasis
|
||||
role="bold">mangle</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the Netfilter mangle table using the command
|
||||
<emphasis role="bold">iptables -t mangle -L -n -v</emphasis>.
|
||||
The <emphasis role="bold">-x</emphasis> option is passed
|
||||
directly through to iptables and causes actual packet and byte
|
||||
counts to be displayed. Without this option, those counts are
|
||||
abbreviated.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">marks</emphasis></term>
|
||||
|
||||
@@ -1036,6 +1339,16 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">opens</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.8. Displays the iptables rules in
|
||||
the 'dynamic' chain created through use of the <command>open
|
||||
</command>command..</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">policies</emphasis></term>
|
||||
|
||||
@@ -1052,7 +1365,9 @@
|
||||
<term><emphasis role="bold">routing</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the system's IPv4 routing configuration.</para>
|
||||
<para>Displays the system's IPv4 routing configuration. The -c
|
||||
option causes the route cache to be displayed in addition to
|
||||
the other routing information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1091,7 +1406,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">start</emphasis></term>
|
||||
<term><emphasis role="bold">start</emphasis> [-<option>p</option>]
|
||||
[-<option>n</option>] [<option>-f</option>]
|
||||
[-<option>C</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Start Shorewall Lite. Existing connections through
|
||||
@@ -1102,6 +1419,22 @@
|
||||
<para>The <option>-p</option> option causes the connection tracking
|
||||
table to be flushed; the <command>conntrack</command> utility must
|
||||
be installed to use this option.</para>
|
||||
|
||||
<para>The <option>-n</option> option prevents the firewall script
|
||||
from modifying the current routing configuration.</para>
|
||||
|
||||
<para>The <option>-f</option> option was added in Shorewall 4.6.5.
|
||||
If the RESTOREFILE named in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5) exists, is
|
||||
executable and is not older than the current filewall script, then
|
||||
that saved configuration is restored.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5
|
||||
and is only meaningful when the <option>-f</option> option is also
|
||||
specified. If the previously-saved configuration is restored, and if
|
||||
the <option>-C</option> option was also specified in the <emphasis
|
||||
role="bold">save</emphasis> command, then the packet and byte
|
||||
counters will be restored.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#
|
||||
# IPTABLES - iptables
|
||||
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
|
||||
# MODULE_SUFFIX - "o gz ko o.gz ko.gz"
|
||||
# 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
|
||||
|
@@ -5,7 +5,8 @@
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall (lite)
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
@@ -13,7 +14,7 @@ Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
|
21
Shorewall-lite/shorewall-lite.service.214
Normal file
21
Shorewall-lite/shorewall-lite.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall (lite)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -40,6 +40,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
|
@@ -7,10 +7,12 @@
|
||||
#
|
||||
# You can comment out the ports you do not want open
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 389 #LDAP services
|
||||
PARAM - - udp 389
|
||||
PARAM - - tcp 636 #LDAP SSL
|
||||
|
@@ -7,6 +7,8 @@
|
||||
# Assumes that ports 80 and 443 are already open
|
||||
# If needed, use the macros that open Http and Https to reduce redundancy
|
||||
####################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 8200 # Goto Meeting only needed (TCP outbound)
|
||||
?FORMAT 2
|
||||
####################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 8200 # Goto Meeting only needed (TCP outbound)
|
||||
|
13
Shorewall/Macros/macro.Jabber
Normal file
13
Shorewall/Macros/macro.Jabber
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - Jabber Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Jabber
|
||||
#
|
||||
# This macro accepts Jabber traffic.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 5222
|
@@ -1,13 +1,14 @@
|
||||
#
|
||||
# Shorewall version 3.4 - JabberPlain Macro
|
||||
# Shorewall version 4 - JabberPlain Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.JabberPlain
|
||||
#
|
||||
# This macro accepts Jabber traffic (plaintext).
|
||||
# This macro accepts Jabber traffic (plaintext). This macro is
|
||||
# deprecated - use of macro.Jabber instead is recommended.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 5222
|
||||
Jabber
|
||||
|
@@ -1,9 +1,11 @@
|
||||
#
|
||||
# Shorewall version 3.4 - JabberSecure (ssl) Macro
|
||||
# Shorewall version 4 - JabberSecure (SSL) Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.JabberSecure
|
||||
#
|
||||
# This macro accepts Jabber traffic (ssl).
|
||||
# This macro accepts Jabber traffic (SSL). Use of Jabber with SSL
|
||||
# is deprecated, please configure Jabber with STARTTLS and use
|
||||
# Jabber macro instead.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
|
13
Shorewall/Macros/macro.QUIC
Normal file
13
Shorewall/Macros/macro.QUIC
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - QUIC Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.QUIC
|
||||
#
|
||||
# This macro handles QUIC (Quick UDP Internet Connections).
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - udp 80,443
|
11
Shorewall/Macros/macro.Tinc
Normal file
11
Shorewall/Macros/macro.Tinc
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Shorewall version 4 - tinc Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Tinc Macro
|
||||
#
|
||||
# This macro handles tinc traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - udp 655
|
15
Shorewall/Macros/macro.Zabbix
Normal file
15
Shorewall/Macros/macro.Zabbix
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Shorewall version 4 - Zabbix Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Zabbix
|
||||
#
|
||||
# This macro handles Zabbix monitoring software server traffic to agent
|
||||
# and trap traffic from agent to zabbix server.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 10050 # zabbix_agent
|
||||
PARAM DEST SOURCE tcp 10051 # zabbix_trap
|
@@ -34,6 +34,7 @@ use strict;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = ( qw( process_arprules create_arptables_load preview_arptables_load ) );
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
our %arp_table;
|
||||
our $arp_input;
|
||||
|
@@ -30,7 +30,7 @@ package Shorewall::Chains;
|
||||
require Exporter;
|
||||
|
||||
use Scalar::Util 'reftype';
|
||||
use Digest::SHA qw(sha1);
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
use File::Basename;
|
||||
use Shorewall::Config qw(:DEFAULT :internal);
|
||||
use Shorewall::Zones;
|
||||
@@ -110,6 +110,7 @@ our @EXPORT = ( qw(
|
||||
INLINERULE
|
||||
OPTIONS
|
||||
IPTABLES
|
||||
TARPIT
|
||||
FILTER_TABLE
|
||||
NAT_TABLE
|
||||
MANGLE_TABLE
|
||||
@@ -259,6 +260,7 @@ our %EXPORT_TAGS = (
|
||||
get_interface_gateway
|
||||
get_interface_mac
|
||||
have_global_variables
|
||||
have_address_variables
|
||||
set_global_variables
|
||||
save_dynamic_chains
|
||||
load_ipsets
|
||||
@@ -278,7 +280,7 @@ our %EXPORT_TAGS = (
|
||||
|
||||
Exporter::export_ok_tags('internal');
|
||||
|
||||
our $VERSION = '4.5_18';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
#
|
||||
# Chain Table
|
||||
@@ -316,7 +318,7 @@ our $VERSION = '4.5_18';
|
||||
# restriction => Restrictions on further rules in this chain.
|
||||
# audit => Audit the result.
|
||||
# filtered => Number of filter rules at the front of an interface forward chain
|
||||
# digest => string representation of the chain's rules for use in optimization
|
||||
# digest => SHA1 digest of the string representation of the chain's rules for use in optimization
|
||||
# level 8.
|
||||
# complete => The last rule in the chain is a -g or a simple -j to a terminating target
|
||||
# Suppresses adding additional rules to the chain end of the chain
|
||||
@@ -426,6 +428,7 @@ use constant { STANDARD => 0x1, #defined by Netfilter
|
||||
INLINERULE => 0x40000, #INLINE
|
||||
OPTIONS => 0x80000, #Target Accepts Options
|
||||
IPTABLES => 0x100000, #IPTABLES or IP6TABLES
|
||||
TARPIT => 0x200000, #TARPIT
|
||||
|
||||
FILTER_TABLE => 0x1000000,
|
||||
MANGLE_TABLE => 0x2000000,
|
||||
@@ -647,6 +650,7 @@ our %opttype = ( rule => CONTROL,
|
||||
simple => CONTROL,
|
||||
matches => CONTROL,
|
||||
complex => CONTROL,
|
||||
t => CONTROL,
|
||||
|
||||
i => UNIQUE,
|
||||
s => UNIQUE,
|
||||
@@ -761,7 +765,6 @@ sub initialize( $$$ ) {
|
||||
RETURN => 1,
|
||||
QUEUE => 1,
|
||||
CLASSIFY => 1,
|
||||
CT => 1,
|
||||
DNAT => 1,
|
||||
MASQUERADE => 1,
|
||||
NETMAP => 1,
|
||||
@@ -889,6 +892,8 @@ sub set_rule_option( $$$ ) {
|
||||
}
|
||||
} elsif ( $opttype == EXCLUSIVE ) {
|
||||
$ruleref->{$option} .= ",$value";
|
||||
} elsif ( $opttype == CONTROL ) {
|
||||
$ruleref->{$option} = $value;
|
||||
} elsif ( $opttype == UNIQUE ) {
|
||||
#
|
||||
# Shorewall::Rules::perl_action_tcp_helper() can produce rules that have two -p specifications.
|
||||
@@ -923,7 +928,7 @@ sub transform_rule( $;\$ ) {
|
||||
my $option;
|
||||
my $invert = '';
|
||||
|
||||
if ( $input =~ s/^(!\s+)?-([psdjgiom])\s+// ) {
|
||||
if ( $input =~ s/^(!\s+)?-([psdjgiomt])\s+// ) {
|
||||
#
|
||||
# Normal case of single-character
|
||||
$invert = '!' if $1;
|
||||
@@ -953,7 +958,7 @@ sub transform_rule( $;\$ ) {
|
||||
|
||||
PARAM:
|
||||
{
|
||||
while ( $input ne '' && $input !~ /^(?:!|-[psdjgiom])\s/ ) {
|
||||
while ( $input ne '' && $input !~ /^(?:!|-[psdjgiomt])\s/ ) {
|
||||
last PARAM if $input =~ /^--([^\s]+)/ && $aliases{$1 || '' };
|
||||
$input =~ s/^([^\s]+)\s*//;
|
||||
my $token = $1;
|
||||
@@ -1984,6 +1989,10 @@ sub zone_forward_chain($) {
|
||||
#
|
||||
sub use_forward_chain($$) {
|
||||
my ( $interface, $chainref ) = @_;
|
||||
my @loopback_zones = loopback_zones;
|
||||
|
||||
return 0 if $interface eq loopback_interface && ! @loopback_zones;
|
||||
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
|
||||
@@ -2858,6 +2867,7 @@ sub initialize_chain_table($) {
|
||||
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
|
||||
'INLINE' => INLINERULE,
|
||||
'IPTABLES' => IPTABLES,
|
||||
'TARPIT' => STANDARD + TARPIT + OPTIONS,
|
||||
);
|
||||
|
||||
for my $chain ( qw(OUTPUT PREROUTING) ) {
|
||||
@@ -2923,6 +2933,7 @@ sub initialize_chain_table($) {
|
||||
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
|
||||
'INLINE' => INLINERULE,
|
||||
'IP6TABLES' => IPTABLES,
|
||||
'TARPIT' => STANDARD + TARPIT + OPTIONS,
|
||||
);
|
||||
|
||||
for my $chain ( qw(OUTPUT PREROUTING) ) {
|
||||
@@ -3054,7 +3065,7 @@ sub calculate_digest( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
$chainref->{digest} = sha1 $digest;
|
||||
$chainref->{digest} = sha1_hex $digest;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -4437,6 +4448,7 @@ sub do_proto( $$$;$ )
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
$output .= $invert;
|
||||
$output .= '-m set ';
|
||||
$output .= get_set_flags( $ports, 'dst' );
|
||||
} else {
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
@@ -4476,7 +4488,8 @@ sub do_proto( $$$;$ )
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
$output .= $invert;
|
||||
$output .= get_set_flags( $ports, 'dst' );
|
||||
$output .= '-m set ';
|
||||
$output .= get_set_flags( $ports, 'src' );
|
||||
} elsif ( $multiport ) {
|
||||
if ( port_count( $sports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
@@ -4641,30 +4654,35 @@ sub do_iproto( $$$ )
|
||||
|
||||
if ( $ports ne '' ) {
|
||||
$invert = $ports =~ s/^!// ? '! ' : '';
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
|
||||
if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) {
|
||||
fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 );
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
push @output , set => ${invert} . get_set_flags( $ports, 'dst' );
|
||||
} else {
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
|
||||
if ( port_count ( $ports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
} elsif ( $invert ) {
|
||||
fatal_error "An inverted port list may only have up to 15 ports";
|
||||
if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) {
|
||||
fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 );
|
||||
|
||||
if ( port_count ( $ports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
} elsif ( $invert ) {
|
||||
fatal_error "An inverted port list may only have up to 15 ports";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ports = validate_port_list $pname , $ports;
|
||||
push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " );
|
||||
$multiport = 1;
|
||||
} else {
|
||||
fatal_error "Missing DEST PORT" unless supplied $ports;
|
||||
$ports = validate_portpair $pname , $ports;
|
||||
$ports = validate_port_list $pname , $ports;
|
||||
push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " );
|
||||
$multiport = 1;
|
||||
} else {
|
||||
fatal_error "Missing DEST PORT" unless supplied $ports;
|
||||
$ports = validate_portpair $pname , $ports;
|
||||
|
||||
if ( $srcndst ) {
|
||||
push @output, multiport => "${invert}--ports ${ports}";
|
||||
} else {
|
||||
push @output, dport => "${invert}${ports}";
|
||||
if ( $srcndst ) {
|
||||
push @output, multiport => "${invert}--ports ${ports}";
|
||||
} else {
|
||||
push @output, dport => "${invert}${ports}";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -4674,8 +4692,10 @@ sub do_iproto( $$$ )
|
||||
if ( $sports ne '' ) {
|
||||
fatal_error "'=' in the SOURCE PORT(S) column requires one or more ports in the DEST PORT(S) column" if $sports eq '=';
|
||||
$invert = $sports =~ s/^!// ? '! ' : '';
|
||||
if ( $multiport ) {
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
push @output, set => ${invert} . get_set_flags( $ports, 'src' );
|
||||
} elsif ( $multiport ) {
|
||||
if ( port_count( $sports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
@@ -4876,62 +4896,79 @@ my %norate = ( DROP => 1, REJECT => 1 );
|
||||
# Create a "-m limit" match for the passed LIMIT/BURST
|
||||
#
|
||||
sub do_ratelimit( $$ ) {
|
||||
my ( $rate, $action ) = @_;
|
||||
my ( $rates, $action ) = @_;
|
||||
|
||||
return '' unless $rate and $rate ne '-';
|
||||
return '' unless $rates and $rates ne '-';
|
||||
|
||||
fatal_error "Rate Limiting not available with $action" if $norate{$action};
|
||||
#
|
||||
# "-m hashlimit" match for the passed LIMIT/BURST
|
||||
#
|
||||
if ( $rate =~ /^[sd]:{1,2}/ ) {
|
||||
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
|
||||
|
||||
my $limit = "-m hashlimit ";
|
||||
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
my $units;
|
||||
my @rates = split_list $rates, 'rate';
|
||||
|
||||
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
fatal_error "Invalid Burst ($7)" unless $7;
|
||||
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
$limit .= "--$match $3 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
if ( @rates == 2 ) {
|
||||
$rates[0] = 's:' . $rates[0];
|
||||
$rates[1] = 'd:' . $rates[1];
|
||||
} elsif ( @rates > 2 ) {
|
||||
fatal error "Only two rates may be specified";
|
||||
}
|
||||
|
||||
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
|
||||
my $limit = '';
|
||||
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
for my $rate ( @rates ) {
|
||||
#
|
||||
# "-m hashlimit" match for the passed LIMIT/BURST
|
||||
#
|
||||
if ( $rate =~ /^([sd]):{1,2}/ ) {
|
||||
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
my $units;
|
||||
|
||||
$limit .= "-m hashlimit ";
|
||||
|
||||
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
fatal_error "Invalid Burst ($7)" unless $7;
|
||||
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
$limit .= "--$match $3 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
|
||||
$limit .= "--hashlimit-htable-expire $expire ";
|
||||
}
|
||||
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
|
||||
|
||||
$limit;
|
||||
} elsif ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($1)" unless $2;
|
||||
fatal_error "Invalid Burst ($5)" unless $5;
|
||||
"-m limit --limit $1 --limit-burst $5 ";
|
||||
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
|
||||
fatal_error "Invalid Rate (${1}${2})" unless $1;
|
||||
"-m limit --limit $rate ";
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
}
|
||||
|
||||
$limit .= "--hashlimit-htable-expire $expire ";
|
||||
}
|
||||
} else {
|
||||
if ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($1)" unless $2;
|
||||
fatal_error "Invalid Burst ($5)" unless $5;
|
||||
$limit = "-m limit --limit $1 --limit-burst $5 ";
|
||||
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
|
||||
fatal_error "Invalid Rate (${1}${2})" unless $1;
|
||||
$limit = "-m limit --limit $rate ";
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$limit;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -5476,7 +5513,7 @@ sub get_set_flags( $$ ) {
|
||||
|
||||
my $rest = '';
|
||||
|
||||
if ( $setname =~ /^(.*)\[([1-6])(?:,(.*))\]$/ ) {
|
||||
if ( $setname =~ /^(.*)\[([1-6])(?:,(.+))?\]$/ ) {
|
||||
$setname = $1;
|
||||
my $count = $2;
|
||||
$rest = $3;
|
||||
@@ -5501,7 +5538,7 @@ sub get_set_flags( $$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $rest ) {
|
||||
if ( supplied $rest ) {
|
||||
my @extensions = split_list($rest, 'ipset option');
|
||||
|
||||
for ( @extensions ) {
|
||||
@@ -5567,6 +5604,8 @@ sub have_ipset_rules() {
|
||||
|
||||
sub get_interface_address( $ );
|
||||
|
||||
sub get_interface_gateway ( $;$ );
|
||||
|
||||
sub record_runtime_address( $$;$ ) {
|
||||
my ( $addrtype, $interface, $protect ) = @_;
|
||||
|
||||
@@ -6504,7 +6543,6 @@ sub set_chain_variables() {
|
||||
|
||||
emit( 'IPTABLES_RESTORE=${IPTABLES}-restore',
|
||||
'[ -x "$IPTABLES_RESTORE" ] || startup_error "$IPTABLES_RESTORE does not exist or is not executable"' );
|
||||
|
||||
emit( 'g_tool=$IPTABLES' );
|
||||
} else {
|
||||
if ( $config{IP6TABLES} ) {
|
||||
@@ -6519,7 +6557,6 @@ sub set_chain_variables() {
|
||||
|
||||
emit( 'IP6TABLES_RESTORE=${IP6TABLES}-restore',
|
||||
'[ -x "$IP6TABLES_RESTORE" ] || startup_error "$IP6TABLES_RESTORE does not exist or is not executable"' );
|
||||
|
||||
emit( 'g_tool=$IP6TABLES' );
|
||||
}
|
||||
|
||||
@@ -6658,11 +6695,10 @@ sub get_interface_gateway ( $;$ ) {
|
||||
$global_variables |= ALL_COMMANDS;
|
||||
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)\n);
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface));
|
||||
} else {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface"
|
||||
);
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
|
||||
}
|
||||
|
||||
$protect ? "\${$variable:-" . NILIP . '}' : "\$$variable";
|
||||
@@ -6768,16 +6804,40 @@ sub have_global_variables() {
|
||||
have_capability( 'ADDRTYPE' ) ? $global_variables : $global_variables | NOT_RESTORE;
|
||||
}
|
||||
|
||||
sub have_address_variables() {
|
||||
( keys %interfaceaddr || keys %interfacemacs || keys %interfacegateways );
|
||||
}
|
||||
|
||||
#
|
||||
# Generate setting of run-time global shell variables
|
||||
#
|
||||
sub set_global_variables( $ ) {
|
||||
sub set_global_variables( $$ ) {
|
||||
|
||||
my $setall = shift;
|
||||
my ( $setall, $conditional ) = @_;
|
||||
|
||||
emit $_ for values %interfaceaddr;
|
||||
emit $_ for values %interfacegateways;
|
||||
emit $_ for values %interfacemacs;
|
||||
if ( $conditional ) {
|
||||
my ( $interface, $code );
|
||||
|
||||
while ( ( $interface, $code ) = each %interfaceaddr ) {
|
||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
||||
}
|
||||
|
||||
while ( ( $interface, $code ) = each %interfacegateways ) {
|
||||
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
|
||||
push_indent;
|
||||
emit( $code );
|
||||
pop_indent;
|
||||
emit( qq(fi\n) );
|
||||
}
|
||||
|
||||
while ( ( $interface, $code ) = each %interfacemacs ) {
|
||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
||||
}
|
||||
} else {
|
||||
emit $_ for values %interfaceaddr;
|
||||
emit "$_\n" for values %interfacegateways;
|
||||
emit $_ for values %interfacemacs;
|
||||
}
|
||||
|
||||
if ( $setall ) {
|
||||
emit $_ for values %interfaceaddrs;
|
||||
@@ -7650,7 +7710,7 @@ sub add_interface_options( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
$chainref->{digest} = sha1 $digest;
|
||||
$chainref->{digest} = sha1_hex $digest;
|
||||
}
|
||||
#
|
||||
# Insert jumps to the interface chains into the rules chains
|
||||
@@ -7892,14 +7952,18 @@ sub emitr1( $$ ) {
|
||||
|
||||
sub save_dynamic_chains() {
|
||||
|
||||
my $tool;
|
||||
my $tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}';
|
||||
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
|
||||
|
||||
emit ( 'if [ "$COMMAND" = restart -o "$COMMAND" = refresh ]; then' );
|
||||
push_indent;
|
||||
|
||||
if ( have_capability 'IPTABLES_S' ) {
|
||||
$tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}';
|
||||
emit( 'if [ -n "$g_counters" ]; then' ,
|
||||
" ${tool}-save --counters | grep -vE '[ :]shorewall ' > \${VARDIR}/.${utility}-input",
|
||||
"fi\n"
|
||||
);
|
||||
|
||||
if ( have_capability 'IPTABLES_S' ) {
|
||||
emit <<"EOF";
|
||||
if chain_exists 'UPnP -t nat'; then
|
||||
$tool -t nat -S UPnP | tail -n +2 > \${VARDIR}/.UPnP
|
||||
@@ -7914,11 +7978,12 @@ else
|
||||
fi
|
||||
|
||||
if chain_exists dynamic; then
|
||||
$tool -S dynamic | tail -n +2 > \${VARDIR}/.dynamic
|
||||
$tool -S dynamic | tail -n +2 | fgrep -v -- '-j ACCEPT' > \${VARDIR}/.dynamic
|
||||
else
|
||||
rm -f \${VARDIR}/.dynamic
|
||||
fi
|
||||
EOF
|
||||
|
||||
} else {
|
||||
$tool = $family == F_IPV4 ? '${IPTABLES}-save' : '${IP6TABLES}-save';
|
||||
|
||||
@@ -8008,7 +8073,7 @@ sub create_save_ipsets() {
|
||||
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
emit( ' local file' ,
|
||||
'',
|
||||
' file=$1'
|
||||
' file=${1:-${VARDIR}/save.ipsets}'
|
||||
);
|
||||
|
||||
if ( @ipsets ) {
|
||||
@@ -8034,7 +8099,9 @@ sub create_save_ipsets() {
|
||||
emit( '',
|
||||
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" ,
|
||||
" \$IPSET save \$set >> \$file" ,
|
||||
" done" );
|
||||
" done" ,
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
emit ( '' ,
|
||||
' if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then' ,
|
||||
@@ -8051,7 +8118,9 @@ sub create_save_ipsets() {
|
||||
' fi' );
|
||||
}
|
||||
|
||||
emit("}\n" );
|
||||
emit( " return 0",
|
||||
'',
|
||||
"}\n" );
|
||||
} elsif ( @ipsets || $globals{SAVED_IPSETS} ) {
|
||||
emit( '' ,
|
||||
' rm -f ${VARDIR}/ipsets.tmp' ,
|
||||
@@ -8073,10 +8142,13 @@ sub create_save_ipsets() {
|
||||
emit( '' ,
|
||||
" grep -qE -- \"(-N|^create )\" \${VARDIR}/ipsets.tmp && cat \${VARDIR}/ipsets.tmp >> \$file\n" ,
|
||||
'' ,
|
||||
' return 0',
|
||||
'' ,
|
||||
"}\n" );
|
||||
}
|
||||
} elsif ( $config{SAVE_IPSETS} ) {
|
||||
emit( ' error_message "WARNING: No ipsets were saved"',
|
||||
' return 1',
|
||||
"}\n" );
|
||||
} else {
|
||||
emit( ' true',
|
||||
@@ -8223,17 +8295,29 @@ sub create_netfilter_load( $ ) {
|
||||
'# Create the input to iptables-restore/ip6tables-restore and pass that input to the utility',
|
||||
'#',
|
||||
'setup_netfilter()',
|
||||
'{'
|
||||
);
|
||||
'{',
|
||||
' local option',
|
||||
);
|
||||
|
||||
push_indent;
|
||||
|
||||
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
|
||||
my $UTILITY = $family == F_IPV4 ? 'IPTABLES_RESTORE' : 'IP6TABLES_RESTORE';
|
||||
|
||||
save_progress_message "Preparing $utility input...";
|
||||
emit( '',
|
||||
'if [ "$COMMAND" = restart -a -n "$g_counters" ] && chain_exists $g_sha1sum1 && chain_exists $g_sha1sum2 ; then',
|
||||
' option="--counters"',
|
||||
'',
|
||||
' progress_message "Reusing existing ruleset..."',
|
||||
'',
|
||||
'else'
|
||||
);
|
||||
|
||||
emit '';
|
||||
push_indent;
|
||||
|
||||
emit 'option=';
|
||||
|
||||
save_progress_message "Preparing $utility input...";
|
||||
|
||||
emit "exec 3>\${VARDIR}/.${utility}-input";
|
||||
|
||||
@@ -8273,6 +8357,14 @@ sub create_netfilter_load( $ ) {
|
||||
push @chains, $chainref;
|
||||
}
|
||||
}
|
||||
#
|
||||
# SHA1SUM chains for handling 'restart -s'
|
||||
#
|
||||
if ( $table eq 'filter' ) {
|
||||
emit_unindented ':$g_sha1sum1 - [0:0]';
|
||||
emit_unindented ':$g_sha1sum2 - [0:0]';
|
||||
}
|
||||
|
||||
#
|
||||
# Then emit the rules
|
||||
#
|
||||
@@ -8287,20 +8379,24 @@ sub create_netfilter_load( $ ) {
|
||||
}
|
||||
|
||||
enter_cmd_mode;
|
||||
|
||||
pop_indent, emit "fi\n";
|
||||
#
|
||||
# Now generate the actual ip[6]tables-restore command
|
||||
#
|
||||
emit( 'exec 3>&-',
|
||||
'',
|
||||
'[ -n "$g_debug_iptables" ] && command=debug_restore_input || command=$' . $UTILITY,
|
||||
'',
|
||||
'progress_message2 "Running $command..."',
|
||||
'',
|
||||
"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"
|
||||
);
|
||||
'' );
|
||||
|
||||
emit( '[ -n "$g_debug_iptables" ] && command=debug_restore_input || command="$' . $UTILITY . ' $option"' );
|
||||
|
||||
emit( '',
|
||||
'progress_message2 "Running $command..."',
|
||||
'',
|
||||
"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"
|
||||
);
|
||||
|
||||
pop_indent;
|
||||
|
||||
@@ -8639,7 +8735,7 @@ sub get_inline_matches( $ ) {
|
||||
# Split the passed target into the basic target and parameter
|
||||
#
|
||||
sub get_target_param( $ ) {
|
||||
my ( $target, $param ) = split '/', $_[0];
|
||||
my ( $target, $param ) = split '/', $_[0], 2;
|
||||
|
||||
unless ( defined $param ) {
|
||||
( $target, $param ) = ( $1, $2 ) if $target =~ /^(.*?)[(](.*)[)]$/;
|
||||
|
@@ -274,10 +274,21 @@ sub generate_script_2() {
|
||||
'detect_configuration()',
|
||||
'{' );
|
||||
|
||||
my $global_variables = have_global_variables;
|
||||
my $global_variables = have_global_variables;
|
||||
my $optional_interfaces = find_interfaces_by_option( 'optional' );
|
||||
|
||||
push_indent;
|
||||
|
||||
if ( have_address_variables || @$optional_interfaces ) {
|
||||
emit( 'local interface',
|
||||
'',
|
||||
'interface="$1"',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
map_provider_to_interface if have_providers;
|
||||
|
||||
if ( $global_variables ) {
|
||||
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
@@ -292,7 +303,7 @@ sub generate_script_2() {
|
||||
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
|
||||
set_global_variables(0);
|
||||
set_global_variables(0, 0);
|
||||
|
||||
handle_optional_interfaces(0);
|
||||
}
|
||||
@@ -306,10 +317,10 @@ sub generate_script_2() {
|
||||
push_indent;
|
||||
}
|
||||
|
||||
set_global_variables(1);
|
||||
set_global_variables(1,1);
|
||||
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
handle_optional_interfaces(0);
|
||||
handle_optional_interfaces(1);
|
||||
emit ';;';
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
@@ -352,7 +363,8 @@ sub generate_script_3($) {
|
||||
|
||||
emit "#\n# Start/Restart the Firewall\n#";
|
||||
|
||||
emit 'define_firewall() {';
|
||||
emit( 'define_firewall() {',
|
||||
' local options' );
|
||||
|
||||
push_indent;
|
||||
|
||||
@@ -470,10 +482,12 @@ sub generate_script_3($) {
|
||||
emit( '',
|
||||
'if [ $COMMAND = restore ]; then',
|
||||
' iptables_save_file=${VARDIR}/$(basename $0)-iptables',
|
||||
' if [ -f $iptables_save_file ]; then' );
|
||||
' if [ -f $iptables_save_file ]; then',
|
||||
' [ -n "$g_counters" ] && options=--counters'
|
||||
);
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
emit( ' cat $iptables_save_file | $IPTABLES_RESTORE # Use this nonsensical form to appease SELinux' );
|
||||
emit( ' cat $iptables_save_file | $IPTABLES_RESTORE $options # Use this nonsensical form to appease SELinux' );
|
||||
|
||||
emit( '',
|
||||
' arptables_save_file=${VARDIR}/$(basename $0)-arptables',
|
||||
@@ -483,7 +497,7 @@ sub generate_script_3($) {
|
||||
if $config{SAVE_ARPTABLES};
|
||||
|
||||
} else {
|
||||
emit ' cat $iptables_save_file | $IP6TABLES_RESTORE # Use this nonsensical form to appease SELinux'
|
||||
emit ' cat $iptables_save_file | $IP6TABLES_RESTORE $options # Use this nonsensical form to appease SELinux'
|
||||
}
|
||||
|
||||
emit( ' else',
|
||||
@@ -512,45 +526,41 @@ EOF
|
||||
#
|
||||
# Use a parameter list rather than 'here documents' to avoid an extra blank line
|
||||
#
|
||||
emit(
|
||||
' run_refreshed_exit',
|
||||
' do_iptables -N shorewall' );
|
||||
emit( ' run_refreshed_exit',
|
||||
' do_iptables -N shorewall' );
|
||||
|
||||
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
|
||||
emit(
|
||||
" set_state Started $config_dir",
|
||||
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
|
||||
'else',
|
||||
' setup_netfilter'
|
||||
" set_state Started $config_dir",
|
||||
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
|
||||
'else',
|
||||
' setup_netfilter'
|
||||
);
|
||||
|
||||
push_indent;
|
||||
emit 'setup_arptables' if $have_arptables;
|
||||
setup_load_distribution;
|
||||
pop_indent;
|
||||
|
||||
emit<<'EOF';
|
||||
conditionally_flush_conntrack
|
||||
EOF
|
||||
emit( " conditionally_flush_conntrack\n" );
|
||||
|
||||
push_indent;
|
||||
initialize_switches;
|
||||
setup_forwarding( $family , 0 );
|
||||
pop_indent;
|
||||
|
||||
emit<<"EOF";
|
||||
run_start_exit
|
||||
do_iptables -N shorewall
|
||||
EOF
|
||||
emit( ' run_start_exit',
|
||||
' do_iptables -N shorewall',
|
||||
'' );
|
||||
|
||||
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
emit( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
|
||||
emit<<"EOF";
|
||||
set_state Started $config_dir
|
||||
my_pathname=\$(my_pathname)
|
||||
[ \$my_pathname = \${VARDIR}/firewall ] || cp -f \$my_pathname \${VARDIR}/firewall
|
||||
run_started_exit
|
||||
fi
|
||||
EOF
|
||||
emit( " set_state Started $config_dir",
|
||||
' my_pathname=$(my_pathname)',
|
||||
' [ $my_pathname = ${VARDIR}/firewall ] || cp -f $my_pathname ${VARDIR}/firewall',
|
||||
' run_started_exit',
|
||||
"fi\n" );
|
||||
|
||||
emit<<'EOF';
|
||||
date > ${VARDIR}/restarted
|
||||
@@ -650,10 +660,7 @@ sub compiler {
|
||||
|
||||
set_config_path( $config_path ) if $config_path;
|
||||
|
||||
if ( $directory ne '' ) {
|
||||
fatal_error "$directory is not an existing directory" unless -d $directory;
|
||||
set_shorewall_dir( $directory );
|
||||
}
|
||||
set_shorewall_dir( $directory ) if $directory ne '';
|
||||
|
||||
$verbosity = 1 if $debug && $verbosity < 1;
|
||||
|
||||
@@ -666,15 +673,6 @@ sub compiler {
|
||||
#
|
||||
get_configuration( $export , $update , $annotate , $directives , $inline );
|
||||
#
|
||||
# Create a temp file to hold the script
|
||||
#
|
||||
if ( $scriptfilename ) {
|
||||
set_command( 'compile', 'Compiling', 'Compiled' );
|
||||
create_temp_script( $scriptfilename , $export );
|
||||
} else {
|
||||
set_command( 'check', 'Checking', 'Checked' );
|
||||
}
|
||||
#
|
||||
# Chain table initialization depends on shorewall.conf and capabilities. So it must be deferred until
|
||||
# now when shorewall.conf has been processed and the capabilities have been determined.
|
||||
#
|
||||
@@ -684,6 +682,15 @@ sub compiler {
|
||||
#
|
||||
run_user_exit1 'compile';
|
||||
#
|
||||
# Create a temp file to hold the script
|
||||
#
|
||||
if ( $scriptfilename ) {
|
||||
set_command( 'compile', 'Compiling', 'Compiled' );
|
||||
create_temp_script( $scriptfilename , $export );
|
||||
} else {
|
||||
set_command( 'check', 'Checking', 'Checked' );
|
||||
}
|
||||
#
|
||||
# Z O N E D E F I N I T I O N
|
||||
# (Produces no output to the compiled script)
|
||||
#
|
||||
@@ -855,7 +862,7 @@ sub compiler {
|
||||
#
|
||||
# Apply Policies
|
||||
#
|
||||
apply_policy_rules;
|
||||
complete_policy_chains;
|
||||
#
|
||||
# Reject Action
|
||||
#
|
||||
|
@@ -40,6 +40,7 @@ use Cwd qw(abs_path getcwd);
|
||||
use autouse 'Carp' => qw(longmess confess);
|
||||
use Scalar::Util 'reftype';
|
||||
use FindBin;
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
#
|
||||
@@ -88,6 +89,7 @@ our @EXPORT = qw(
|
||||
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
|
||||
|
||||
our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
generate_sha1
|
||||
finalize_script
|
||||
enable_script
|
||||
disable_script
|
||||
@@ -230,7 +232,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
|
||||
Exporter::export_ok_tags('internal');
|
||||
|
||||
our $VERSION = '4.6.0-Beta1';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
#
|
||||
# describe the current command, it's present progressive, and it's completion.
|
||||
@@ -299,7 +301,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 SUBSYSLOCK LOG_VERBOSITY/;
|
||||
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY/;
|
||||
#
|
||||
# From parsing the capabilities file or detecting capabilities
|
||||
#
|
||||
@@ -392,6 +394,9 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
MASQUERADE_TGT => 'MASQUERADE Target',
|
||||
UDPLITEREDIRECT => 'UDPLITE Port Redirection',
|
||||
NEW_TOS_MATCH => 'New tos Match',
|
||||
TARPIT_TARGET => 'TARPIT Target',
|
||||
IFACE_MATCH => 'Iface Match',
|
||||
TCPMSS_TARGET => 'TCPMSS Target',
|
||||
|
||||
AMANDA_HELPER => 'Amanda Helper',
|
||||
FTP_HELPER => 'FTP Helper',
|
||||
@@ -408,7 +413,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
SIP0_HELPER => 'SIP-0 Helper',
|
||||
SNMP_HELPER => 'SNMP Helper',
|
||||
TFTP_HELPER => 'TFTP Helper',
|
||||
TFTP0_HELPER => 'TFTP-0 Helper',
|
||||
TFTP0_HELPER => 'TFTP-0 Helper',
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
@@ -710,7 +715,7 @@ sub initialize( $;$$) {
|
||||
EXPORT => 0,
|
||||
KLUDGEFREE => '',
|
||||
VERSION => "4.5.19-Beta1",
|
||||
CAPVERSION => 40600 ,
|
||||
CAPVERSION => 40609 ,
|
||||
);
|
||||
#
|
||||
# From shorewall.conf file
|
||||
@@ -875,9 +880,6 @@ sub initialize( $;$$) {
|
||||
#
|
||||
# Valid log levels
|
||||
#
|
||||
# Note that we don't include LOGMARK; that is so we can default its
|
||||
# priority to 'info' (LOGMARK itself defaults to 'warn').
|
||||
#
|
||||
%validlevels = ( DEBUG => 7,
|
||||
INFO => 6,
|
||||
NOTICE => 5,
|
||||
@@ -977,6 +979,9 @@ sub initialize( $;$$) {
|
||||
UDPLITEREDIRECT => undef,
|
||||
NEW_TOS_MATCH => undef,
|
||||
REAP_OPTION => undef,
|
||||
TARPIT_TARGET => undef,
|
||||
IFACE_MATCH => undef,
|
||||
TCPMSS_TARGET => undef,
|
||||
|
||||
AMANDA_HELPER => undef,
|
||||
FTP_HELPER => undef,
|
||||
@@ -1266,9 +1271,7 @@ sub cleanup_iptables() {
|
||||
qt1( "$iptables $iptablesw -t raw -X $sillyname" );
|
||||
}
|
||||
|
||||
$sillyname = $sillyname1 = undef;
|
||||
|
||||
$sillyname = '';
|
||||
$sillyname = $sillyname1 = '';
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1589,7 +1592,7 @@ sub set_command( $$$ ) {
|
||||
#
|
||||
# Print the current TOD to STDOUT.
|
||||
#
|
||||
sub timestamp() {
|
||||
sub get_localtime() {
|
||||
our @localtime = localtime;
|
||||
printf '%02d:%02d:%02d ', @localtime[2,1,0];
|
||||
}
|
||||
@@ -1606,7 +1609,7 @@ sub progress_message {
|
||||
$line =~ s/\s+/ /g;
|
||||
|
||||
if ( $verbosity > 1 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
#
|
||||
# We use this function to display messages containing raw config file images which may contains tabs (including multiple tabs in succession).
|
||||
# The following makes such messages look more readable and uniform
|
||||
@@ -1629,7 +1632,7 @@ sub progress_message_nocompress {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity > 1 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1650,7 +1653,7 @@ sub progress_message2 {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity > 0 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1671,7 +1674,7 @@ sub progress_message3 {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity >= 0 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1760,6 +1763,13 @@ sub create_temp_script( $$ ) {
|
||||
|
||||
}
|
||||
|
||||
# Generate the SHA1 digest of the (incomplete) script
|
||||
#
|
||||
sub generate_sha1() {
|
||||
my $data = `cat $tempfile`;
|
||||
sha1_hex $data;
|
||||
}
|
||||
|
||||
#
|
||||
# Finalize the script file
|
||||
#
|
||||
@@ -1769,6 +1779,19 @@ sub finalize_script( $ ) {
|
||||
$script = 0;
|
||||
|
||||
if ( $file ne '-' ) {
|
||||
my $sha1sum = generate_sha1;
|
||||
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
|
||||
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
|
||||
|
||||
@ARGV = ( $tempfile );
|
||||
$^I = '';
|
||||
|
||||
while ( <> ) {
|
||||
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
|
||||
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
|
||||
print;
|
||||
}
|
||||
|
||||
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";
|
||||
chmod 0700, $file or fatal_error "Cannot secure $file for execute access";
|
||||
progress_message3 "Shorewall configuration compiled to $file" unless $export;
|
||||
@@ -1818,7 +1841,7 @@ sub set_config_path( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# Set $debug
|
||||
# Set $debug and $confess
|
||||
#
|
||||
sub set_debug( $$ ) {
|
||||
$debug = shift;
|
||||
@@ -1843,6 +1866,9 @@ sub find_file($)
|
||||
"$config_path[0]$filename";
|
||||
}
|
||||
|
||||
#
|
||||
# Split a comma-separated list into a Perl array
|
||||
#
|
||||
sub split_list( $$;$ ) {
|
||||
my ($list, $type, $origlist ) = @_;
|
||||
|
||||
@@ -1851,6 +1877,9 @@ sub split_list( $$;$ ) {
|
||||
split /,/, $list;
|
||||
}
|
||||
|
||||
#
|
||||
# This version handles parenthetical list elements with embedded commas. It removes the parentheses
|
||||
#
|
||||
sub split_list1( $$;$ ) {
|
||||
my ($list, $type, $keepparens ) = @_;
|
||||
|
||||
@@ -2002,6 +2031,9 @@ sub split_list3( $$ ) {
|
||||
@list2;
|
||||
}
|
||||
|
||||
#
|
||||
# Splits the columns of a config file record
|
||||
#
|
||||
sub split_columns( $ ) {
|
||||
my ($list) = @_;
|
||||
|
||||
@@ -3366,7 +3398,7 @@ sub read_a_line($) {
|
||||
# Must check for shell/perl before doing variable expansion
|
||||
#
|
||||
if ( $options & EMBEDDED_ENABLED ) {
|
||||
if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\??SHELL\s*//i ) {
|
||||
if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\?SHELL\s*//i || $currentline =~ s/^\s*SHELL\s+// ) {
|
||||
handle_first_entry if $first_entry;
|
||||
embedded_shell( $1 );
|
||||
next;
|
||||
@@ -3829,7 +3861,7 @@ sub load_kernel_modules( ) {
|
||||
|
||||
close LSMOD;
|
||||
|
||||
$config{MODULE_SUFFIX} = 'o gz ko o.gz ko.gz' unless $config{MODULE_SUFFIX};
|
||||
$config{MODULE_SUFFIX} = 'o gz xz ko o.gz o.xz ko.gz ko.xz' unless $config{MODULE_SUFFIX};
|
||||
|
||||
my @suffixes = split /\s+/ , $config{MODULE_SUFFIX};
|
||||
|
||||
@@ -4197,6 +4229,10 @@ sub Addrtype() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -m addrtype --src-type BROADCAST -j ACCEPT" );
|
||||
}
|
||||
|
||||
sub Tarpit_Target() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp -j TARPIT" );
|
||||
}
|
||||
|
||||
sub Tcpmss_Match() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT" );
|
||||
}
|
||||
@@ -4427,6 +4463,14 @@ sub Arptables_JF() {
|
||||
}
|
||||
}
|
||||
|
||||
sub Iface_Match() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -m iface --iface lo --loopback" );
|
||||
}
|
||||
|
||||
sub Tcpmss_Target() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
|
||||
}
|
||||
|
||||
our %detect_capability =
|
||||
( ACCOUNT_TARGET =>\&Account_Target,
|
||||
AMANDA_HELPER => \&Amanda_Helper,
|
||||
@@ -4459,6 +4503,7 @@ our %detect_capability =
|
||||
HASHLIMIT_MATCH => \&Hashlimit_Match,
|
||||
HEADER_MATCH => \&Header_Match,
|
||||
HELPER_MATCH => \&Helper_Match,
|
||||
IFACE_MATCH => \&Iface_Match,
|
||||
IMQ_TARGET => \&Imq_Target,
|
||||
IPMARK_TARGET => \&IPMark_Target,
|
||||
IPP2P_MATCH => \&Ipp2p_Match,
|
||||
@@ -4511,7 +4556,9 @@ our %detect_capability =
|
||||
SIP0_HELPER => \&SIP0_Helper,
|
||||
SNMP_HELPER => \&SNMP_Helper,
|
||||
STATISTIC_MATCH => \&Statistic_Match,
|
||||
TARPIT_TARGET => \&Tarpit_Target,
|
||||
TCPMSS_MATCH => \&Tcpmss_Match,
|
||||
TCPMSS_TARGET => \&Tcpmss_Target,
|
||||
TFTP_HELPER => \&TFTP_Helper,
|
||||
TFTP0_HELPER => \&TFTP0_Helper,
|
||||
TIME_MATCH => \&Time_Match,
|
||||
@@ -4663,6 +4710,9 @@ sub determine_capabilities() {
|
||||
$capabilities{MASQUERADE_TGT} = detect_capability( 'MASQUERADE_TGT' );
|
||||
$capabilities{UDPLITEREDIRECT} = detect_capability( 'UDPLITEREDIRECT' );
|
||||
$capabilities{NEW_TOS_MATCH} = detect_capability( 'NEW_TOS_MATCH' );
|
||||
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
|
||||
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
|
||||
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
|
||||
|
||||
unless ( have_capability 'CT_TARGET' ) {
|
||||
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
|
||||
@@ -4730,6 +4780,7 @@ sub ensure_config_path() {
|
||||
#
|
||||
sub set_shorewall_dir( $ ) {
|
||||
$shorewall_dir = shift;
|
||||
fatal_error "$shorewall_dir is not an existing directory" unless -d $shorewall_dir;
|
||||
ensure_config_path;
|
||||
}
|
||||
|
||||
@@ -4966,6 +5017,10 @@ sub read_capabilities() {
|
||||
warning_message "Your capabilities file does not contain a Kernel Version -- using 2.6.30";
|
||||
$capabilities{KERNELVERSION} = 20630;
|
||||
}
|
||||
#
|
||||
# Assume that this is available when using an old capabilities files
|
||||
#
|
||||
$capabilities{TCPMSS_TARGET} = 1 if ( ( $capabilities{CAPVERSION} || 0 ) < 40609 );
|
||||
|
||||
$helpers_aliases{ftp} = 'ftp-0', $capabilities{FTP_HELPER} = 1 if $capabilities{FTP0_HELPER};
|
||||
$helpers_aliases{irc} = 'irc-0', $capabilities{IRC_HELPER} = 1 if $capabilities{IRC0_HELPER};
|
||||
@@ -5056,15 +5111,23 @@ sub unsupported_yes_no_warning( $ ) {
|
||||
#
|
||||
# Process the params file
|
||||
#
|
||||
sub get_params() {
|
||||
sub get_params( $ ) {
|
||||
my $export = $_[0];
|
||||
|
||||
my $fn = find_file 'params';
|
||||
|
||||
my %reserved = ( COMMAND => 1, CONFDIR => 1, SHAREDIR => 1, VARDIR => 1 );
|
||||
|
||||
if ( -f $fn ) {
|
||||
my $shellpath = $export ? '/bin/sh' : $config{SHOREWALL_SHELL} || '/bin/sh';
|
||||
|
||||
$shellpath = which( $shellpath ) unless $shellpath =~ '/';
|
||||
|
||||
fatal_error "SHOREWALL_SHELL ($shellpath) is not found or is not executable" unless -x $shellpath;
|
||||
|
||||
progress_message2 "Processing $fn ...";
|
||||
|
||||
my $command = "$FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family";
|
||||
my $command = "$shellpath $FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family";
|
||||
#
|
||||
# getparams silently sources the params file under 'set -a', then executes 'export -p'
|
||||
#
|
||||
@@ -5334,7 +5397,7 @@ sub get_configuration( $$$$$ ) {
|
||||
|
||||
ensure_config_path;
|
||||
|
||||
get_params;
|
||||
get_params( $export );
|
||||
|
||||
process_shorewall_conf( $update, $annotate, $directives );
|
||||
|
||||
@@ -5552,8 +5615,9 @@ sub get_configuration( $$$$$ ) {
|
||||
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
||||
default_yes_no 'CLEAR_TC' , $family == F_IPV4 ? 'Yes' : '';
|
||||
|
||||
if ( supplied $config{CLAMPMSS} ) {
|
||||
default_yes_no 'CLAMPMSS' , '' unless $config{CLAMPMSS} =~ /^\d+$/;
|
||||
if ( supplied( $val = $config{CLAMPMSS} ) ) {
|
||||
default_yes_no 'CLAMPMSS' , '' unless $val =~ /^\d+$/;
|
||||
require_capability 'TCPMSS_TARGET', "CLAMPMSS=$val", 's' if $config{CLAMPMSS};
|
||||
} else {
|
||||
$config{CLAMPMSS} = '';
|
||||
}
|
||||
@@ -5784,7 +5848,7 @@ sub get_configuration( $$$$$ ) {
|
||||
} elsif ( $val eq 'netlink' ) {
|
||||
$val = 'nfnetlink_log';
|
||||
} elsif ( $val eq 'LOG' ) {
|
||||
$val = $family == F_IPV4 ? 'ipt_LOG' : 'ip6t_log';
|
||||
$val = $family == F_IPV4 ? 'ipt_LOG' : 'ip6t_LOG';
|
||||
} else {
|
||||
fatal_error "Invalid LOG Backend ($val)";
|
||||
}
|
||||
|
@@ -854,7 +854,7 @@ sub add_common_rules ( $$ ) {
|
||||
|
||||
my $interfaceref = find_interface $interface;
|
||||
|
||||
unless ( $interfaceref->{physical} eq 'lo' ) {
|
||||
unless ( $interfaceref->{physical} eq loopback_interface ) {
|
||||
unless ( $interfaceref->{options}{ignore} & NO_SFILTER || $interfaceref->{options}{rpfilter} ) {
|
||||
|
||||
my @filters = @{$interfaceref->{filter}};
|
||||
@@ -1452,7 +1452,7 @@ sub handle_loopback_traffic() {
|
||||
my $rawout = $raw_table->{OUTPUT};
|
||||
my $rulenum = 0;
|
||||
my $loopback = loopback_zones;
|
||||
my $loref = known_interface('lo');
|
||||
my $loref = known_interface(loopback_interface);
|
||||
|
||||
my $unmanaged;
|
||||
my $outchainref;
|
||||
@@ -1463,17 +1463,29 @@ sub handle_loopback_traffic() {
|
||||
# We have a vserver zone -- route output through a separate chain
|
||||
#
|
||||
$outchainref = new_standard_chain 'loopback';
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => 'lo';
|
||||
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, iface => '--dev-out --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => loopback_interface;
|
||||
}
|
||||
} else {
|
||||
#
|
||||
# Only the firewall -- just use the OUTPUT chain
|
||||
#
|
||||
if ( $unmanaged = $loref && $loref->{options}{unmanaged} ) {
|
||||
add_ijump( $filter_table->{INPUT}, j => 'ACCEPT', i => 'lo' );
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => 'lo' );
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', iface => '--dev-out --loopback' );
|
||||
} else {
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => loopback_interface );
|
||||
}
|
||||
} else {
|
||||
$outchainref = $filter_table->{OUTPUT};
|
||||
@rule = ( o => 'lo');
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
@rule = ( iface => '--dev-out --loopback' );
|
||||
} else {
|
||||
@rule = ( o => loopback_interface );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1552,7 +1564,7 @@ sub add_interface_jumps {
|
||||
our %forward_jump_added;
|
||||
my @interfaces = grep $_ ne '%vserver%', @_;
|
||||
my $dummy;
|
||||
my $lo_jump_added = interface_zone( 'lo' ) && ! get_interface_option( 'lo', 'destonly' );
|
||||
my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
|
||||
#
|
||||
# Add Nat jumps
|
||||
#
|
||||
@@ -1582,7 +1594,13 @@ sub add_interface_jumps {
|
||||
my $outputref = $filter_table->{output_chain $interface};
|
||||
my $interfaceref = find_interface($interface);
|
||||
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' if $interfaceref->{physical} eq '+' && ! $lo_jump_added++;
|
||||
if ( $interfaceref->{physical} eq '+' && ! $lo_jump_added++ ) {
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $interfaceref->{options}{port} ) {
|
||||
my $bridge = $interfaceref->{bridge};
|
||||
@@ -1621,7 +1639,13 @@ sub add_interface_jumps {
|
||||
}
|
||||
}
|
||||
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' unless $lo_jump_added++;
|
||||
unless ( $lo_jump_added++ ) {
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
|
||||
}
|
||||
}
|
||||
|
||||
handle_loopback_traffic;
|
||||
}
|
||||
@@ -2394,7 +2418,7 @@ EOF
|
||||
case $COMMAND in
|
||||
stop|clear|restore)
|
||||
if chain_exists dynamic; then
|
||||
${IPTABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic
|
||||
${IPTABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@@ -2409,7 +2433,7 @@ EOF
|
||||
case $COMMAND in
|
||||
stop|clear|restore)
|
||||
if chain_exists dynamic; then
|
||||
${IP6TABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic
|
||||
${IP6TABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@@ -2551,8 +2575,13 @@ EOF
|
||||
|
||||
process_routestopped unless process_stoppedrules;
|
||||
|
||||
add_ijump $input, j => 'ACCEPT', i => 'lo';
|
||||
add_ijump $output, j => 'ACCEPT', o => 'lo' unless $config{ADMINISABSENTMINDED};
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $input, j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
add_ijump $output, j => 'ACCEPT', iface => '--dev-out --loopback' unless $config{ADMINISABSENTMINDED};
|
||||
} else {
|
||||
add_ijump $input, j => 'ACCEPT', i => loopback_interface;
|
||||
add_ijump $output, j => 'ACCEPT', o => loopback_interface unless $config{ADMINISABSENTMINDED};
|
||||
}
|
||||
|
||||
my $interfaces = find_interfaces_by_option 'dhcp';
|
||||
|
||||
|
@@ -356,15 +356,35 @@ sub setup_log_backend($) {
|
||||
|
||||
emit( 'progress_message2 "Setting up log backend"',
|
||||
'',
|
||||
"if [ -f $file ]; then",
|
||||
" if echo $setting > $file; then",
|
||||
" progress_message 'Log Backend set to $setting'",
|
||||
' else',
|
||||
" error_message 'WARNING: Unable to set log backend to $setting'",
|
||||
' fi',
|
||||
'else',
|
||||
" error_message 'WARNING: $file does not exist - log backend not set'",
|
||||
"fi\n" );
|
||||
"if [ -f $file ]; then"
|
||||
);
|
||||
|
||||
if ( $setting =~ /ip6?t_log/i ) {
|
||||
my $alternative = 'nf_log_ipv' . $family;
|
||||
|
||||
emit( " setting=$setting",
|
||||
'',
|
||||
" fgrep -q $setting /proc/net/netfilter/nf_log || setting=$alternative",
|
||||
'',
|
||||
" if echo \$setting > $file; then",
|
||||
' progress_message "Log Backend set to $setting"',
|
||||
' else',
|
||||
' error_message "WARNING: Unable to set log backend to $setting"',
|
||||
' fi',
|
||||
'else',
|
||||
" error_message 'WARNING: $file does not exist - log backend not set'",
|
||||
"fi\n"
|
||||
);
|
||||
} else {
|
||||
emit( " if echo $setting > $file; then",
|
||||
" progress_message 'Log Backend set to $setting'",
|
||||
' else',
|
||||
" error_message 'WARNING: Unable to set log backend to $setting'",
|
||||
' fi',
|
||||
'else',
|
||||
" error_message 'WARNING: $file does not exist - log backend not set'",
|
||||
"fi\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,9 +44,10 @@ our @EXPORT = qw( process_providers
|
||||
compile_updown
|
||||
setup_load_distribution
|
||||
have_providers
|
||||
map_provider_to_interface
|
||||
);
|
||||
our @EXPORT_OK = qw( initialize provider_realm );
|
||||
our $VERSION = '4.4_24';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
use constant { LOCAL_TABLE => 255,
|
||||
MAIN_TABLE => 254,
|
||||
@@ -530,8 +531,9 @@ sub process_a_provider( $ ) {
|
||||
$track = 0;
|
||||
} elsif ( $option =~ /^balance=(\d+)$/ ) {
|
||||
fatal_error q('balance=<weight>' is not available in IPv6) if $family == F_IPV6;
|
||||
fatal_error 'The balance setting must be non-zero' unless $1;
|
||||
$balance = $1;
|
||||
} elsif ( $option eq 'balance' ) {
|
||||
} elsif ( $option eq 'balance' || $option eq 'primary') {
|
||||
$balance = 1;
|
||||
} elsif ( $option eq 'loose' ) {
|
||||
$loose = 1;
|
||||
@@ -566,8 +568,8 @@ sub process_a_provider( $ ) {
|
||||
$track = 0 if $config{TRACK_PROVIDERS};
|
||||
$default_balance = 0 if $config{USE_DEFAULT_RT};
|
||||
} elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) {
|
||||
$load = $1;
|
||||
require_capability 'STATISTIC_MATCH', "load=$load", 's';
|
||||
$load = sprintf "%1.8f", $1;
|
||||
require_capability 'STATISTIC_MATCH', "load=$1", 's';
|
||||
} elsif ( $option eq 'autosrc' ) {
|
||||
$noautosrc = 0;
|
||||
} elsif ( $option eq 'noautosrc' ) {
|
||||
@@ -693,8 +695,6 @@ sub process_a_provider( $ ) {
|
||||
$provider_interfaces{$interface} = $table unless $shared;
|
||||
|
||||
if ( $track ) {
|
||||
fatal_error "The 'track' option requires a numeric value in the MARK column" if $mark eq '-';
|
||||
|
||||
if ( $routemarked_interfaces{$interface} ) {
|
||||
fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface} == ROUTEMARKED_UNSHARED;
|
||||
fatal_error "Multiple providers through the same interface must their IP address specified in the INTERFACES" unless $shared;
|
||||
@@ -1085,10 +1085,8 @@ CEOF
|
||||
}
|
||||
}
|
||||
|
||||
sub add_an_rtrule( ) {
|
||||
my ( $source, $dest, $provider, $priority, $originalmark ) =
|
||||
split_line( 'rtrules file',
|
||||
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
|
||||
sub add_an_rtrule1( $$$$$ ) {
|
||||
my ( $source, $dest, $provider, $priority, $originalmark ) = @_;
|
||||
|
||||
our $current_if;
|
||||
|
||||
@@ -1177,6 +1175,17 @@ sub add_an_rtrule( ) {
|
||||
progress_message " Routing rule \"$currentline\" $done";
|
||||
}
|
||||
|
||||
sub add_an_rtrule( ) {
|
||||
my ( $sources, $dests, $provider, $priority, $originalmark ) =
|
||||
split_line( 'rtrules file',
|
||||
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
|
||||
for my $source ( split_list( $sources, "source" ) ) {
|
||||
for my $dest (split_list( $dests , "dest" ) ) {
|
||||
add_an_rtrule1( $source, $dest, $provider, $priority, $originalmark );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub add_a_route( ) {
|
||||
my ( $provider, $dest, $gateway, $device ) =
|
||||
split_line( 'routes file',
|
||||
@@ -1505,7 +1514,7 @@ EOF
|
||||
" start_provider_$provider" );
|
||||
}
|
||||
|
||||
emit ( ' else',
|
||||
emit ( ' elif [ -z "$2" ]; then',
|
||||
" startup_error \"Interface $providerref->{physical} is already enabled\"",
|
||||
' fi',
|
||||
' ;;'
|
||||
@@ -1553,7 +1562,7 @@ EOF
|
||||
}
|
||||
|
||||
emit( " stop_$providerref->{what}_$provider",
|
||||
' else',
|
||||
' elif [ -z "$2" ]; then',
|
||||
" startup_error \"Interface $providerref->{physical} is already disabled\"",
|
||||
' fi',
|
||||
' ;;'
|
||||
@@ -1578,10 +1587,44 @@ sub have_providers() {
|
||||
return our $providers;
|
||||
}
|
||||
|
||||
sub map_provider_to_interface() {
|
||||
|
||||
my $haveoptional;
|
||||
|
||||
for my $providerref ( values %providers ) {
|
||||
if ( $providerref->{optional} ) {
|
||||
unless ( $haveoptional++ ) {
|
||||
emit( 'if [ -n "$interface" ]; then',
|
||||
' case $interface in' );
|
||||
|
||||
push_indent;
|
||||
push_indent;
|
||||
}
|
||||
|
||||
emit( $providerref->{provider} . ')',
|
||||
' interface=' . $providerref->{physical},
|
||||
' ;;' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $haveoptional ) {
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
emit( ' esac',
|
||||
"fi\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub setup_providers() {
|
||||
our $providers;
|
||||
|
||||
if ( $providers ) {
|
||||
if ( $maxload ) {
|
||||
warning_message "The sum of the provider interface loads exceeds 1.000000" if $maxload > 1;
|
||||
warning_message "The sum of the provider interface loads is less than 1.000000" if $maxload < 1;
|
||||
}
|
||||
|
||||
emit "\nif [ -z \"\$g_noroutes\" ]; then";
|
||||
|
||||
push_indent;
|
||||
@@ -1719,12 +1762,12 @@ sub compile_updown() {
|
||||
q( if [ "$COMMAND" = up ]; then) ,
|
||||
q( progress_message3 "Attempting enable on interface $1") ,
|
||||
q( COMMAND=enable) ,
|
||||
q( detect_configuration),
|
||||
q( detect_configuration $1),
|
||||
q( enable_provider $1),
|
||||
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) ,
|
||||
q( progress_message3 "Attempting disable on interface $1") ,
|
||||
q( COMMAND=disable) ,
|
||||
q( detect_configuration),
|
||||
q( detect_configuration $1),
|
||||
q( disable_provider $1) ,
|
||||
q( fi) ,
|
||||
q(elif [ "$COMMAND" = up ]; then) ,
|
||||
@@ -1931,6 +1974,19 @@ sub handle_optional_interfaces( $ ) {
|
||||
|
||||
emit( "$physical)" ), push_indent if $wildcards;
|
||||
|
||||
if ( $provider eq $physical ) {
|
||||
#
|
||||
# Just an optional interface, or provider and interface are the same
|
||||
#
|
||||
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
|
||||
} else {
|
||||
#
|
||||
# Provider
|
||||
#
|
||||
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
|
||||
}
|
||||
|
||||
push_indent;
|
||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||
} else {
|
||||
@@ -1942,6 +1998,10 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit( " SW_${base}_IS_USABLE=Yes" ,
|
||||
'fi' );
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit( "fi\n" );
|
||||
|
||||
emit( ';;' ), pop_indent if $wildcards;
|
||||
}
|
||||
|
||||
@@ -2048,7 +2108,7 @@ sub handle_stickiness( $ ) {
|
||||
$rule1 = clone_irule( $_ );
|
||||
|
||||
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
||||
set_rule_option( $rule1, 'recent', "--name $list --update --seconds 300 --reap" );
|
||||
set_rule_option( $rule1, 'recent', "--name $list --update --seconds $rule1->{t} --reap" );
|
||||
|
||||
$rule2 = clone_irule( $_ );
|
||||
|
||||
@@ -2083,7 +2143,7 @@ sub handle_stickiness( $ ) {
|
||||
$rule1 = clone_irule $_;
|
||||
|
||||
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
||||
set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds 300 --reap" );
|
||||
set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds $rule1->{t} --reap" );
|
||||
|
||||
$rule2 = clone_irule $_;
|
||||
|
||||
|
@@ -113,7 +113,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
$action = $1;
|
||||
$disposition = $1;
|
||||
}
|
||||
} elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))$/ ) {
|
||||
} elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))?$/ ) {
|
||||
if ( $family == F_IPV4 ) {
|
||||
fatal_error 'Invalid conntrack ACTION (IP6TABLES)' if $1;
|
||||
} else {
|
||||
@@ -125,8 +125,8 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;
|
||||
$disposition = $tgt;
|
||||
$action = 2;
|
||||
validate_level( $level = $3 ) if supplied $3;
|
||||
$action = $2;
|
||||
validate_level( $level = $4 ) if supplied $4;
|
||||
} else {
|
||||
( $disposition, my ( $option, $args ), $level ) = split ':', $action, 4;
|
||||
|
||||
@@ -146,7 +146,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
if ( $option eq 'helper' ) {
|
||||
my $modifiers = '';
|
||||
|
||||
$disposition = "helper";
|
||||
$disposition = 'helper';
|
||||
|
||||
if ( $args =~ /^([-\w.]+)\((.+)\)$/ ) {
|
||||
$args = $1;
|
||||
@@ -156,8 +156,9 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Invalid helper' ($args)" if $args =~ /,/;
|
||||
validate_helper( $args, $proto );
|
||||
$action = "CT --helper $helpers_aliases{$args}";
|
||||
$exception_rule = do_proto( $proto, '-', '-' );
|
||||
|
||||
$exception_rule = do_proto( $proto, '-', '-' );
|
||||
|
||||
for my $mod ( split_list1( $modifiers, 'ctevents' ) ) {
|
||||
fatal_error "Invalid helper option ($mod)" unless $mod =~ /^(\w+)=(.+)$/;
|
||||
$mod = $1;
|
||||
@@ -176,6 +177,17 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Invalid helper option ($mod)";
|
||||
}
|
||||
}
|
||||
} elsif ( $option eq 'ctevents' ) {
|
||||
$disposition = 'helper';
|
||||
|
||||
for ( split_list( $args, 'ctevents' ) ) {
|
||||
fatal_error "Invalid 'ctevents' event ($_)" unless $valid_ctevent{$_};
|
||||
}
|
||||
|
||||
$action = "CT --ctevents $args";
|
||||
} elsif ( $option eq 'expevents' ) {
|
||||
fatal_error "Invalid expevent argument ($args)" unless $args eq 'new';
|
||||
$action = 'CT --expevents new';
|
||||
} else {
|
||||
fatal_error "Invalid CT option ($option)";
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
process_policies
|
||||
apply_policy_rules
|
||||
complete_policy_chains
|
||||
complete_standard_chain
|
||||
setup_syn_flood_chains
|
||||
save_policies
|
||||
@@ -224,6 +224,7 @@ sub initialize( $ ) {
|
||||
$family = shift;
|
||||
#
|
||||
# Chains created as a result of entries in the policy file
|
||||
#
|
||||
@policy_chains = ();
|
||||
#
|
||||
# This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored
|
||||
@@ -348,44 +349,44 @@ sub new_policy_chain($$$$$)
|
||||
#
|
||||
sub set_policy_chain($$$$$$)
|
||||
{
|
||||
my ($source, $dest, $chain1, $chainref, $policy, $intrazone) = @_;
|
||||
my ( $chain, $source, $dest, $polchainref, $policy, $intrazone ) = @_;
|
||||
|
||||
my $chainref1 = $filter_table->{$chain1};
|
||||
my $chainref = $filter_table->{$chain};
|
||||
|
||||
if ( $chainref1 ) {
|
||||
if ( $intrazone && $source eq $dest && $chainref1->{provisional} ) {
|
||||
$chainref1->{policychain} = '';
|
||||
$chainref1->{provisional} = '';
|
||||
if ( $chainref ) {
|
||||
if ( $intrazone && $source eq $dest && $chainref->{provisional} ) {
|
||||
$chainref->{policychain} = '';
|
||||
$chainref->{provisional} = '';
|
||||
}
|
||||
} else {
|
||||
$chainref1 = new_rules_chain $chain1;
|
||||
$chainref = new_rules_chain $chain;
|
||||
}
|
||||
|
||||
unless ( $chainref1->{policychain} ) {
|
||||
unless ( $chainref->{policychain} ) {
|
||||
if ( $config{EXPAND_POLICIES} ) {
|
||||
#
|
||||
# We convert the canonical chain into a policy chain, using the settings of the
|
||||
# passed policy chain.
|
||||
#
|
||||
$chainref1->{policychain} = $chain1;
|
||||
$chainref1->{loglevel} = $chainref->{loglevel} if defined $chainref->{loglevel};
|
||||
$chainref1->{audit} = $chainref->{audit} if defined $chainref->{audit};
|
||||
$chainref->{policychain} = $chain;
|
||||
$chainref->{loglevel} = $polchainref->{loglevel} if defined $polchainref->{loglevel};
|
||||
$chainref->{audit} = $polchainref->{audit} if defined $polchainref->{audit};
|
||||
|
||||
if ( defined $chainref->{synparams} ) {
|
||||
$chainref1->{synparams} = $chainref->{synparams};
|
||||
$chainref1->{synchain} = $chainref->{synchain};
|
||||
if ( defined $polchainref->{synparams} ) {
|
||||
$chainref->{synparams} = $polchainref->{synparams};
|
||||
$chainref->{synchain} = $polchainref->{synchain};
|
||||
}
|
||||
|
||||
$chainref1->{default} = $chainref->{default} if defined $chainref->{default};
|
||||
$chainref1->{is_policy} = 1;
|
||||
push @policy_chains, $chainref1;
|
||||
$chainref->{default} = $polchainref->{default} if defined $polchainref->{default};
|
||||
$chainref->{is_policy} = 1;
|
||||
push @policy_chains, $chainref;
|
||||
} else {
|
||||
$chainref1->{policychain} = $chainref->{name};
|
||||
$chainref->{policychain} = $polchainref->{name};
|
||||
}
|
||||
|
||||
$chainref1->{policy} = $policy;
|
||||
$chainref1->{policypair} = [ $source, $dest ];
|
||||
$chainref1->{origin} = $chainref->{origin};
|
||||
$chainref->{policy} = $policy;
|
||||
$chainref->{policypair} = [ $source, $dest ];
|
||||
$chainref->{origin} = $polchainref->{origin};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +469,64 @@ sub process_default_action( $$$$ ) {
|
||||
$default;
|
||||
}
|
||||
|
||||
#
|
||||
# Verify an NFQUEUE specification and return the appropriate ip[6]tables target
|
||||
#
|
||||
sub handle_nfqueue( $$ ) {
|
||||
my ($params, $allow_bypass ) = @_;
|
||||
my ( $action, $bypass );
|
||||
my ( $queue1, $queue2, $queuenum1, $queuenum2 );
|
||||
|
||||
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules and Policies', '' );
|
||||
|
||||
if ( supplied( $params ) ) {
|
||||
( my $queue, $bypass, my $junk ) = split ',', $params, 3;
|
||||
|
||||
fatal_error "Invalid NFQUEUE parameter list ($params)" if defined $junk;
|
||||
|
||||
if ( supplied $queue ) {
|
||||
if ( $queue eq 'bypass' ) {
|
||||
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
|
||||
fatal_error "Invalid NFQUEUE options (bypass,$bypass)" if supplied $bypass;
|
||||
return 'NFQUEUE --queue-bypass';
|
||||
}
|
||||
|
||||
( $queue1, $queue2 ) = split ':', $queue, 2;
|
||||
|
||||
fatal_error "Invalid NFQUEUE parameter list ($params)" unless supplied $queue1;
|
||||
|
||||
$queuenum1 = numeric_value( $queue1 );
|
||||
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue1)" unless defined( $queuenum1) && $queuenum1 >= 0 && $queuenum1 <= 65535;
|
||||
|
||||
if ( supplied $queue2 ) {
|
||||
$queuenum2 = numeric_value( $queue2 );
|
||||
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue2)" unless defined( $queuenum2) && $queuenum2 >= 0 && $queuenum2 <= 65535 && $queuenum1 < $queuenum2;
|
||||
}
|
||||
} else {
|
||||
$queuenum1 = 0;
|
||||
}
|
||||
} else {
|
||||
$queuenum1 = 0;
|
||||
}
|
||||
|
||||
if ( supplied $bypass ) {
|
||||
fatal_error "Invalid NFQUEUE option ($bypass)" if $bypass ne 'bypass';
|
||||
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
|
||||
|
||||
$bypass =' --queue-bypass';
|
||||
} else {
|
||||
$bypass = '';
|
||||
}
|
||||
|
||||
if ( supplied $queue2 ) {
|
||||
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}";
|
||||
} else {
|
||||
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Process an entry in the policy file.
|
||||
#
|
||||
@@ -518,11 +577,9 @@ sub process_a_policy() {
|
||||
$default = process_default_action( $originalpolicy, $policy, $default, $level );
|
||||
|
||||
if ( defined $queue ) {
|
||||
fatal_error "Invalid policy ($policy($queue))" unless $policy eq 'NFQUEUE';
|
||||
require_capability( 'NFQUEUE_TARGET', 'An NFQUEUE Policy', 's' );
|
||||
my $queuenum = numeric_value( $queue );
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue)" unless defined( $queuenum) && $queuenum <= 65535;
|
||||
$policy = "NFQUEUE --queue-num $queuenum";
|
||||
$policy = handle_nfqueue( $queue,
|
||||
0 # Don't allow 'bypass'
|
||||
);
|
||||
} elsif ( $policy eq 'NONE' ) {
|
||||
fatal_error "NONE policy not allowed with \"all\""
|
||||
if $clientwild || $serverwild;
|
||||
@@ -548,10 +605,10 @@ sub process_a_policy() {
|
||||
$chainref->{provisional} = 0;
|
||||
$chainref->{policy} = $policy;
|
||||
} else {
|
||||
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
}
|
||||
} elsif ( $chainref->{policy} ) {
|
||||
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
} else {
|
||||
convert_to_policy_chain( $chainref, $client, $server, $policy, 0 , $audit );
|
||||
push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild );
|
||||
@@ -582,24 +639,24 @@ sub process_a_policy() {
|
||||
if ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
for my $zone1 ( @zonelist ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${zone1} ), $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $zone1, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${zone}, ${zone1} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $zone1, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for my $zone ( all_zones ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${server} ), $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $server, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${zone}, ${server} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $server, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
} elsif ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${client}, ${zone} ), $chainref, $policy, $intrazone;
|
||||
print_policy $client, $zone, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${client}, ${zone} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $client, $zone, $originalpolicy, $chain;
|
||||
}
|
||||
|
||||
} else {
|
||||
print_policy $client, $server, $policy, $chain;
|
||||
print_policy $client, $server, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,8 +727,8 @@ sub process_policies()
|
||||
unless ( $zone eq $zone1 ) {
|
||||
my $name = rules_chain( $zone, $zone1 );
|
||||
my $name1 = rules_chain( $zone1, $zone );
|
||||
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
}
|
||||
}
|
||||
} elsif ( $type == LOOPBACK ) {
|
||||
@@ -679,8 +736,8 @@ sub process_policies()
|
||||
unless ( $zone eq $zone1 || zone_type( $zone1 ) == LOOPBACK ) {
|
||||
my $name = rules_chain( $zone, $zone1 );
|
||||
my $name1 = rules_chain( $zone1, $zone );
|
||||
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,9 +769,9 @@ sub process_policies()
|
||||
#
|
||||
# Policy Rule application
|
||||
#
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$);
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$$);
|
||||
|
||||
sub policy_rules( $$$$$ ) {
|
||||
sub add_policy_rules( $$$$$ ) {
|
||||
my ( $chainref , $target, $loglevel, $default, $dropmulticast ) = @_;
|
||||
|
||||
unless ( $target eq 'NONE' ) {
|
||||
@@ -737,6 +794,7 @@ sub policy_rules( $$$$$ ) {
|
||||
process_inline( $action, #Inline
|
||||
$chainref, #Chain
|
||||
'', #Matches
|
||||
'', #Matches1
|
||||
$loglevel, #Log Level and Tag
|
||||
$default, #Target
|
||||
$param || '', #Param
|
||||
@@ -774,7 +832,7 @@ sub report_syn_flood_protection() {
|
||||
#
|
||||
# Complete a policy chain - Add policy-enforcing rules and syn flood, if specified
|
||||
#
|
||||
sub default_policy( $$$ ) {
|
||||
sub complete_policy_chain( $$$ ) { #Chainref, Source Zone, Destination Zone
|
||||
my $chainref = $_[0];
|
||||
my $policyref = $filter_table->{$chainref->{policychain}};
|
||||
my $synparams = $policyref->{synparams};
|
||||
@@ -785,20 +843,20 @@ sub default_policy( $$$ ) {
|
||||
assert( $policyref );
|
||||
|
||||
if ( $chainref eq $policyref ) {
|
||||
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
if ( $policy eq 'ACCEPT' || $policy eq 'QUEUE' || $policy =~ /^NFQUEUE/ ) {
|
||||
if ( $synparams ) {
|
||||
report_syn_flood_protection;
|
||||
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
add_ijump $chainref, g => $policyref;
|
||||
$chainref = $policyref;
|
||||
policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./;
|
||||
add_policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./;
|
||||
}
|
||||
} elsif ( $policy eq 'CONTINUE' ) {
|
||||
report_syn_flood_protection if $synparams;
|
||||
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
report_syn_flood_protection if $synparams;
|
||||
add_ijump $chainref , g => $policyref;
|
||||
@@ -814,7 +872,7 @@ sub ensure_rules_chain( $ );
|
||||
#
|
||||
# Finish all policy Chains
|
||||
#
|
||||
sub apply_policy_rules() {
|
||||
sub complete_policy_chains() {
|
||||
progress_message2 'Applying Policies...';
|
||||
|
||||
for my $chainref ( @policy_chains ) {
|
||||
@@ -845,7 +903,7 @@ sub apply_policy_rules() {
|
||||
|
||||
if ( $name =~ /^all[-2]|[-2]all$/ ) {
|
||||
run_user_exit $chainref;
|
||||
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -856,7 +914,7 @@ sub apply_policy_rules() {
|
||||
|
||||
if ( $chainref->{referenced} ) {
|
||||
run_user_exit $chainref;
|
||||
default_policy $chainref, $zone, $zone1;
|
||||
complete_policy_chain $chainref, $zone, $zone1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -890,7 +948,7 @@ sub complete_standard_chain ( $$$$ ) {
|
||||
}
|
||||
|
||||
|
||||
policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
|
||||
add_policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1140,7 +1198,7 @@ sub normalize_action_name( $ ) {
|
||||
#
|
||||
# Produce a recognizable target from a normalized action
|
||||
#
|
||||
sub externalize( $ ) {
|
||||
sub external_name( $ ) {
|
||||
my ( $target, $level, $tag, $params ) = split /:/, shift, 4;
|
||||
|
||||
$target = join( '', $target, '(', $params , ')' ) if $params;
|
||||
@@ -1622,7 +1680,7 @@ my %builtinops = ( 'dropBcast' => \&dropBcast,
|
||||
'Limit' => \&Limit,
|
||||
);
|
||||
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$ );
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
|
||||
|
||||
#
|
||||
# Populate an action invocation chain. As new action tuples are encountered,
|
||||
@@ -1686,6 +1744,7 @@ sub process_action($$) {
|
||||
}
|
||||
|
||||
process_rule( $chainref,
|
||||
'',
|
||||
'',
|
||||
$nolog ? $target : merge_levels( join(':', @actparms{'chain','loglevel','logtag'}), $target ),
|
||||
'',
|
||||
@@ -1748,15 +1807,31 @@ sub process_actions() {
|
||||
undef, #Columns
|
||||
1 ); #Allow inline matches
|
||||
|
||||
my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION );
|
||||
my $noinline = 0;
|
||||
my $nolog = ( $type == INLINE ) || 0;
|
||||
my $builtin = 0;
|
||||
my $raw = 0;
|
||||
my $mangle = 0;
|
||||
my $filter = 0;
|
||||
my $nat = 0;
|
||||
my $terminating = 0;
|
||||
my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION );
|
||||
|
||||
use constant { INLINE_OPT => 1 ,
|
||||
NOINLINE_OPT => 2 ,
|
||||
NOLOG_OPT => 4 ,
|
||||
BUILTIN_OPT => 8 ,
|
||||
RAW_OPT => 16 ,
|
||||
MANGLE_OPT => 32 ,
|
||||
FILTER_OPT => 64 ,
|
||||
NAT_OPT => 128 ,
|
||||
TERMINATING_OPT => 256 ,
|
||||
};
|
||||
|
||||
my %options = ( inline => INLINE_OPT ,
|
||||
noinline => NOINLINE_OPT ,
|
||||
nolog => NOLOG_OPT ,
|
||||
builtin => BUILTIN_OPT ,
|
||||
raw => RAW_OPT ,
|
||||
mangle => MANGLE_OPT ,
|
||||
filter => FILTER_OPT ,
|
||||
nat => NAT_OPT ,
|
||||
terminating => TERMINATING_OPT ,
|
||||
);
|
||||
|
||||
my $opts = $type == INLINE ? NOLOG_OPT : 0;
|
||||
|
||||
if ( $action =~ /:/ ) {
|
||||
warning_message 'Default Actions are now specified in /etc/shorewall/shorewall.conf';
|
||||
@@ -1767,31 +1842,14 @@ sub process_actions() {
|
||||
|
||||
if ( $options ne '-' ) {
|
||||
for ( split_list( $options, 'option' ) ) {
|
||||
if ( $_ eq 'inline' ) {
|
||||
$type = INLINE;
|
||||
} elsif ( $_ eq 'noinline' ) {
|
||||
$noinline = 1;
|
||||
} elsif ( $_ eq 'nolog' ) {
|
||||
$nolog = 1;
|
||||
} elsif ( $_ eq 'builtin' ) {
|
||||
$builtin = 1;
|
||||
} elsif ( $_ eq 'terminating' ) {
|
||||
$terminating = 1;
|
||||
} elsif ( $_ eq 'mangle' ) {
|
||||
$mangle = 1;
|
||||
} elsif ( $_ eq 'raw' ) {
|
||||
$raw = 1;
|
||||
} elsif ( $_ eq 'filter' ) {
|
||||
$filter = 1;
|
||||
} elsif ( $_ eq 'nat' ) {
|
||||
$nat = 1;
|
||||
} else {
|
||||
fatal_error "Invalid option ($_)";
|
||||
}
|
||||
fatal_error "Invalid option ($_)" unless $options{$_};
|
||||
$opts |= $options{$_};
|
||||
}
|
||||
|
||||
$type = INLINE if $opts & INLINE_OPT;
|
||||
}
|
||||
|
||||
fatal_error "Conflicting OPTIONS ($options)" if $noinline && $type == INLINE;
|
||||
fatal_error "Conflicting OPTIONS ($options)" if ( $opts & NOINLINE_OPT && $type == INLINE ) || ( $opts & INLINE_OPT && $opts & BUILTIN_OPT );
|
||||
|
||||
if ( my $actiontype = $targets{$action} ) {
|
||||
if ( ( $actiontype & ACTION ) && ( $type == INLINE ) ) {
|
||||
@@ -1808,15 +1866,15 @@ sub process_actions() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $builtin ) {
|
||||
if ( $opts & BUILTIN_OPT ) {
|
||||
my $actiontype = USERBUILTIN | OPTIONS;
|
||||
$actiontype |= MANGLE_TABLE if $mangle;
|
||||
$actiontype |= RAW_TABLE if $raw;
|
||||
$actiontype |= NAT_TABLE if $nat;
|
||||
$actiontype |= MANGLE_TABLE if $opts & MANGLE_OPT;
|
||||
$actiontype |= RAW_TABLE if $opts & RAW_OPT;
|
||||
$actiontype |= NAT_TABLE if $opts & NAT_OPT;
|
||||
#
|
||||
# For backward compatibility, we assume that user-defined builtins are valid in the filter table
|
||||
#
|
||||
$actiontype |= FILTER_TABLE if $filter || ! ($mangle || $raw || $nat);
|
||||
$actiontype |= FILTER_TABLE if $opts & FILTER_OPT || ! ( $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT ) );
|
||||
|
||||
if ( $builtin_target{$action} ) {
|
||||
$builtin_target{$action} |= $actiontype;
|
||||
@@ -1826,16 +1884,17 @@ sub process_actions() {
|
||||
|
||||
$targets{$action} = $actiontype;
|
||||
|
||||
make_terminating( $action ) if $terminating;
|
||||
make_terminating( $action ) if $opts & TERMINATING_OPT
|
||||
} else {
|
||||
fatal_error "Table names are only allowed for builtin actions" if $mangle || $raw || $nat || $filter;
|
||||
new_action $action, $type, $noinline, $nolog;
|
||||
fatal_error "Table names are only allowed for builtin actions" if $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT | FILTER_OPT );
|
||||
|
||||
new_action $action, $type, ( $opts & NOINLINE_OPT ) != 0 , ( $opts & NOLOG_OPT ) != 0;
|
||||
|
||||
my $actionfile = find_file( "action.$action" );
|
||||
|
||||
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
|
||||
|
||||
$inlines{$action} = { file => $actionfile, nolog => $nolog } if $type == INLINE;
|
||||
$inlines{$action} = { file => $actionfile, nolog => $opts & NOLOG_OPT } if $type == INLINE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1874,6 +1933,7 @@ sub process_reject_action() {
|
||||
process_inline( $action, #Inline
|
||||
$rejectref, #Chain
|
||||
'', #Matches
|
||||
'', #Matches1
|
||||
'', #Log Level and Tag
|
||||
$action, #Target
|
||||
'', #Param
|
||||
@@ -1902,8 +1962,8 @@ sub process_reject_action() {
|
||||
#
|
||||
# Expand a macro rule from the rules file
|
||||
#
|
||||
sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($macro, $chainref, $matches, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
sub process_macro ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($macro, $chainref, $matches, $matches1, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
|
||||
my $generated = 0;
|
||||
|
||||
@@ -2002,7 +2062,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
$generated |= process_rule(
|
||||
$chainref,
|
||||
$matches,
|
||||
$matches,
|
||||
$matches1,
|
||||
$mtarget,
|
||||
$param,
|
||||
$msource,
|
||||
@@ -2035,8 +2096,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
#
|
||||
# Expand an inline action rule from the rules file
|
||||
#
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($inline, $chainref, $matches, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($inline, $chainref, $matches, $matches1, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
|
||||
my $generated = 0;
|
||||
|
||||
@@ -2126,7 +2187,8 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
$generated |= process_rule(
|
||||
$chainref,
|
||||
$matches,
|
||||
$matches,
|
||||
$matches1,
|
||||
$mtarget,
|
||||
$param,
|
||||
$msource,
|
||||
@@ -2179,9 +2241,10 @@ sub verify_audit($;$$) {
|
||||
# reference is also passed when rules are being generated during processing of a macro used as a default action.
|
||||
#
|
||||
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise
|
||||
$rule, #Matches
|
||||
$matches1, #Matches after the ones generated by the columns
|
||||
$target,
|
||||
$current_param,
|
||||
$source,
|
||||
@@ -2211,6 +2274,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $blacklist = ( $section == BLACKLIST_SECTION );
|
||||
my $matches = $rule;
|
||||
my $raw_matches = '';
|
||||
my $exceptionrule = '';
|
||||
|
||||
if ( $inchain = defined $chainref ) {
|
||||
( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action};
|
||||
@@ -2245,6 +2309,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $generated = process_macro( $basictarget,
|
||||
$chainref,
|
||||
$rule . $raw_matches,
|
||||
$matches1,
|
||||
$target,
|
||||
$current_param,
|
||||
$source,
|
||||
@@ -2268,10 +2333,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
return $generated;
|
||||
|
||||
} elsif ( $actiontype & NFQ ) {
|
||||
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' );
|
||||
my $paramval = $param eq '' ? 0 : numeric_value( $param );
|
||||
fatal_error "Invalid value ($param) for NFQUEUE queue number" unless defined($paramval) && $paramval <= 65535;
|
||||
$action = "NFQUEUE --queue-num $paramval";
|
||||
$action = handle_nfqueue( $param,
|
||||
1 # Allow 'bypass'
|
||||
);
|
||||
} elsif ( $actiontype & SET ) {
|
||||
require_capability( 'IPSET_MATCH', 'SET and UNSET rules', '' );
|
||||
fatal_error "$action rules require a set name parameter" unless $param;
|
||||
@@ -2284,7 +2348,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
validate_level( $action );
|
||||
$loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action;
|
||||
$action = 'LOG';
|
||||
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES ) ) ) {
|
||||
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES | TARPIT ) ) ) {
|
||||
fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN;
|
||||
fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq '';
|
||||
}
|
||||
@@ -2294,7 +2358,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
#
|
||||
fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[-+!]$// && $blacklist;
|
||||
|
||||
unless ( $actiontype & ( ACTION | INLINE | IPTABLES ) ) {
|
||||
unless ( $actiontype & ( ACTION | INLINE | IPTABLES | TARPIT ) ) {
|
||||
#
|
||||
# Catch empty parameter list
|
||||
#
|
||||
@@ -2398,6 +2462,22 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
$action = '';
|
||||
}
|
||||
},
|
||||
|
||||
TARPIT => sub {
|
||||
require_capability 'TARPIT_TARGET', 'TARPIT', 's';
|
||||
|
||||
fatal_error "TARPIT is only valid with PROTO tcp (6)" if ( resolve_proto( $proto ) || 0 ) != TCP;
|
||||
|
||||
if ( supplied $param ) {
|
||||
fatal_error "TARPIT Parameter must be 'tarpit', 'honeypot' or 'reset'" unless $param =~ /^(tarpit|honeypot|reset)$/;
|
||||
$action = "TARPIT --$param";
|
||||
$log_action = 'TARPIT';
|
||||
} else {
|
||||
$action = $log_action = 'TARPIT';
|
||||
}
|
||||
|
||||
$exceptionrule = '-p 6 ';
|
||||
},
|
||||
);
|
||||
|
||||
my $function = $functions{ $bt };
|
||||
@@ -2466,11 +2546,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
$destzone = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unless ( $inchain ) {
|
||||
fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq '';
|
||||
fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
|
||||
}
|
||||
} elsif ( ! $inchain ) {
|
||||
fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq '';
|
||||
fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
|
||||
}
|
||||
|
||||
my $restriction = NO_RESTRICT;
|
||||
@@ -2590,7 +2668,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
#
|
||||
$normalized_target = normalize_action( $basictarget, $loglevel, $param );
|
||||
|
||||
fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( externalize( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget};
|
||||
fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( external_name( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget};
|
||||
|
||||
if ( my $ref = use_action( $normalized_target ) ) {
|
||||
#
|
||||
@@ -2634,6 +2712,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $generated = process_inline( $basictarget,
|
||||
$chainref,
|
||||
$rule . $raw_matches,
|
||||
$matches1,
|
||||
$loglevel,
|
||||
$target,
|
||||
$current_param,
|
||||
@@ -2688,7 +2767,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
do_headers( $headers ) ,
|
||||
do_condition( $condition , $chain ) ,
|
||||
do_helper( $helper ) ,
|
||||
$raw_matches ,
|
||||
$matches1 . $raw_matches ,
|
||||
);
|
||||
} else {
|
||||
$rule .= join( '',
|
||||
@@ -2700,7 +2779,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
do_time( $time ) ,
|
||||
do_headers( $headers ) ,
|
||||
do_condition( $condition , $chain ) ,
|
||||
$raw_matches ,
|
||||
$matches1 . $raw_matches ,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2833,7 +2912,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
$action ,
|
||||
$loglevel ,
|
||||
$log_action ,
|
||||
'' )
|
||||
$exceptionrule )
|
||||
unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref );
|
||||
}
|
||||
|
||||
@@ -2945,8 +3024,8 @@ sub merge_target( $$ ) {
|
||||
#
|
||||
# May be called by Perl code in action bodies (regular and inline) to generate a rule.
|
||||
#
|
||||
sub perl_action_helper($$;$) {
|
||||
my ( $target, $matches, $isstatematch ) = @_;
|
||||
sub perl_action_helper($$;$$) {
|
||||
my ( $target, $matches, $isstatematch , $matches1 ) = @_;
|
||||
my $action = $actparms{action};
|
||||
my $chainref = $actparms{0};
|
||||
my $result;
|
||||
@@ -2955,6 +3034,12 @@ sub perl_action_helper($$;$) {
|
||||
|
||||
$matches .= ' ' unless $matches =~ /^(?:.+\s)?$/;
|
||||
|
||||
if ( $matches1 ) {
|
||||
$matches1 .= ' ' unless $matches1 =~ /^(?:.+\s)?$/;
|
||||
} else {
|
||||
$matches1 = '';
|
||||
}
|
||||
|
||||
set_inline_matches( $target =~ /^INLINE(?::.*)?$/ ? $matches : '' );
|
||||
|
||||
if ( $isstatematch ) {
|
||||
@@ -2978,6 +3063,7 @@ sub perl_action_helper($$;$) {
|
||||
if ( my $ref = $inlines{$action} ) {
|
||||
$result = &process_rule( $chainref,
|
||||
$matches,
|
||||
$matches1,
|
||||
merge_target( $ref, $target ),
|
||||
'', # CurrentParam
|
||||
@columns );
|
||||
@@ -2986,6 +3072,7 @@ sub perl_action_helper($$;$) {
|
||||
|
||||
$result = process_rule( $chainref,
|
||||
$matches,
|
||||
$matches1,
|
||||
merge_target( $actions{$action}, $target ),
|
||||
'', # Current Param
|
||||
'-', # Source
|
||||
@@ -3037,6 +3124,7 @@ sub perl_action_tcp_helper($$) {
|
||||
if ( my $ref = $inlines{$action} ) {
|
||||
$result = &process_rule( $chainref,
|
||||
$proto,
|
||||
'',
|
||||
merge_target( $ref, $target ),
|
||||
'',
|
||||
@columns[0,1],
|
||||
@@ -3046,6 +3134,7 @@ sub perl_action_tcp_helper($$) {
|
||||
} else {
|
||||
$result = process_rule( $chainref,
|
||||
$proto,
|
||||
'',
|
||||
merge_target( $actions{$action}, $target ),
|
||||
'', # Current Param
|
||||
'-', # Source
|
||||
@@ -3239,6 +3328,7 @@ sub process_raw_rule ( ) {
|
||||
for my $proto ( @protos ) {
|
||||
for my $user ( @users ) {
|
||||
if ( process_rule( undef,
|
||||
'',
|
||||
'',
|
||||
$target,
|
||||
'',
|
||||
|
@@ -225,6 +225,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
my $device = '';
|
||||
our $cmd;
|
||||
our $designator;
|
||||
our $ttl = 0;
|
||||
my $fw = firewall_zone;
|
||||
|
||||
sub handle_mark_param( $$ ) {
|
||||
@@ -260,6 +261,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
$chain ||= $designator;
|
||||
$chain ||= $default_chain;
|
||||
|
||||
$option ||= ( $and_or eq '|' ? '--or-mark' : $and_or ? '--and-mark' : '--set-mark' );
|
||||
|
||||
my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} );
|
||||
|
||||
for ( my $packet = 0; $packet < $marks; $packet++, $markval += $increment ) {
|
||||
@@ -331,7 +334,31 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
sub ipset_command() {
|
||||
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' );
|
||||
|
||||
require_capability( 'IPSET_MATCH', "$cmd rules", '' );
|
||||
fatal_error "$cmd rules require a set name parameter" unless $params;
|
||||
|
||||
my ( $setname, $flags, $rest ) = split ':', $params, 3;
|
||||
fatal_error "Invalid ADD/DEL parameter ($params)" if $rest;
|
||||
$setname =~ s/^\+//;
|
||||
fatal_error "Expected ipset name ($setname)" unless $setname =~ /^(6_)?[a-zA-Z][-\w]*$/;
|
||||
fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/;
|
||||
$target = join( ' ', 'SET --' . $xlate{$cmd} , $setname , $flags );
|
||||
}
|
||||
|
||||
my %commands = (
|
||||
ADD => {
|
||||
defaultchain => PREROUTING,
|
||||
allowedchains => ALLCHAINS,
|
||||
minparams => 1,
|
||||
maxparams => 1,
|
||||
function => sub() {
|
||||
ipset_command();
|
||||
}
|
||||
},
|
||||
|
||||
CHECKSUM => {
|
||||
defaultchain => 0,
|
||||
allowedchains => ALLCHAINS,
|
||||
@@ -394,6 +421,16 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
},
|
||||
},
|
||||
|
||||
DEL => {
|
||||
defaultchain => PREROUTING,
|
||||
allowedchains => ALLCHAINS,
|
||||
minparams => 1,
|
||||
maxparams => 1,
|
||||
function => sub() {
|
||||
ipset_command();
|
||||
}
|
||||
},
|
||||
|
||||
DIVERT => {
|
||||
defaultchain => REALPREROUTING,
|
||||
allowedchains => PREROUTING | REALPREROUTING,
|
||||
@@ -562,7 +599,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
RESTORE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | FORWARD | OUTPUT | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -585,13 +622,20 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
$target = ( $chain == OUTPUT ? 'sticko' : 'sticky' );
|
||||
$restriction = DESTIFACE_DISALLOW;
|
||||
ensure_mangle_chain( $target );
|
||||
if (supplied $params) {
|
||||
$ttl = numeric_value( $params );
|
||||
fatal_error "The SAME timeout must be positive" unless $ttl;
|
||||
} else {
|
||||
$ttl = 300;
|
||||
}
|
||||
|
||||
$sticky++;
|
||||
},
|
||||
},
|
||||
|
||||
SAVE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | FORWARD | OUTPUT | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -599,7 +643,6 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
if ( supplied $params ) {
|
||||
handle_mark_param( '--save-mark --mask ' ,
|
||||
$config{TC_EXPERT} ? HIGHMARK : SMALLMARK );
|
||||
|
||||
} else {
|
||||
$target .= '--save-mark --mask ' . in_hex( $globals{TC_MASK} );
|
||||
}
|
||||
@@ -763,7 +806,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
for ( @state ) {
|
||||
fatal_error "Invalid STATE ($_)" unless exists $state{$_};
|
||||
fatal_error "Duplicate STATE ($_)" if $state{$_};
|
||||
fatal_error "Duplicate STATE ($_)" if $state{$_}++;
|
||||
}
|
||||
} else {
|
||||
$state = 'ALL';
|
||||
@@ -799,6 +842,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
do_dscp( $dscp ) .
|
||||
state_match( $state ) .
|
||||
do_time( $time ) .
|
||||
( $ttl ? "-t $ttl " : '' ) .
|
||||
$raw_matches ,
|
||||
$source ,
|
||||
$dest ,
|
||||
@@ -850,13 +894,17 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
our %tccmd;
|
||||
|
||||
unless ( %tccmd ) {
|
||||
%tccmd = ( SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
%tccmd = ( ADD => { match => sub ( $ ) { $_[0] =~ /^ADD/ }
|
||||
},
|
||||
DEL => { match => sub ( $ ) { $_[0] =~ /^DEL/ }
|
||||
},
|
||||
SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
} ,
|
||||
RESTORE => { match => sub ( $ ) { $_[0] eq 'RESTORE' },
|
||||
} ,
|
||||
CONTINUE => { match => sub ( $ ) { $_[0] eq 'CONTINUE' },
|
||||
} ,
|
||||
SAME => { match => sub ( $ ) { $_[0] eq 'SAME' },
|
||||
SAME => { match => sub ( $ ) { $_[0] =~ /^SAME(?:\(d+\))?$/ },
|
||||
} ,
|
||||
IPMARK => { match => sub ( $ ) { $_[0] =~ /^IPMARK/ },
|
||||
} ,
|
||||
@@ -1053,7 +1101,7 @@ sub process_mangle_rule( ) {
|
||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
||||
if ( $family == F_IPV4 ) {
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) =
|
||||
split_line2( 'tcrules file',
|
||||
split_line2( 'mangle file',
|
||||
{ mark => 0,
|
||||
action => 0,
|
||||
source => 1,
|
||||
@@ -1078,7 +1126,7 @@ sub process_mangle_rule( ) {
|
||||
$headers = '-';
|
||||
} else {
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) =
|
||||
split_line2( 'tcrules file',
|
||||
split_line2( 'mangle file',
|
||||
{ mark => 0,
|
||||
action => 0,
|
||||
source => 1,
|
||||
|
@@ -132,6 +132,13 @@ sub setup_tunnels() {
|
||||
add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$source
|
||||
}
|
||||
|
||||
sub setup_one_tinc {
|
||||
my ( $inchainref, $outchainref, $kind, $source, $dest ) = @_;
|
||||
|
||||
add_tunnel_rule $inchainref, p => 'udp --dport 655', @$source;
|
||||
add_tunnel_rule $outchainref, p => 'udp --dport 655', @$dest;
|
||||
}
|
||||
|
||||
sub setup_one_openvpn {
|
||||
my ($inchainref, $outchainref, $kind, $source, $dest) = @_;
|
||||
|
||||
@@ -154,7 +161,7 @@ sub setup_tunnels() {
|
||||
}
|
||||
|
||||
add_tunnel_rule $inchainref, p => "$protocol --dport $port", @$source;
|
||||
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;;
|
||||
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;
|
||||
}
|
||||
|
||||
sub setup_one_openvpn_client {
|
||||
@@ -263,6 +270,7 @@ sub setup_tunnels() {
|
||||
'6in4' => { function => \&setup_one_other, params => [ \@source, \@dest , 41 ] } ,
|
||||
'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, \@source, \@dest ] } ,
|
||||
'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, \@source, \@dest ] } ,
|
||||
'tinc' => { function => \&setup_one_tinc, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, \@source, \@dest ] } ,
|
||||
|
@@ -55,6 +55,7 @@ our @EXPORT = ( qw( NOTHING
|
||||
find_zone
|
||||
firewall_zone
|
||||
loopback_zones
|
||||
loopback_interface
|
||||
local_zones
|
||||
defined_zone
|
||||
zone_type
|
||||
@@ -219,6 +220,7 @@ our $minroot;
|
||||
our $zonemark;
|
||||
our $zonemarkincr;
|
||||
our $zonemarklimit;
|
||||
our $loopback_interface;
|
||||
|
||||
use constant { FIREWALL => 1,
|
||||
IP => 2,
|
||||
@@ -329,6 +331,7 @@ sub initialize( $$ ) {
|
||||
%mapbase1 = ();
|
||||
$baseseq = 0;
|
||||
$minroot = 0;
|
||||
$loopback_interface = '';
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
%validinterfaceoptions = (arp_filter => BINARY_IF_OPTION,
|
||||
@@ -341,6 +344,7 @@ sub initialize( $$ ) {
|
||||
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
logmartians => BINARY_IF_OPTION,
|
||||
loopback => BINARY_IF_OPTION,
|
||||
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
|
||||
norfc1918 => OBSOLETE_IF_OPTION,
|
||||
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
@@ -386,6 +390,7 @@ sub initialize( $$ ) {
|
||||
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
dhcp => SIMPLE_IF_OPTION,
|
||||
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
loopback => BINARY_IF_OPTION,
|
||||
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
|
||||
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
@@ -460,6 +465,7 @@ sub parse_zone_option_list($$\$$)
|
||||
} else {
|
||||
fatal_error "Missing value for option \"$e\"" unless defined $val;
|
||||
fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/;
|
||||
require_capability 'TCPMSS_TARGET', "mss=$val", 's' if $e eq 'mss';
|
||||
}
|
||||
|
||||
my $key = $zonekey{$e};
|
||||
@@ -1253,6 +1259,7 @@ sub process_interface( $$ ) {
|
||||
fatal_error "The '$option' option requires a value" unless defined $value;
|
||||
my $numval = numeric_value $value;
|
||||
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
|
||||
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
|
||||
$options{$option} = $numval;
|
||||
$hostoptions{$option} = $numval if $hostopt;
|
||||
} elsif ( $type == IPLIST_IF_OPTION ) {
|
||||
@@ -1353,8 +1360,15 @@ sub process_interface( $$ ) {
|
||||
$options{ignore} ||= 0;
|
||||
}
|
||||
|
||||
$options{loopback} ||= ( $physical eq 'lo' );
|
||||
|
||||
if ( $options{loopback} ) {
|
||||
fatal_error "Only one 'loopback' interface is allowed" if $loopback_interface;
|
||||
$loopback_interface = $physical;
|
||||
}
|
||||
|
||||
if ( $options{unmanaged} ) {
|
||||
fatal_error "The 'lo' interface may not be unmanaged when there are vserver zones" if $physical eq 'lo' && vserver_zones;
|
||||
fatal_error "The loopback interface ($loopback_interface) may not be unmanaged when there are vserver zones" if $options{loopback} && vserver_zones;
|
||||
|
||||
while ( my ( $option, $value ) = each( %options ) ) {
|
||||
fatal_error "The $option option may not be specified with 'unmanaged'" if $prohibitunmanaged{$option};
|
||||
@@ -1382,9 +1396,9 @@ sub process_interface( $$ ) {
|
||||
if ( $zone ) {
|
||||
fatal_error "Unmanaged interfaces may not be associated with a zone" if $options{unmanaged};
|
||||
|
||||
if ( $physical eq 'lo' ) {
|
||||
fatal_error "Only a loopback zone may be assigned to 'lo'" unless $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "Invalid definition of 'lo'" if $bridge ne $interface;
|
||||
if ( $options{loopback} ) {
|
||||
fatal_error "Only a loopback zone may be assigned to '$physical'" unless $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "Invalid definition of '$physical'" if $bridge ne $interface;
|
||||
|
||||
for ( qw/arp_filter
|
||||
arp_ignore
|
||||
@@ -1406,10 +1420,10 @@ sub process_interface( $$ ) {
|
||||
upnpclient
|
||||
mss
|
||||
/ ) {
|
||||
fatal_error "The 'lo' interface may not specify the '$_' option" if supplied $options{$_};
|
||||
fatal_error "The '$config{LOOPBACK}' interface may not specify the '$_' option" if supplied $options{$_};
|
||||
}
|
||||
} else {
|
||||
fatal_error "A loopback zone may only be assigned to 'lo'" if $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "A loopback zone may only be assigned to the loopback interface" if $zoneref->{type} == LOOPBACK;
|
||||
}
|
||||
|
||||
$netsref ||= [ allip ];
|
||||
@@ -1466,6 +1480,22 @@ sub validate_interfaces_file( $ ) {
|
||||
#
|
||||
fatal_error "No network interfaces defined" unless @interfaces;
|
||||
|
||||
#
|
||||
# Define the loopback interface if it hasn't been already
|
||||
#
|
||||
unless ( $loopback_interface ) {
|
||||
$interfaces{lo} = { name => 'lo',
|
||||
bridge => 'lo',
|
||||
nets => 0,
|
||||
number => $nextinum++,
|
||||
root => 'lo',
|
||||
broadcasts => undef,
|
||||
options => { loopback => 1 , ignore => 1 },
|
||||
zone => '',
|
||||
physical => 'lo' };
|
||||
push @interfaces, $loopback_interface = 'lo';
|
||||
}
|
||||
|
||||
if ( vserver_zones ) {
|
||||
#
|
||||
# While the user thinks that vservers are associated with a particular interface, they really are not.
|
||||
@@ -1481,7 +1511,7 @@ sub validate_interfaces_file( $ ) {
|
||||
broadcasts => undef ,
|
||||
options => {} ,
|
||||
zone => '',
|
||||
physical => 'lo',
|
||||
physical => $loopback_interface,
|
||||
};
|
||||
|
||||
push @interfaces, $interface;
|
||||
@@ -1543,6 +1573,13 @@ sub known_interface($)
|
||||
$physical{$interface} || 0;
|
||||
}
|
||||
|
||||
#
|
||||
# Return the loopback interface physical name
|
||||
#
|
||||
sub loopback_interface() {
|
||||
$loopback_interface;
|
||||
}
|
||||
|
||||
#
|
||||
# Return interface number
|
||||
#
|
||||
@@ -1589,7 +1626,7 @@ sub managed_interfaces() {
|
||||
# Return a list of unmanaged interfaces (skip 'lo' since it is implicitly unmanaged when there are no loopback zones).
|
||||
#
|
||||
sub unmanaged_interfaces() {
|
||||
grep ( $interfaces{$_}{options}{unmanaged} && $_ ne 'lo', @interfaces );
|
||||
grep ( $interfaces{$_}{options}{unmanaged} && ! $interfaces{$_}{options}{loopback}, @interfaces );
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1989,10 +2026,10 @@ sub process_host( ) {
|
||||
fatal_error "Unknown interface ($interface)" unless ($interfaceref = $interfaces{$interface}) && $interfaceref->{root};
|
||||
fatal_error "Unmanaged interfaces may not be associated with a zone" if $interfaceref->{unmanaged};
|
||||
|
||||
if ( $interfaceref->{name} eq 'lo' ) {
|
||||
fatal_error "Only a loopback zone may be associated with the loopback interface (lo)" if $type != LOOPBACK;
|
||||
if ( $interfaceref->{physical} eq $loopback_interface ) {
|
||||
fatal_error "Only a loopback zone may be associated with the loopback interface ($loopback_interface)" if $type != LOOPBACK;
|
||||
} else {
|
||||
fatal_error "Loopback zones may only be associated with the loopback interface (lo)" if $type == LOOPBACK;
|
||||
fatal_error "Loopback zones may only be associated with the loopback interface ($loopback_interface)" if $type == LOOPBACK;
|
||||
}
|
||||
} else {
|
||||
fatal_error "Invalid HOST(S) column contents: $hosts"
|
||||
@@ -2032,6 +2069,7 @@ sub process_host( ) {
|
||||
$zoneref->{options}{in}{blacklist} = 1;
|
||||
} elsif ( $option =~ /^mss=(\d+)$/ ) {
|
||||
fatal_error "Invalid mss ($1)" unless $1 >= 500;
|
||||
require_capability 'TCPMSS_TARGET', $option, 's';
|
||||
$options{mss} = $1;
|
||||
$zoneref->{options}{complex} = 1;
|
||||
} elsif ( $validhostoptions{$option}) {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
# (c) 1999-2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This program is part of Shorewall.
|
||||
# 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.
|
||||
# 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
|
||||
@@ -17,30 +17,41 @@
|
||||
#
|
||||
# Options are:
|
||||
#
|
||||
# -n Don't alter Routing
|
||||
# -v and -q Standard Shorewall Verbosity control
|
||||
# -t Timestamp progress messages
|
||||
# -p Purge conntrack table
|
||||
# -r Recover from failed start/restart
|
||||
# -V <verbosity> Set verbosity level explicitly
|
||||
# -R <restore> Overrides RESTOREFILE setting
|
||||
# -n Do not alter Routing
|
||||
# -v and -q Standard Shorewall Verbosity control
|
||||
# -t Timestamp progress messages
|
||||
# -p Purge conntrack table
|
||||
# -r Recover from failed start/restart
|
||||
# -V <verbosity> Set verbosity level explicitly
|
||||
# -R <restore> Overrides RESTOREFILE setting
|
||||
#
|
||||
# Commands are:
|
||||
#
|
||||
# start Starts the firewall
|
||||
# refresh Refresh the firewall
|
||||
# restart Restarts the firewall
|
||||
# reload Reload the firewall
|
||||
# clear Removes all firewall rules
|
||||
# stop Stops the firewall
|
||||
# status Displays firewall status
|
||||
# version Displays the version of Shorewall that
|
||||
# generated this program
|
||||
# clear Removes all firewall rules
|
||||
# disable Disable an optional interface
|
||||
# down Stop an optional interface
|
||||
# enable Enable an optional interface
|
||||
# help Show command syntax
|
||||
# reenable Disable then nable an optional
|
||||
# interface
|
||||
# refresh Refresh the firewall
|
||||
# reload Reload the firewall
|
||||
# restart Restarts the firewall
|
||||
# restore Restore a saved configuration
|
||||
# reset Reset byte and packet counters
|
||||
# run Call a function in this program
|
||||
# savesets Save the ipset contents
|
||||
# status Displays firewall status
|
||||
# start Starts the firewall
|
||||
# stop Stops the firewall
|
||||
# up Start an optional interface
|
||||
# version Displays the version of Shorewall that
|
||||
# generated this program
|
||||
#
|
||||
################################################################################
|
||||
# Functions imported from /usr/share/shorewall/lib.core
|
||||
################################################################################
|
||||
# Address family-neutral Functions
|
||||
# Address family-neutral Functions
|
||||
################################################################################
|
||||
#
|
||||
# Conditionally produce message
|
||||
@@ -587,54 +598,67 @@ debug_restore_input() {
|
||||
done
|
||||
}
|
||||
|
||||
interface_up() {
|
||||
interface_enabled() {
|
||||
return $(cat ${VARDIR}/$1.status)
|
||||
}
|
||||
|
||||
distribute_load() {
|
||||
local interface
|
||||
local totalload
|
||||
local load
|
||||
local mark
|
||||
local maxload
|
||||
local currentload # Total load of enabled interfaces
|
||||
local load # Specified load of an enabled interface
|
||||
local mark # Mark of an enabled interface
|
||||
local totalload # Total load of all interfaces - usually 1.000000
|
||||
local nload # Normalized load of an enabled interface
|
||||
local var # Interface name to embed in a variable name
|
||||
|
||||
maxload=$1
|
||||
totalload=$1
|
||||
shift
|
||||
|
||||
totalload=0
|
||||
currentload=0
|
||||
|
||||
for interface in $@; do
|
||||
if interface_up $interface; then
|
||||
if interface_enabled $interface; then
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
load=$(cat ${VARDIR}/${interface}_load)
|
||||
eval ${interface}_load=$load
|
||||
eval ${var}_load=$load
|
||||
mark=$(cat ${VARDIR}/${interface}_mark)
|
||||
eval ${interface}_mark=$mark
|
||||
totalload=$( bc <<EOF
|
||||
eval ${var}_mark=$mark
|
||||
currentload=$( bc <<EOF
|
||||
scale=8
|
||||
$totalload + $load
|
||||
$currentload + $load
|
||||
EOF
|
||||
)
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $totalload ]; then
|
||||
if [ $currentload ]; then
|
||||
for interface in $@; do
|
||||
qt $g_tool -t mangle -F ~$interface
|
||||
eval load=\$${interface}_load
|
||||
eval mark=\$${interface}_mark
|
||||
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
eval load=\$${var}_load
|
||||
eval mark=\$${var}_mark
|
||||
|
||||
if [ -n "$load" ]; then
|
||||
load=$(bc <<EOF
|
||||
nload=$(bc <<EOF
|
||||
scale=8
|
||||
( $load / $totalload ) * $maxload
|
||||
( $load / $currentload ) * $totalload
|
||||
EOF
|
||||
)
|
||||
totalload=$(bc <<EOF
|
||||
currentload=$(bc <<EOF
|
||||
scale=8
|
||||
$totalload - $load
|
||||
$currentload - $load
|
||||
EOF
|
||||
)
|
||||
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load -j MARK --set-mark $mark
|
||||
|
||||
case $nload in
|
||||
.*|0.*)
|
||||
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $nload -j MARK --set-mark $mark
|
||||
;;
|
||||
*)
|
||||
run_iptables -t mangle -A ~$interface -j MARK --set-mark $mark
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -652,7 +676,7 @@ interface_is_usable() # $1 = interface
|
||||
local status;
|
||||
status=0
|
||||
|
||||
if [ "$1" != lo ]; then
|
||||
if ! loopback_interface $1; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
|
||||
[ "$COMMAND" = enable ] || run_isusable_exit $1
|
||||
status=$?
|
||||
@@ -845,6 +869,7 @@ detect_dynamic_gateway() { # $1 = interface
|
||||
local GATEWAYS
|
||||
GATEWAYS=
|
||||
local gateway
|
||||
local file
|
||||
|
||||
gateway=$(run_findgw_exit $1);
|
||||
|
||||
@@ -852,14 +877,21 @@ detect_dynamic_gateway() { # $1 = interface
|
||||
gateway=$( find_peer $($IP addr list $interface ) )
|
||||
fi
|
||||
|
||||
if [ -z "$gateway" -a -f ${VARLIB}/dhcpcd/dhcpcd-${1}.info ]; then
|
||||
eval $(grep ^GATEWAYS= ${VARLIB}/dhcpcd/dhcpcd-${1}.info 2> /dev/null)
|
||||
file="${VARLIB}/dhcpcd/dhcpcd-${1}.info"
|
||||
if [ -z "$gateway" -a -f "${file}" ]; then
|
||||
eval $(grep ^GATEWAYS= "${file}" 2> /dev/null)
|
||||
[ -n "$GATEWAYS" ] && GATEWAYS=${GATEWAYS%,*} && gateway=$GATEWAYS
|
||||
fi
|
||||
|
||||
if [ -z "$gateway" -a -f ${VARLIB}/dhcp/dhclient-${1}.lease ]; then
|
||||
gateway=$(grep 'option routers' ${VARLIB}/dhcp/dhclient-${1}.lease | tail -n 1 | while read j1 j2 gateway; do echo $gateway ; return 0; done)
|
||||
fi
|
||||
for file in \
|
||||
"${VARLIB}/dhcp/dhclient-${1}.lease" \
|
||||
"${VARLIB}/dhcp/dhclient.${1}.leases"
|
||||
do
|
||||
[ -n "$gateway" ] && break
|
||||
if [ -f "${file}" ]; then
|
||||
gateway=$(grep 'option routers' "${file}" | tail -n 1 | while read j1 j2 gateway; do echo "${gateway%\;}" ; return 0; done)
|
||||
fi
|
||||
done
|
||||
|
||||
[ -n "$gateway" ] && echo $gateway
|
||||
}
|
||||
@@ -894,18 +926,21 @@ detect_gateway() # $1 = interface
|
||||
# Disable IPV6
|
||||
#
|
||||
disable_ipv6() {
|
||||
local foo
|
||||
foo="$($IP -f inet6 addr list 2> /dev/null)"
|
||||
local temp
|
||||
temp="$($IP -f inet6 addr list 2> /dev/null)"
|
||||
|
||||
if [ -n "$foo" ]; then
|
||||
if [ -n "$temp" ]; then
|
||||
if [ -x "$IP6TABLES" ]; then
|
||||
$IP6TABLES -P FORWARD DROP
|
||||
$IP6TABLES -P INPUT DROP
|
||||
$IP6TABLES -P OUTPUT DROP
|
||||
$IP6TABLES -F
|
||||
$IP6TABLES -X
|
||||
$IP6TABLES -A OUTPUT -o lo -j ACCEPT
|
||||
$IP6TABLES -A INPUT -i lo -j ACCEPT
|
||||
|
||||
for temp in $(find_loopback_interfaces); do
|
||||
$IP6TABLES -A OUTPUT -o $temp -j ACCEPT
|
||||
$IP6TABLES -A INPUT -i $temp -j ACCEPT
|
||||
done
|
||||
else
|
||||
error_message "WARNING: DISABLE_IPV6=Yes in shorewall.conf but this system does not appear to have ip6tables"
|
||||
fi
|
||||
|
@@ -15,12 +15,14 @@ usage() {
|
||||
echo " down <interface>"
|
||||
echo " enable <interface>"
|
||||
echo " reset"
|
||||
echo " reenable <interface>"
|
||||
echo " refresh"
|
||||
echo " restart"
|
||||
echo " run <command> [ <parameter> ... ]"
|
||||
echo " status"
|
||||
echo " up <interface>"
|
||||
echo " savesets <file>"
|
||||
echo " call <function> [ <parameter> ... ]"
|
||||
echo " version"
|
||||
echo
|
||||
echo "Options are:"
|
||||
@@ -29,6 +31,7 @@ usage() {
|
||||
echo " -n Don't update routing configuration"
|
||||
echo " -p Purge Conntrack Table"
|
||||
echo " -t Timestamp progress Messages"
|
||||
echo " -c Save/restore iptables counters"
|
||||
echo " -V <verbosity> Set verbosity explicitly"
|
||||
echo " -R <file> Override RESTOREFILE setting"
|
||||
exit $1
|
||||
@@ -86,6 +89,17 @@ g_purge=$PURGE
|
||||
g_noroutes=$NOROUTES
|
||||
g_timestamp=$TIMESTAMP
|
||||
g_recovering=$RECOVERING
|
||||
#
|
||||
# These two variables contain the high-order and low-order parts respectively of
|
||||
# an SHA1 digest of this file. The digest is generated before the two following
|
||||
# lines are updated to contain the value of that digest.
|
||||
#
|
||||
g_sha1sum1=
|
||||
g_sha1sum2=
|
||||
#
|
||||
# Other Globals
|
||||
#
|
||||
g_counters=
|
||||
|
||||
initialize
|
||||
|
||||
@@ -137,6 +151,10 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
g_recovering=Yes
|
||||
option=${option#r}
|
||||
;;
|
||||
c*)
|
||||
g_counters=Yes
|
||||
option=${option#c}
|
||||
;;
|
||||
V*)
|
||||
option=${option#V}
|
||||
|
||||
@@ -357,20 +375,37 @@ case "$COMMAND" in
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration
|
||||
enable_provider $1
|
||||
detect_configuration $1
|
||||
enable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
disable)
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration
|
||||
disable_provider $1
|
||||
detect_configuration $1
|
||||
disable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
reenable)
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration $1
|
||||
COMMAND=enable disable_provider $1 Yes
|
||||
COMMAND=disable enable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
run)
|
||||
@@ -387,10 +422,35 @@ case "$COMMAND" in
|
||||
savesets)
|
||||
if [ $# -eq 2 ]; then
|
||||
save_ipsets $2
|
||||
status=$?
|
||||
else
|
||||
usage 2
|
||||
fi
|
||||
;;
|
||||
call)
|
||||
#
|
||||
# Way to call functions in the generated script directly
|
||||
#
|
||||
detect_configuration
|
||||
|
||||
shift
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# See what it is
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
fatal_error "$1 is not a known shell function"
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
version)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo $SHOREWALL_VERSION
|
||||
|
@@ -188,7 +188,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -199,7 +199,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -196,7 +196,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -199,7 +199,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, "-m recent --name $event --remove --rdest" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rdest" );
|
||||
} else {
|
||||
perl_action_helper( $action, "-m recent --name $event --remove --rsource" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rsource" );
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, "-m recent --name $event --set --rdest" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --set --rdest" );
|
||||
} else {
|
||||
perl_action_helper( $action, "-m recent --name $event --set --rsource" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --set --rsource" );
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -166,7 +166,7 @@ HELPERS=
|
||||
|
||||
IMPLICIT_CONTINUE=No
|
||||
|
||||
INLINE_MATCHES=Yes
|
||||
INLINE_MATCHES=No
|
||||
|
||||
IPSET_WARNINGS=Yes
|
||||
|
||||
|
@@ -58,8 +58,14 @@ loadmodule nf_nat_sip
|
||||
loadmodule nf_nat_snmp_basic
|
||||
loadmodule nf_nat_tftp
|
||||
#
|
||||
# While not actually helpers, these are handy to have
|
||||
# While not actually helpers, these are included here so that
|
||||
# LOG_BACKEND can work correctly. Not all of them will be
|
||||
# loaded, since at least one of them will be an alias on any
|
||||
# given system.
|
||||
#
|
||||
loadmodule ipt_LOG
|
||||
loadmodule nf_log_ipv4
|
||||
loadmodule xt_LOG
|
||||
loadmodule xt_NFLOG
|
||||
loadmodule xt_ULOG
|
||||
loadmodule ipt_ULOG
|
||||
loadmodule nfnetlink_log
|
||||
|
@@ -39,7 +39,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting Shorewall: "
|
||||
$shorewall $OPTIONS start 2>&1 | $logger
|
||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
@@ -69,7 +69,7 @@ restart() {
|
||||
# Note that we don't simply stop and start since shorewall has a built in
|
||||
# restart which stops the firewall if running and then starts it.
|
||||
echo -n $"Restarting Shorewall: "
|
||||
$shorewall $OPTIONS restart 2>&1 | $logger
|
||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
|
@@ -10,15 +10,16 @@
|
||||
|
||||
OPTIONS=""
|
||||
|
||||
# Use /etc/default shorewall to specify $OPTIONS to run at startup, however this
|
||||
# this might prevent shorewall from starting. use at your own risk
|
||||
# Use /etc/default shorewall to specify $OPTIONS and STARTOPTIONS to
|
||||
# run at startup, however this this might prevent shorewall from
|
||||
# starting. use at your own risk
|
||||
if [ -f /etc/default/shorewall ] ; then
|
||||
. /etc/default/shorewall
|
||||
fi
|
||||
|
||||
start() {
|
||||
echo "Starting IPv4 shorewall rules..."
|
||||
exec /sbin/shorewall $OPTIONS start
|
||||
exec /sbin/shorewall $OPTIONS start $STARTOPTIONS
|
||||
}
|
||||
|
||||
stop() {
|
||||
@@ -28,7 +29,7 @@ stop() {
|
||||
|
||||
restart() {
|
||||
echo "Restarting IPv4 shorewall rules..."
|
||||
exec /sbin/shorewall restart
|
||||
exec /sbin/shorewall restart $RESTARTOPTIONS
|
||||
}
|
||||
|
||||
status() {
|
||||
|
@@ -323,6 +323,7 @@ if [ $PRODUCT = shorewall ]; then
|
||||
fi
|
||||
|
||||
eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Chains.pm
|
||||
eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Config.pm
|
||||
fi
|
||||
elif [ "$BUILD" = "$HOST" ]; then
|
||||
#
|
||||
@@ -332,6 +333,7 @@ if [ $PRODUCT = shorewall ]; then
|
||||
if ! perl -e 'use Digest::SHA;' 2> /dev/null ; then
|
||||
if perl -e 'use Digest::SHA1;' 2> /dev/null ; then
|
||||
sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Chains.pm
|
||||
sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Config.pm
|
||||
DIGEST=SHA1
|
||||
else
|
||||
echo "ERROR: Shorewall $VERSION requires either Digest::SHA or Digest::SHA1" >&2
|
||||
@@ -395,7 +397,7 @@ echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
|
||||
#
|
||||
if [ -n "$INITFILE" ]; then
|
||||
if [ -f "${INITSOURCE}" ]; then
|
||||
initfile="${DESTDIR}/${INITDIR}/${INITFILE}"
|
||||
initfile="${DESTDIR}${INITDIR}/${INITFILE}"
|
||||
install_file $INITSOURCE "$initfile" 0544
|
||||
|
||||
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
|
||||
@@ -425,12 +427,16 @@ fi
|
||||
#
|
||||
# Install the .service file
|
||||
#
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service"
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -1176,7 +1182,7 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR
|
||||
fi
|
||||
|
||||
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
if systemctl enable ${PRODUCT}.service; then
|
||||
echo "$Product will start automatically at boot"
|
||||
fi
|
||||
|
@@ -109,25 +109,6 @@ get_config() {
|
||||
g_tool=$IP6TABLES
|
||||
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
|
||||
else
|
||||
IP='ip'
|
||||
fi
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
case "$IPSET" in
|
||||
*/*)
|
||||
@@ -188,7 +169,7 @@ get_config() {
|
||||
*)
|
||||
if [ -n "$STARTUP_ENABLED" ]; then
|
||||
fatal_error "Invalid Value for STARTUP_ENABLED: $STARTUP_ENABLED"
|
||||
exit 2
|
||||
exit 6
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -245,6 +226,25 @@ get_config() {
|
||||
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
|
||||
else
|
||||
IP='ip'
|
||||
fi
|
||||
|
||||
case $VERBOSITY in
|
||||
-1|0|1|2)
|
||||
;;
|
||||
@@ -323,6 +323,8 @@ get_config() {
|
||||
LEGACY_FASTSTART=Yes
|
||||
;;
|
||||
esac
|
||||
|
||||
g_loopback=$(find_loopback_interfaces)
|
||||
}
|
||||
|
||||
#
|
||||
@@ -534,6 +536,10 @@ start_command() {
|
||||
g_inline=Yes
|
||||
option=${option#i}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -570,14 +576,14 @@ start_command() {
|
||||
esac
|
||||
|
||||
if [ -n "${g_fast}${AUTOMAKE}" ]; then
|
||||
if [ -z "$g_fast" -o -z "$LEGACY_FASTSTART" ]; then
|
||||
if [ -z "$g_fast" -o -z "${LEGACY_FASTSTART}${g_counters}" ]; then
|
||||
#
|
||||
# Automake or LEGACY_FASTSTART=No -- use the last compiled script
|
||||
# Automake or ( LEGACY_FASTSTART=No and not -C ) -- use the last compiled script
|
||||
#
|
||||
object=firewall
|
||||
else
|
||||
#
|
||||
# 'start -f' with LEGACY_FASTSTART=Yes -- use last saved configuration
|
||||
# 'start -f' with ( LEGACY_FASTSTART=Yes or -C ) -- use last saved configuration
|
||||
#
|
||||
object=$RESTOREFILE
|
||||
fi
|
||||
@@ -943,6 +949,10 @@ restart_command() {
|
||||
g_inline=Yes
|
||||
option=${option#i}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -1635,6 +1645,7 @@ usage() # $1 = exit status
|
||||
echo " allow <address> ..."
|
||||
echo " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ <directory> ]"
|
||||
echo " clear"
|
||||
echo " close <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ <directory name> ] [ <path name> ]"
|
||||
echo " delete <interface>[:<host-list>] ... <zone>"
|
||||
echo " disable <interface>"
|
||||
@@ -1669,16 +1680,19 @@ usage() # $1 = exit status
|
||||
echo " noiptrace <ip6tables match expression>"
|
||||
fi
|
||||
|
||||
echo " open <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " reenable <interface>"
|
||||
echo " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]"
|
||||
echo " reject <address> ..."
|
||||
echo " reload [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ -i ] [ <directory> ] <system>"
|
||||
echo " reset [ <chain> ... ]"
|
||||
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ <file name> ]"
|
||||
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]"
|
||||
echo " run <command> [ <parameter> ... ]"
|
||||
echo " safe-restart [ -t <timeout> ] [ <directory> ]"
|
||||
echo " safe-start [ -t <timeout> ] [ <directory> ]"
|
||||
echo " save [ <file name> ]"
|
||||
echo " save [ -C ] [ <file name> ]"
|
||||
echo " savesets"
|
||||
echo " [ show | list | ls ] [ -x ] [ -t {filter|mangle|nat|raw|rawpost} ] [ {chain [<chain> [ <chain> ... ]"
|
||||
echo " [ show | list | ls ] actions"
|
||||
echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
|
||||
@@ -1700,16 +1714,17 @@ usage() # $1 = exit status
|
||||
echo " [ show | list | ls ] marks"
|
||||
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost|routing"
|
||||
echo " [ show | list | ls ] nfacct"
|
||||
echo " [ show | list | ls ] opens"
|
||||
echo " [ show | list | ls ] policies"
|
||||
echo " [ show | list | ls ] routing"
|
||||
echo " [ show | list | ls ] tc [ device ]"
|
||||
echo " [ show | list | ls ] vardir"
|
||||
echo " [ show | list | ls ] zones"
|
||||
echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
|
||||
echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
|
||||
echo " status [ -i ]"
|
||||
echo " stop"
|
||||
echo " try <directory> [ <timeout> ]"
|
||||
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]"
|
||||
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]"
|
||||
echo " version [ -a ]"
|
||||
echo
|
||||
exit $1
|
||||
|
@@ -90,7 +90,8 @@
|
||||
role="bold">NOTRACK</emphasis>|<emphasis
|
||||
role="bold">CT</emphasis>:<emphasis
|
||||
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<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: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>
|
||||
|
||||
<listitem>
|
||||
<para>This column is only present when FORMAT >= 2. Values other
|
||||
@@ -114,7 +115,8 @@
|
||||
<replaceable>name</replaceable> to this connection. This is more
|
||||
flexible than loading the conntrack helper with preset ports. If
|
||||
a <replaceable>log-level</replaceable> is specified, the packet
|
||||
will also be logged at that level.</para>
|
||||
will also be logged at that level. Beginning with Shorewall
|
||||
4.6.10, the helper name is optional</para>
|
||||
|
||||
<para>At this writing, the available helpers are:</para>
|
||||
|
||||
@@ -244,6 +246,31 @@
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>ctevents:<replaceable>event</replaceable>[,...]</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.10. Only generate the specified
|
||||
conntrack events for this connection. Possible event types are:
|
||||
<emphasis role="bold">new</emphasis>, <emphasis
|
||||
role="bold">related</emphasis>, <emphasis
|
||||
role="bold">destroy</emphasis>, <emphasis
|
||||
role="bold">reply</emphasis>, <emphasis
|
||||
role="bold">assured</emphasis>, <emphasis
|
||||
role="bold">protoinfo</emphasis>, <emphasis
|
||||
role="bold">helper</emphasis>, <emphasis
|
||||
role="bold">mark</emphasis> (this is connection mark, not packet
|
||||
mark), <emphasis role="bold">natseqinfo</emphasis>, and
|
||||
<emphasis role="bold">secmark</emphasis>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>expevents=new</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.10. Only generate <emphasis
|
||||
role="bold">new</emphasis> expectation events for this
|
||||
connection.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>DROP</option></para>
|
||||
|
||||
|
@@ -382,6 +382,17 @@ loc eth2 -</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>loopback</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.6. Designates the interface as
|
||||
the loopback interface. This option is assumed if the
|
||||
interface's physical name is 'lo'. Only one interface man have
|
||||
the <option>loopback</option> option specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">logmartians[={0|1}]</emphasis></term>
|
||||
@@ -902,7 +913,7 @@ net ppp0 -</programlisting>
|
||||
|
||||
<programlisting>FORMAT 2
|
||||
#ZONE INTERFACE OPTIONS
|
||||
- br0 routeback</programlisting>
|
||||
- br0 bridge</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@@ -124,7 +124,29 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>CHECKSUM</term>
|
||||
<term><emphasis
|
||||
role="bold">ADD(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.7. Causes addresses and/or port
|
||||
numbers to be added to the named
|
||||
<replaceable>ipset</replaceable>. The
|
||||
<replaceable>flags</replaceable> specify the address or tuple
|
||||
to be added to the set and must match the type of ipset
|
||||
involved. For example, for an iphash ipset, either the SOURCE
|
||||
or DESTINATION address can be added using
|
||||
<replaceable>flags</replaceable> <emphasis
|
||||
role="bold">src</emphasis> or <emphasis
|
||||
role="bold">dst</emphasis> respectively (see the -A command in
|
||||
ipset (8)).</para>
|
||||
|
||||
<para>ADD is non-terminating. Even if a packet matches the
|
||||
rule, it is passed on to the next rule.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">CHECKSUM</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Compute and fill in the checksum in a packet that lacks
|
||||
@@ -139,7 +161,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>CLASSIFY(<replaceable>classid</replaceable>)</term>
|
||||
<term><emphasis
|
||||
role="bold">CLASSIFY(<replaceable>classid</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>A classification Id (classid) is of the form
|
||||
@@ -189,7 +212,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>CONMARK({mark|range})</term>
|
||||
<term><emphasis
|
||||
role="bold">CONMARK({mark|range})</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Identical to MARK with the exception that the mark is
|
||||
@@ -212,6 +236,27 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">DEL(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.7. Causes an entry to be deleted
|
||||
from the named <replaceable>ipset</replaceable>. The
|
||||
<replaceable>flags</replaceable> specify the address or tuple
|
||||
to be deleted from the set and must match the type of ipset
|
||||
involved. For example, for an iphash ipset, either the SOURCE
|
||||
or DESTINATION address can be deleted using
|
||||
<replaceable>flags</replaceable> <emphasis
|
||||
role="bold">src</emphasis> or <emphasis
|
||||
role="bold">dst</emphasis> respectively (see the -D command in
|
||||
ipset (8)).</para>
|
||||
|
||||
<para>DEL is non-terminating. Even if a packet matches the
|
||||
rule, it is passed on to the next rule.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">DIVERT</emphasis></term>
|
||||
|
||||
@@ -322,7 +367,7 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>IPMARK</term>
|
||||
<term><emphasis role="bold">IPMARK</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Assigns a mark to each matching packet based on the
|
||||
@@ -430,8 +475,9 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>IPTABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</term>
|
||||
<term><emphasis
|
||||
role="bold">IPTABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>This action allows you to specify an iptables target
|
||||
@@ -452,7 +498,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</term>
|
||||
<term><emphasis
|
||||
role="bold">MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>mark</replaceable> is a packet mark
|
||||
@@ -495,7 +542,7 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">RESTORE</emphasis>[(/<emphasis>mask</emphasis>)]</term>
|
||||
role="bold">RESTORE</emphasis>[(<emphasis>mask</emphasis>)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restore the packet's mark from the connection's mark
|
||||
@@ -505,7 +552,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">SAME</emphasis></term>
|
||||
<term><emphasis
|
||||
role="bold">SAME[(<replaceable>timeout</replaceable>)]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Some websites run applications that require multiple
|
||||
@@ -529,17 +577,22 @@ SAME:P 192.168.1.0/24 0.0.0.0/0 tcp 80,443</programlisting>
|
||||
connections to an individual remote system to all use the same
|
||||
provider. For example:<programlisting>#ACTION SOURCE DEST PROTO DEST
|
||||
# PORT(S)
|
||||
SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
|
||||
If the firewall attempts a connection on TCP port 80 or 443
|
||||
and it has sent a packet on either of those ports in the last
|
||||
five minutes to the same remote system then the new connection
|
||||
will use the same provider as the connection over which that
|
||||
last packet was sent.</para>
|
||||
SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>The
|
||||
optional <replaceable>timeout</replaceable> parameter was
|
||||
added in Shorewall 4.6.7 and specifies a number of seconds .
|
||||
When not specified, a value of 300 seconds (5 minutes) is
|
||||
assumed. If the firewall attempts a connection on TCP port 80
|
||||
or 443 and it has sent a packet on either of those ports in
|
||||
the last <replaceable>timeout</replaceable> seconds to the
|
||||
same remote system then the new connection will use the same
|
||||
provider as the connection over which that last packet was
|
||||
sent.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">SAVE[(/<emphasis>mask)</emphasis>]
|
||||
<term><emphasis
|
||||
role="bold">SAVE[(<emphasis><replaceable>mask</replaceable>)</emphasis>]
|
||||
</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
|
@@ -105,7 +105,7 @@
|
||||
role="bold">REJECT</emphasis>|<emphasis
|
||||
role="bold">CONTINUE</emphasis>|<emphasis
|
||||
role="bold">QUEUE</emphasis>|<emphasis
|
||||
role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber</emphasis>)]|<emphasis
|
||||
role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber1</emphasis>[:<replaceable>queuenumber2</replaceable>])]|<emphasis
|
||||
role="bold">NONE</emphasis>}[<emphasis
|
||||
role="bold">:</emphasis>{<emphasis>default-action-or-macro</emphasis>[:level]|<emphasis
|
||||
role="bold">None</emphasis>}]</term>
|
||||
@@ -180,8 +180,14 @@
|
||||
<listitem>
|
||||
<para>Queue the request for a user-space application using the
|
||||
nfnetlink_queue mechanism. If a
|
||||
<replaceable>queuenumber</replaceable> is not given, queue
|
||||
zero (0) is assumed.</para>
|
||||
<replaceable>queuenumber1</replaceable> is not given, queue
|
||||
zero (0) is assumed. Beginning with Shorewall 4.6.10, a second
|
||||
queue number (queuenumber2) may be given. This specifies a
|
||||
range of queues to use. Packets are then balanced across the
|
||||
given queues. This is useful for multicore systems: start
|
||||
multiple instances of the userspace program on queues x, x+1,
|
||||
.. x+n and use "x:x+n". Packets belonging to the same
|
||||
connection are put into the same nfqueue.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -242,13 +248,34 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">BURST:LIMIT</emphasis> (limit) -
|
||||
[{<emphasis>s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">second</emphasis>|<emphasis
|
||||
role="bold">minute</emphasis>}[:<emphasis>burst</emphasis>]</term>
|
||||
[-|<replaceable>limit</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>where limit is one of:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>[<emphasis
|
||||
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
|
||||
|
||||
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst2</emphasis>]</member>
|
||||
</simplelist>
|
||||
|
||||
<para>If passed, specifies the maximum TCP connection
|
||||
<emphasis>rate</emphasis> and the size of an acceptable
|
||||
<emphasis>burst</emphasis>. If not specified, TCP connections are
|
||||
@@ -261,9 +288,19 @@
|
||||
the user and specifies a hash table to be used to count matching
|
||||
connections. If not give, the name <emphasis
|
||||
role="bold">shorewall</emphasis> is assumed. Where more than one
|
||||
POLICY specifies the same name, the connections counts for the
|
||||
policies are aggregated and the individual rates apply to the
|
||||
POLICY or rule specifies the same name, the connections counts for
|
||||
the policies are aggregated and the individual rates apply to the
|
||||
aggregated count.</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.5, two<replaceable>
|
||||
limit</replaceable>s may be specified, separated by a comma. In this
|
||||
case, the first limit (<replaceable>name1</replaceable>,
|
||||
<replaceable>rate1</replaceable>, burst1) specifies the per-source
|
||||
IP limit and the second limit specifies the per-destination IP
|
||||
limit.</para>
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -220,7 +220,22 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>noautosrc</term>
|
||||
<term><emphasis
|
||||
role="bold">load=<replaceable>probability</replaceable></emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.0. This option provides an
|
||||
alternative method of load balancing based on probabilities.
|
||||
Providers to be balanced are given a
|
||||
<replaceable>probability</replaceable> (a number 0 > n
|
||||
>= 1) with up to 8 digits to the right of the decimal
|
||||
point. Beginning with Shorewall 4.6.10, a warning is issued if
|
||||
the sum of the probabilities is not 1.00000000.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">noautosrc</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.17. Prevents the addition of a
|
||||
@@ -255,6 +270,19 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">primary</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.6, <emphasis
|
||||
role="bold">primary</emphasis> is equivalent to <emphasis
|
||||
role="bold">balance=1</emphasis> and is preferred when the
|
||||
remaining providers specify <emphasis
|
||||
role="bold">fallback</emphasis> or <emphasis
|
||||
role="bold">tproxy</emphasis>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">src=</emphasis><replaceable>source-address</replaceable></term>
|
||||
|
@@ -48,6 +48,9 @@
|
||||
&<replaceable>interface</replaceable> in this column to indicate
|
||||
that the source is the primary IP address of the named
|
||||
interface.</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.8, you may specify a
|
||||
comma-separated list of addresses in this column.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -64,6 +67,9 @@
|
||||
role="bold">DEST</emphasis>, place "-" in that column. Note that you
|
||||
may not omit both <emphasis role="bold">SOURCE</emphasis> and
|
||||
<emphasis role="bold">DEST</emphasis>.</para>
|
||||
|
||||
<para>Beginning with Shorewall 4.6.8, you may specify a
|
||||
comma-separated list of addresses in this column.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -559,24 +559,36 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">NFQUEUE</emphasis>[(<replaceable>queuenumber</replaceable>)]</term>
|
||||
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber</replaceable>1[:<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Queues the packet to a user-space application using the
|
||||
nfnetlink_queue mechanism. If a
|
||||
<replaceable>queuenumber</replaceable> is not specified, queue
|
||||
zero (0) is assumed.</para>
|
||||
<replaceable>queuenumber</replaceable>1 is not specified,
|
||||
queue zero (0) is assumed. Beginning with Shorewall 4.6.10,
|
||||
the keyword <emphasis role="bold">bypass</emphasis> can be
|
||||
given. By default, if no userspace program is listening on an
|
||||
NFQUEUE, then all packets that are to be queued are dropped.
|
||||
When this option is used, the NFQUEUE rule is silently
|
||||
bypassed instead. The packet will move on to the next rule.
|
||||
Also beginning in Shorewall 4.6.10, a second queue number
|
||||
(<replaceable>queuenumber2</replaceable>) may be specified.
|
||||
This specifies a range of queues to use. Packets are then
|
||||
balanced across the given queues. This is useful for multicore
|
||||
systems: start multiple instances of the userspace program on
|
||||
queues x, x+1, .. x+n and use "x:x+n". Packets belonging to
|
||||
the same connection are put into the same nfqueue.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">NFQUEUE![(<replaceable>queuenumber</replaceable>)]</emphasis></term>
|
||||
<term><emphasis role="bold"><emphasis
|
||||
role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>like NFQUEUE but exempts the rule from being suppressed
|
||||
by OPTIMIZE=1 in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).</para>
|
||||
url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -652,6 +664,76 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>TARPIT [(<emphasis role="bold">tarpit</emphasis> |
|
||||
<emphasis role="bold">honeypot</emphasis> | <emphasis
|
||||
role="bold">reset</emphasis>)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.6.</para>
|
||||
|
||||
<para>TARPIT captures and holds incoming TCP connections using
|
||||
no local per-connection resources.</para>
|
||||
|
||||
<para>TARPIT only works with the PROTO column set to tcp (6),
|
||||
and is totally application agnostic. This module will answer a
|
||||
TCP request and play along like a listening server, but aside
|
||||
from sending an ACK or RST, no data is sent. Incoming packets
|
||||
are ignored and dropped. The attacker will terminate the
|
||||
session eventually. This module allows the initial packets of
|
||||
an attack to be captured by other software for inspection. In
|
||||
most cases this is sufficient to determine the nature of the
|
||||
attack.</para>
|
||||
|
||||
<para>This offers similar functionality to LaBrea
|
||||
<http://www.hackbusters.net/LaBrea/> but does not
|
||||
require dedicated hardware or IPs. Any TCP port that you would
|
||||
normally DROP or REJECT can instead become a tarpit.</para>
|
||||
|
||||
<para>The target accepts a single optional parameter:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>tarpit</term>
|
||||
|
||||
<listitem>
|
||||
<para>This mode is the default and completes a
|
||||
connection with the attacker but limits the window size
|
||||
to 0, thus keeping the attacker waiting long periods of
|
||||
time. While he is maintaining state of the connection
|
||||
and trying to continue every 60-240 seconds, we keep
|
||||
none, so it is very lightweight. Attempts to close the
|
||||
connection are ignored, forcing the remote side to time
|
||||
out the connection in 12-24 minutes.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>honeypot</term>
|
||||
|
||||
<listitem>
|
||||
<para>This mode completes a connection with the
|
||||
attacker, but signals a normal window size, so that the
|
||||
remote side will attempt to send data, often with some
|
||||
very nasty exploit attempts. We can capture these
|
||||
packets for decoding and further analysis. The module
|
||||
does not send any data, so if the remote expects an
|
||||
application level response, the game is up.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>reset</term>
|
||||
|
||||
<listitem>
|
||||
<para>This mode is handy because we can send an inline
|
||||
RST (reset). It has no other function.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)]</term>
|
||||
@@ -786,7 +868,10 @@
|
||||
When there are nested zones, <emphasis role="bold">any</emphasis>
|
||||
only refers to top-level zones (those with no parent zones). Note
|
||||
that <emphasis role="bold">any</emphasis> excludes all vserver
|
||||
zones, since those zones are nested within the firewall zone.</para>
|
||||
zones, since those zones are nested within the firewall zone.
|
||||
Beginning with Shorewall 4.4.13, exclusion is supported with
|
||||
<emphasis role="bold">any</emphasis> -- see see <ulink
|
||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
||||
|
||||
<para>Hosts may also be specified as an IP address range using the
|
||||
syntax
|
||||
@@ -892,18 +977,28 @@
|
||||
(Shorewall 4.4.17 and later).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>loc,dmz</term>
|
||||
|
||||
<listitem>
|
||||
<para>Both the <emphasis role="bold">loc</emphasis> and
|
||||
<emphasis role="bold">dmz</emphasis> zones.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>all!dmz</term>
|
||||
|
||||
<listitem>
|
||||
<para>All but the <emphasis role="bold">dmz</emphasis>
|
||||
zone.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term></term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">DEST</emphasis> -
|
||||
{<emphasis>zone</emphasis>|<emphasis>zone-list</emphasis>[+]|{<emphasis
|
||||
@@ -947,6 +1042,35 @@
|
||||
the <emphasis role="bold">SOURCE</emphasis> or <emphasis
|
||||
role="bold">DEST</emphasis> column, the rule is ignored.</para>
|
||||
|
||||
<para><emphasis role="bold">all</emphasis> means "All Zones",
|
||||
including the firewall itself. <emphasis role="bold">all-</emphasis>
|
||||
means "All Zones, except the firewall itself". When <emphasis
|
||||
role="bold">all</emphasis>[<emphasis role="bold">-</emphasis>] is
|
||||
used either in the <emphasis role="bold">SOURCE</emphasis> or
|
||||
<emphasis role="bold">DEST</emphasis> column intra-zone traffic is
|
||||
not affected. When <emphasis role="bold">all+</emphasis>[<emphasis
|
||||
role="bold">-</emphasis>] is "used, intra-zone traffic is affected.
|
||||
Beginning with Shorewall 4.4.13, exclusion is supported -- see see
|
||||
<ulink
|
||||
url="/manpages6/shorewall6-exclusion.html">shorewall6-exclusion</ulink>(5).</para>
|
||||
|
||||
<para><emphasis role="bold">any</emphasis> is equivalent to
|
||||
<emphasis role="bold">all</emphasis> when there are no nested zones.
|
||||
When there are nested zones, <emphasis role="bold">any</emphasis>
|
||||
only refers to top-level zones (those with no parent zones). Note
|
||||
that <emphasis role="bold">any</emphasis> excludes all vserver
|
||||
zones, since those zones are nested within the firewall zone.</para>
|
||||
|
||||
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis
|
||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] or
|
||||
<emphasis role="bold">any</emphasis>[<emphasis
|
||||
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] is
|
||||
specified, clients may be further restricted to a list of networks
|
||||
and/or hosts by appending ":" and a comma-separated list of network
|
||||
and/or host addresses. Hosts may be specified by IP or MAC address;
|
||||
mac addresses must begin with "~" and must use "-" as a
|
||||
separator.</para>
|
||||
|
||||
<para>When <emphasis role="bold">all</emphasis> is used either in
|
||||
the <emphasis role="bold">SOURCE</emphasis> or <emphasis
|
||||
role="bold">DEST</emphasis> column intra-zone traffic is not
|
||||
@@ -955,11 +1079,6 @@
|
||||
exclusion is supported -- see see <ulink
|
||||
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
|
||||
|
||||
<para><emphasis role="bold">any</emphasis> is equivalent to
|
||||
<emphasis role="bold">all</emphasis> when there are no nested zones.
|
||||
When there are nested zones, <emphasis role="bold">any</emphasis>
|
||||
only refers to top-level zones (those with no parent zones).</para>
|
||||
|
||||
<para>The <replaceable>zone</replaceable> should be omitted in
|
||||
DNAT-, REDIRECT- and NONAT rules.</para>
|
||||
|
||||
@@ -980,7 +1099,8 @@
|
||||
</listitem>
|
||||
</orderedlist></para>
|
||||
|
||||
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis
|
||||
<para>Except when <emphasis
|
||||
role="bold">{all|any}</emphasis>[<emphasis
|
||||
role="bold">+]|[-</emphasis>] is specified, the server may be
|
||||
further restricted to a particular network, host or interface by
|
||||
appending ":" and the network, host or interface. See <emphasis
|
||||
@@ -1001,7 +1121,7 @@
|
||||
role="bold">DNAT-</emphasis>, the connections will be assigned to
|
||||
addresses in the range in a round-robin fashion.</para>
|
||||
|
||||
<para>If you kernel and iptables have ipset match support then you
|
||||
<para>If your kernel and iptables have ipset match support then you
|
||||
may give the name of an ipset prefaced by "+". The ipset name may be
|
||||
optionally followed by a number from 1 to 6 enclosed in square
|
||||
brackets ([]) to indicate the number of levels of destination
|
||||
@@ -1226,22 +1346,41 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">RATE LIMIT</emphasis> (rate) - [<emphasis
|
||||
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</term>
|
||||
<term><emphasis role="bold">RATE LIMIT</emphasis> (rate) -
|
||||
<replaceable>limit</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>limit</replaceable> is one of:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>[<emphasis
|
||||
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
|
||||
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
|
||||
|
||||
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
|
||||
role="bold">/</emphasis>{<emphasis
|
||||
role="bold">sec</emphasis>|<emphasis
|
||||
role="bold">min</emphasis>|<emphasis
|
||||
role="bold">hour</emphasis>|<emphasis
|
||||
role="bold">day</emphasis>}[:<emphasis>burst2</emphasis>]</member>
|
||||
</simplelist>
|
||||
|
||||
<para>You may optionally rate-limit the rule by placing a value in
|
||||
this column:</para>
|
||||
|
||||
<para><emphasis>rate</emphasis> is the number of connections per
|
||||
<para><emphasis>rate*</emphasis> is the number of connections per
|
||||
interval (<emphasis role="bold">sec</emphasis> or <emphasis
|
||||
role="bold">min</emphasis>) and <emphasis>burst</emphasis> is the
|
||||
role="bold">min</emphasis>) and <emphasis>burst</emphasis>* is the
|
||||
largest burst permitted. If no <emphasis>burst</emphasis> is given,
|
||||
a value of 5 is assumed. There may be no no white-space embedded in
|
||||
the specification.</para>
|
||||
@@ -1250,15 +1389,28 @@
|
||||
|
||||
<para>When <option>s:</option> or <option>d:</option> is specified,
|
||||
the rate applies per source IP address or per destination IP address
|
||||
respectively. The <replaceable>name</replaceable> may be chosen by
|
||||
the user and specifies a hash table to be used to count matching
|
||||
respectively. The <replaceable>name</replaceable>s may be chosen by
|
||||
the user and specifiy a hash table to be used to count matching
|
||||
connections. If not given, the name <emphasis
|
||||
role="bold">shorewallN</emphasis> (where N is a unique integer) is
|
||||
assumed. Where more than one rule specifies the same name, the
|
||||
connections counts for the rules are aggregated and the individual
|
||||
rates apply to the aggregated count.</para>
|
||||
assumed. Where more than one rule or POLICY specifies the same name,
|
||||
the connections counts for the rules are aggregated and the
|
||||
individual rates apply to the aggregated count.</para>
|
||||
|
||||
<para>Example: <emphasis role="bold">s:ssh:3/min:5</emphasis></para>
|
||||
<para>Beginning with Shorewall 4.6.5, two<replaceable>
|
||||
limit</replaceable>s may be specified, separated by a comma. In this
|
||||
case, the first limit (<replaceable>name1</replaceable>,
|
||||
<replaceable>rate1</replaceable>, burst1) specifies the per-source
|
||||
IP limit and the second limit specifies the per-destination IP
|
||||
limit.</para>
|
||||
|
||||
<para>Example: <emphasis
|
||||
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
|
||||
|
||||
<para>In this example, the 'client' hash table will be used to
|
||||
enforce the per-source limit and the compiler will pick a unique
|
||||
name for the hash table that tracks the per-destination
|
||||
limit.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -70,7 +70,8 @@
|
||||
<emphasis role="bold">openvpn</emphasis> - OpenVPN in point-to-point mode
|
||||
<emphasis role="bold">openvpnclient</emphasis> - OpenVPN client runs on the firewall
|
||||
<emphasis role="bold">openvpnserver</emphasis> - OpenVPN server runs on the firewall
|
||||
<emphasis role="bold">generic</emphasis> - Other tunnel type</programlisting>
|
||||
<emphasis role="bold">generic</emphasis> - Other tunnel type
|
||||
<emphasis role="bold">tinc</emphasis> - TINC (added in Shorewall 4.6.6)</programlisting>
|
||||
|
||||
<para>If the type is <emphasis role="bold">ipsec</emphasis>, it may
|
||||
be followed by <emphasis role="bold">:ah</emphasis> to indicate that
|
||||
@@ -270,6 +271,19 @@
|
||||
generic:udp:4444 net 4.3.99.124</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>Example 9:</term>
|
||||
|
||||
<listitem>
|
||||
<para>TINC tunnel where the remote gateways are not specified. If
|
||||
you wish to specify a list of gateways, you can do so in the GATEWAY
|
||||
column.</para>
|
||||
|
||||
<programlisting> #TYPE ZONE GATEWAY GATEWAY ZONES
|
||||
tinc net 0.0.0.0/0</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@@ -112,7 +112,7 @@
|
||||
role="bold">none</emphasis>}</term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
role="bold">none</emphasis>}</term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
role="bold">none</emphasis>}</term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
role="bold">none</emphasis>}</term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -384,6 +384,11 @@
|
||||
<para>Set AUTOHELPERS=No.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Modify the HELPERS setting (see below) to list the helpers
|
||||
that you need.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Either:</para>
|
||||
|
||||
@@ -902,9 +907,10 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
role="bold">HELPERS</emphasis>=[<emphasis>helper</emphasis>[,<replaceable>helper</replaceable>...]]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.7. This option lists the Netfilter
|
||||
application helpers that are to be enabled. If not specified, the
|
||||
default is to enable all helpers.</para>
|
||||
<para>Added in Shorewall 4.5.7. This option specifies a
|
||||
comma-separated list naming the Netfilter application helpers that
|
||||
are to be enabled. If not specified, the default is to enable all
|
||||
helpers.</para>
|
||||
|
||||
<para>Possible values for <replaceable>helper</replaceable>
|
||||
are:</para>
|
||||
@@ -1174,7 +1180,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para></para>
|
||||
<para/>
|
||||
|
||||
<blockquote>
|
||||
<para>If this variable is not set or is given an empty value
|
||||
@@ -1423,7 +1429,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para></para>
|
||||
<para/>
|
||||
|
||||
<blockquote>
|
||||
<para>For example, using the default LOGFORMAT, the log prefix for
|
||||
@@ -1440,7 +1446,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
control your firewall after you enable this option.</para>
|
||||
</important>
|
||||
|
||||
<para></para>
|
||||
<para/>
|
||||
|
||||
<caution>
|
||||
<para>Do not use this option if the resulting log messages will
|
||||
@@ -1784,8 +1790,8 @@ LOG:info:,bar net fw</programlisting>
|
||||
|
||||
<listitem>
|
||||
<para>The value of this option determines the possible file
|
||||
extensions of kernel modules. The default value is "ko ko.gz o o.gz
|
||||
gz".</para>
|
||||
extensions of kernel modules. The default value is "ko ko.gz ko.xz o
|
||||
o.gz o.xz gz xz".</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -2162,7 +2168,7 @@ LOG:info:,bar net fw</programlisting>
|
||||
role="bold">"</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para></para>
|
||||
<para/>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -28,4 +28,3 @@ loadmodule iptable_nat
|
||||
loadmodule iptable_raw
|
||||
loadmodule xt_state
|
||||
loadmodule xt_tcpudp
|
||||
loadmodule ipt_LOG
|
||||
|
@@ -32,7 +32,6 @@ loadmodule ipt_ipp2p
|
||||
loadmodule ipt_iprange
|
||||
loadmodule ipt_length
|
||||
loadmodule ipt_limit
|
||||
loadmodule ipt_LOG
|
||||
loadmodule ipt_mac
|
||||
loadmodule ipt_mark
|
||||
loadmodule ipt_MARK
|
||||
@@ -58,4 +57,3 @@ loadmodule ipt_tos
|
||||
loadmodule ipt_TOS
|
||||
loadmodule ipt_ttl
|
||||
loadmodule ipt_TTL
|
||||
loadmodule ipt_ULOG
|
||||
|
@@ -31,7 +31,6 @@ loadmodule xt_mac
|
||||
loadmodule xt_mark
|
||||
loadmodule xt_MARK
|
||||
loadmodule xt_multiport
|
||||
loadmodule xt_NFLOG
|
||||
loadmodule xt_NFQUEUE
|
||||
loadmodule xt_owner
|
||||
loadmodule xt_physdev
|
||||
|
@@ -5,7 +5,8 @@
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
@@ -13,7 +14,7 @@ Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall $OPTIONS start
|
||||
ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
|
21
Shorewall/shorewall.service.214
Normal file
21
Shorewall/shorewall.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -40,6 +40,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
@@ -197,7 +203,7 @@ fi
|
||||
|
||||
rm -rf ${VARDIR}/shorewall
|
||||
rm -rf ${PERLLIBDIR}/Shorewall/*
|
||||
rm -rf ${LIBEXECDIR}/shorewall
|
||||
[ ${LIBEXECDIR} = ${SHAREDIR} ] || rm -rf ${LIBEXECDIR}/shorewall
|
||||
rm -rf ${SHAREDIR}/shorewall/configfiles/
|
||||
rm -rf ${SHAREDIR}/shorewall/Samples/
|
||||
rm -rf ${SHAREDIR}/shorewall/Shorewall/
|
||||
|
@@ -39,7 +39,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting Shorewall: "
|
||||
$shorewall $OPTIONS start 2>&1 | $logger
|
||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
@@ -69,7 +69,7 @@ restart() {
|
||||
# Note that we don't simply stop and start since shorewall has a built in
|
||||
# restart which stops the firewall if running and then starts it.
|
||||
echo -n $"Restarting Shorewall: "
|
||||
$shorewall $OPTIONS restart 2>&1 | $logger
|
||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@
|
||||
#
|
||||
# IPTABLES - iptables
|
||||
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
|
||||
# MODULE_SUFFIX - "o gz ko o.gz ko.gz"
|
||||
# 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
|
||||
|
@@ -5,7 +5,8 @@
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv6 firewall (lite)
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=ip6tables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
@@ -13,7 +14,7 @@ Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall6-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall6-lite $OPTIONS start
|
||||
ExecStart=/sbin/shorewall6-lite $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall6-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
|
21
Shorewall6-lite/shorewall6-lite.service.214
Normal file
21
Shorewall6-lite/shorewall6-lite.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv6 firewall (lite)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=ip6tables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall6-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall6-lite $OPTIONS start
|
||||
ExecStop=/sbin/shorewall6-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -36,6 +36,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
|
@@ -175,7 +175,7 @@ MANGLE_ENABLED=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
|
@@ -175,7 +175,7 @@ MANGLE_ENABLED=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
|
@@ -175,7 +175,7 @@ MANGLE_ENABLED=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
|
@@ -175,7 +175,7 @@ MANGLE_ENABLED=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MUTEX_TIMEOUT=60
|
||||
|
||||
|
16
Shorewall6/configfiles/findgw
Normal file
16
Shorewall6/configfiles/findgw
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Shorewall version 4 - Findgw File
|
||||
#
|
||||
# /etc/shorewall6/findgw
|
||||
#
|
||||
# The code in this file is executed when Shorewall is trying to detect the
|
||||
# gateway through an interface in /etc/shorewall6/providers that has GATEWAY
|
||||
# specified as 'detect'.
|
||||
#
|
||||
# The function should echo the IP address of the gateway if it knows what
|
||||
# it is; the name of the interface is in $1.
|
||||
#
|
||||
# See http://shorewall.net/shorewall_extension_scripts.htm for additional
|
||||
# information.
|
||||
#
|
||||
###############################################################################
|
@@ -35,7 +35,13 @@ loadmodule nf_conntrack_sip
|
||||
loadmodule nf_conntrack_tftp
|
||||
loadmodule nf_conntrack_sane
|
||||
#
|
||||
# While not actually helpers, these are handy to have
|
||||
# While not actually helpers, these are included here so that
|
||||
# LOG_BACKEND can work correctly. Not all of them will be
|
||||
# loaded, since at least one of them will be an alias on any
|
||||
# given system.
|
||||
#
|
||||
loadmodule ip6t_LOG
|
||||
loadmodule nf_log_ipv6
|
||||
loadmodule xt_LOG
|
||||
loadmodule xt_NFLOG
|
||||
loadmodule nfnetlink_log
|
||||
|
@@ -39,7 +39,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting Shorewall: "
|
||||
$shorewall $OPTIONS start 2>&1 | $logger
|
||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
@@ -69,7 +69,7 @@ restart() {
|
||||
# Note that we don't simply stop and start since shorewall has a built in
|
||||
# restart which stops the firewall if running and then starts it.
|
||||
echo -n $"Restarting Shorewall: "
|
||||
$shorewall $OPTIONS restart 2>&1 | $logger
|
||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
|
@@ -10,8 +10,9 @@
|
||||
|
||||
OPTIONS=""
|
||||
|
||||
# Use /etc/default shorewall6 to specify $OPTIONS to run at startup, however this
|
||||
# this might prevent shorewall6 from starting. use at your own risk
|
||||
# Use /etc/default shorewall6 to specify $OPTIONS and STARTOPTIONS to
|
||||
# run at startup, however this this might prevent shorewall6 from
|
||||
# starting. use at your own risk
|
||||
if [ -f /etc/default/shorewall6 ] ; then
|
||||
. /etc/default/shorewall6
|
||||
fi
|
||||
@@ -19,7 +20,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo "Starting IPv6 shorewall rules..."
|
||||
exec /sbin/shorewall6 $OPTIONS start
|
||||
exec /sbin/shorewall6 $OPTIONS start $STARTOPTIONS
|
||||
}
|
||||
|
||||
stop() {
|
||||
@@ -29,7 +30,7 @@ stop() {
|
||||
|
||||
restart() {
|
||||
echo "Restarting IPv6 shorewall rules..."
|
||||
exec /sbin/shorewall6 restart
|
||||
exec /sbin/shorewall6 restart $RESTARTOPTIONS
|
||||
}
|
||||
|
||||
status() {
|
||||
|
@@ -90,7 +90,7 @@
|
||||
role="bold">NOTRACK</emphasis>|<emphasis
|
||||
role="bold">CT</emphasis>:<emphasis
|
||||
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis
|
||||
role="bold">CT:notrack</emphasis>|DROP|LOG|NFLOG(<replaceable>nflog-parameters</replaceable>)|IP6TABLES(<replaceable>target</replaceable>)}[:<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
|
||||
role="bold">CT:ctevents:<replaceable>event</replaceable>[,...]|CT:expevents:new|notrack</emphasis>|DROP|LOG|NFLOG(<replaceable>nflog-parameters</replaceable>)|IP6TABLES(<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
|
||||
@@ -238,12 +238,37 @@
|
||||
<listitem>
|
||||
<para><option>expevents</option><option>=new</option></para>
|
||||
|
||||
<para>Only generate a <emphasis role="bold">new</emphasis>
|
||||
<para>Only generate <emphasis role="bold">new</emphasis>
|
||||
expectation events for this connection.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>ctevents:<replaceable>event</replaceable>[,...]</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.10. Only generate the specified
|
||||
conntrack events for this connection. Possible event types are:
|
||||
<emphasis role="bold">new</emphasis>, <emphasis
|
||||
role="bold">related</emphasis>, <emphasis
|
||||
role="bold">destroy</emphasis>, <emphasis
|
||||
role="bold">reply</emphasis>, <emphasis
|
||||
role="bold">assured</emphasis>, <emphasis
|
||||
role="bold">protoinfo</emphasis>, <emphasis
|
||||
role="bold">helper</emphasis>, <emphasis
|
||||
role="bold">mark</emphasis> (this is connection mark, not packet
|
||||
mark), <emphasis role="bold">natseqinfo</emphasis>, and
|
||||
<emphasis role="bold">secmark</emphasis>.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>expevents=new</para>
|
||||
|
||||
<para>Added in Shorewall 4.6.10. Only generate <emphasis
|
||||
role="bold">new</emphasis> expectation events for this
|
||||
connection.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><option>DROP</option></para>
|
||||
|
||||
|
@@ -323,6 +323,17 @@ loc eth2 -</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>loopback</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.6. Designates the interface as
|
||||
the loopback interface. This option is assumed if the
|
||||
interface's physical name is 'lo'. Only one interface man have
|
||||
the <option>loopback</option> option specified.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">mss</emphasis>=<emphasis>number</emphasis></term>
|
||||
@@ -617,7 +628,7 @@ dmz eth2 -</programlisting>
|
||||
|
||||
<programlisting>FORMAT 2
|
||||
#ZONE INTERFACE OPTIONS
|
||||
- br0 routeback</programlisting>
|
||||
- br0 bridge</programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@@ -125,7 +125,29 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>CHECKSUM</term>
|
||||
<term><emphasis
|
||||
role="bold">ADD(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.7. Causes addresses and/or port
|
||||
numbers to be added to the named
|
||||
<replaceable>ipset</replaceable>. The
|
||||
<replaceable>flags</replaceable> specify the address or tuple
|
||||
to be added to the set and must match the type of ipset
|
||||
involved. For example, for an iphash ipset, either the SOURCE
|
||||
or DESTINATION address can be added using
|
||||
<replaceable>flags</replaceable> <emphasis
|
||||
role="bold">src</emphasis> or <emphasis
|
||||
role="bold">dst</emphasis> respectively (see the -A command in
|
||||
ipset (8)).</para>
|
||||
|
||||
<para>ADD is non-terminating. Even if a packet matches the
|
||||
rule, it is passed on to the next rule.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">CHECKSUM</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Compute and fill in the checksum in a packet that lacks
|
||||
@@ -140,7 +162,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>CLASSIFY(<replaceable>classid</replaceable>)</term>
|
||||
<term><emphasis
|
||||
role="bold">CLASSIFY(<replaceable>classid</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>A classification Id (classid) is of the form
|
||||
@@ -190,7 +213,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>CONMARK({mark|range})</term>
|
||||
<term><emphasis
|
||||
role="bold">CONMARK({mark|range})</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Identical to MARK with the exception that the mark is
|
||||
@@ -213,6 +237,27 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">DEL(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.7. Causes an entry to be deleted
|
||||
from the named <replaceable>ipset</replaceable>. The
|
||||
<replaceable>flags</replaceable> specify the address or tuple
|
||||
to be deleted from the set and must match the type of ipset
|
||||
involved. For example, for an iphash ipset, either the SOURCE
|
||||
or DESTINATION address can be deleted using
|
||||
<replaceable>flags</replaceable> <emphasis
|
||||
role="bold">src</emphasis> or <emphasis
|
||||
role="bold">dst</emphasis> respectively (see the -D command in
|
||||
ipset (8)).</para>
|
||||
|
||||
<para>DEL is non-terminating. Even if a packet matches the
|
||||
rule, it is passed on to the next rule.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">DIVERT</emphasis></term>
|
||||
|
||||
@@ -323,7 +368,7 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>IPMARK</term>
|
||||
<term><emphasis role="bold">IPMARK</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Assigns a mark to each matching packet based on the
|
||||
@@ -431,8 +476,9 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>IP6TABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</term>
|
||||
<term><emphasis
|
||||
role="bold">IP6TABLES({<replaceable>target</replaceable>
|
||||
[<replaceable>option</replaceable> ...])</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>This action allows you to specify an iptables target
|
||||
@@ -453,7 +499,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</term>
|
||||
<term><emphasis
|
||||
role="bold">MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>where <replaceable>mark</replaceable> is a packet mark
|
||||
@@ -496,7 +543,7 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">RESTORE</emphasis>[(/<emphasis>mask</emphasis>)]</term>
|
||||
role="bold">RESTORE</emphasis>[(<emphasis>mask</emphasis>)]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restore the packet's mark from the connection's mark
|
||||
@@ -506,7 +553,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">SAME</emphasis></term>
|
||||
<term><emphasis
|
||||
role="bold">SAME[(<replaceable>timeout</replaceable>)]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Some websites run applications that require multiple
|
||||
@@ -530,17 +578,22 @@ SAME:P 192.168.1.0/24 0.0.0.0/0 tcp 80,443</programlisting>
|
||||
connections to an individual remote system to all use the same
|
||||
provider. For example:<programlisting>#ACTION SOURCE DEST PROTO DEST
|
||||
# PORT(S)
|
||||
SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>
|
||||
If the firewall attempts a connection on TCP port 80 or 443
|
||||
and it has sent a packet on either of those ports in the last
|
||||
five minutes to the same remote system then the new connection
|
||||
will use the same provider as the connection over which that
|
||||
last packet was sent.</para>
|
||||
SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>The
|
||||
optional <replaceable>timeout</replaceable> parameter was
|
||||
added in Shorewall 4.6.7 and specifies a number of seconds .
|
||||
When not specified, a value of 300 seconds (5 minutes) is
|
||||
assumed. If the firewall attempts a connection on TCP port 80
|
||||
or 443 and it has sent a packet on either of those ports in
|
||||
the last <replaceable>timeout</replaceable> seconds to the
|
||||
same remote system then the new connection will use the same
|
||||
provider as the connection over which that last packet was
|
||||
sent.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">SAVE[(/<emphasis>mask)</emphasis>]
|
||||
<term><emphasis role="bold">SAVE[(<emphasis
|
||||
role="bold"><replaceable>mask</replaceable>)</emphasis>]
|
||||
</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user