Compare commits

..

70 Commits

Author SHA1 Message Date
Tom Eastep
a7be3dfece Align progress messages produced by 'reenable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:29:13 -07:00
Tom Eastep
846e8c4ece Correct reenable logic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:29:08 -07:00
Tom Eastep
1cde92e8f3 Initialize g_dockeringress
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 10:43:44 -07:00
Tom Eastep
be5aabcbfb Correct typo in Chains.pm
&g_dockeringress -> $g_dockeringress

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 10:14:22 -07:00
Tom Eastep
a8937e6bc8 Correct harmless typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 10:06:41 -07:00
Tom Eastep
e91bd9a0e9 Remove useless/empty .tmp file when SAVE_IPSETS is set
- Add SAVE_IPSETS support to the Redhat/Fedora sysv init script

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 09:28:43 -07:00
Tom Eastep
5e1cf17ebc DOCKER-INGRESS support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-17 10:57:29 -07:00
Tom Eastep
85a7ec6fe5 Correct module loading in the compiler
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-14 15:08:38 -07:00
Tom Eastep
fb831e3128 Remove empty/useless ipsets tmp file in Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 11:56:24 -07:00
Tom Eastep
2ed11c7e15 Default ADD_IP_ALIASES to 'No' in Shorewall6
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 11:55:53 -07:00
Tom Eastep
ef1353790e Correct VLSM editing in the 'ipcalc' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 10:53:41 -07:00
Tom Eastep
4f79d2e82b Move and simplify handling of nat columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 10:53:04 -07:00
Tom Eastep
e6a2ba78a4 Correct handling of DEST column during action invocation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 10:05:37 -07:00
Tom Eastep
41ea3bdeda Modify the Event actions to handle NAT rules
- Separate DNAT and REDIRECT into DNAT- and REDIRECT- plus ACCEPT

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 09:47:12 -07:00
Tom Eastep
1065c2951b Allow NAT targets to be passed to the Event actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 09:46:03 -07:00
Tom Eastep
3b373f3f21 Correct handling of ipsets in the DEST column of the snat file
- Also corrected handling of exclusion

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-06 11:30:42 -07:00
Tom Eastep
0c05ab3bff Correct typo in shorewall-snat(5)
- missing ':' in IPv4 Example 4.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-05 10:29:19 -07:00
Tom Eastep
ef3a33e3f4 Merge branch '5.1.6'
# Conflicts:
#	Shorewall-core/lib.common

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-30 15:02:23 -07:00
Tom Eastep
8a78fb6e77 Correct -p check for the conntrack utility's availability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-29 09:06:36 -07:00
Tom Eastep
b54a691110 Improve dynamic gateway detection
- Use provider's routing table, if any

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 15:04:47 -07:00
Tom Eastep
90f33dd436 Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 12:48:14 -07:00
Tom Eastep
b7aef24d7c Delete useless line of code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 12:18:29 -07:00
Tom Eastep
6f475cde3f Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 10:19:25 -07:00
Tom Eastep
6053a40af0 Apply Tuomo Soini's loadmodule patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 09:20:50 -07:00
Tom Eastep
7e4dba7623 Revert "Correct check for module already loaded"
This reverts commit 2e98d4375b.
2017-08-23 08:01:25 -07:00
Tom Eastep
3d322d31b7 Add UDP rule to macro.RDP
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-22 08:07:32 -07:00
Tom Eastep
34e4fffd7d Module suffix changes
- Re-order default list in the compiler to match lib.common
- MODULE_SUFFIX="ko ko.xz" in standard .conf files.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-21 12:44:23 -07:00
Tom Eastep
2e98d4375b Correct check for module already loaded
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-21 10:27:29 -07:00
Tom Eastep
419ff8903b Invert logic in Shorewall::Chains::delete_reference() - better readability
- similar change in Shorewall::Chains::adjust_reference_counts()

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 12:25:27 -07:00
Tom Eastep
390ac30be8 Remove a superfluous line of code from Shorewall::Chains::format_rule()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 12:12:54 -07:00
Tom Eastep
8cb98f16ea Add a comment in Shorewall::Chains::optimize_level8()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 08:08:24 -07:00
Tom Eastep
5a9f179e25 Allow port variables as the server port in DNAT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-16 15:36:18 -07:00
Tom Eastep
d8eca457de Correct typo in the Aliased Interfaces article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-16 08:24:44 -07:00
Tom Eastep
8641d53bd1 Use MUTEX_TIMEOUT for ip[6]tables --wait interval
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-15 14:02:08 -07:00
Tom Eastep
7e3521e221 RESTORE_WAIT_OPTION
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 18:56:40 -07:00
Tom Eastep
0603f8e355 Serialize start of IPv4 and IPv6 under systemd
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 12:48:18 -07:00
Tom Eastep
ddefde2d10 Correct handling of address variables in DNAT rule.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 08:30:11 -07:00
Tom Eastep
2beeedd8fe Remove incorrect '+' info from shorewall-interfaces(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 12:19:00 -07:00
Tom Eastep
1a2647618e Allow runtime address variables as the server IP in DNAT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 12:18:16 -07:00
Tom Eastep
72293883dd Tabify the Zones module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 11:28:14 -07:00
Tom Eastep
c31397532c Verify that parent and child zones have a common interface
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 09:24:05 -07:00
Tom Eastep
d0861e813b Make Shorewall's handling of '+' consistent with that of iptables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 08:22:57 -07:00
Tom Eastep
5d5bef105a Remove reference to swping from the shorewall-init article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-11 13:38:58 -07:00
Tom Eastep
da62bd2b32 Use a hash slice in recently-added code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-11 13:38:34 -07:00
Tom Eastep
a83c19cc33 Adjust some default values in shorewall.conf(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-10 15:48:16 -07:00
Tom Eastep
96a33395e8 Correct typo in the Squid document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-09 15:42:19 -07:00
Tom Eastep
dabe8abe52 Add 'action' to the conntrack columns for alternate input
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-09 12:41:45 -07:00
Tom Eastep
a504820d19 Correct optimize level 8 handling of policy and policychain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-07 16:56:30 -07:00
Matt Darfeuille
8db4265ccc docs: Clarify path for locating Shorewall files
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-07 13:48:47 -07:00
Tom Eastep
4c2c1bcdf1 Export CONFDIR and SHAREDIR to the generated script.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-06 13:42:01 -07:00
Tom Eastep
f2ee8013fc Update the providers manpage re balanced IPv6 routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-05 10:12:42 -07:00
Tom Eastep
56c8f70b52 Describe the parameters passed to the enable and disable extension scripts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-04 12:38:14 -07:00
Tom Eastep
657215f9b5 Add sample enabled and disabled scripts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-03 12:50:49 -07:00
Tom Eastep
5589ab76d9 Add arguments to the enabled and disabled user exits
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-03 12:44:15 -07:00
Tom Eastep
ec0e6763e4 add 'enabled' and 'disabled' to the Extension Script Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-02 15:44:48 -07:00
Tom Eastep
6425e5ae5d Remove superfluous white space in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-02 14:09:05 -07:00
Tom Eastep
8521c6f750 Merge branch '5.1.5' 2017-08-02 14:02:03 -07:00
Tom Eastep
c57edb0fbf Update FAQ2* to use address variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-01 14:56:20 -07:00
Tom Eastep
80e6cd8a2f Add enabled and disabled user exits
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-29 15:15:57 -07:00
Tom Eastep
5a24953e6c Merge branch '5.1.5' 2017-07-27 09:14:50 -07:00
Tom Eastep
e573436b12 Correct tcfilter source port handling when BASIC_FILTERS=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-23 12:14:57 -07:00
Tom Eastep
7f44473387 Correct some typos in the Install article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-23 10:44:46 -07:00
Tom Eastep
975a14b94f Allow configure.pl to recognize $SOURCE_DATE_EPOCH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 14:48:40 -07:00
Tom Eastep
cf3c304078 Apply Bernhard M. Wiedemann's patch for configure...
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 14:19:39 -07:00
Tom Eastep
d1a21fb678 Revert "Add SHARED_CONFIG option to shorewallrc"
This reverts commit 4e978b687d.
2017-07-20 12:23:59 -07:00
Tom Eastep
b9b7baf98d Merge branch '5.1.5' 2017-07-20 10:37:53 -07:00
Tom Eastep
92e725de97 Remove link to non-existent blog
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-16 09:23:02 -07:00
Tom Eastep
922bd9eeca Implement SPARSE=Very
- Only installs the .conf file.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-09 16:18:09 -07:00
Tom Eastep
d2b3fa476a Correct VLSM (56->60) in the Shared Config Document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-09 16:17:16 -07:00
Tom Eastep
4e978b687d Add SHARED_CONFIG option to shorewallrc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-07 08:25:33 -07:00
58 changed files with 719 additions and 377 deletions

View File

@@ -25,7 +25,7 @@
# loaded after this one and replaces some of the functions declared here.
#
SHOREWALL_CAPVERSION=50105
SHOREWALL_CAPVERSION=50106
if [ -z "$g_basedir" ]; then
#
@@ -2804,6 +2804,7 @@ determine_capabilities() {
CPU_FANOUT=
NETMAP_TARGET=
NFLOG_SIZE=
RESTORE_WAIT_OPTION=
AMANDA_HELPER=
FTP_HELPER=
@@ -2827,9 +2828,11 @@ determine_capabilities() {
qt $arptables -L OUT && ARPTABLESJF=Yes
fi
[ -z "$(${g_tool}-restore --wait < /dev/null 2>&1)" ] && RESTORE_WAIT_OPTION=Yes
if qt $g_tool --wait -t filter -L INPUT -n -v; then
WAIT_OPTION=Yes
tool="$tool --wait"
g_tool="$g_tool --wait"
fi
chain=fooX$$
@@ -3299,9 +3302,11 @@ report_capabilities_unsorted() {
if [ $g_family -eq 4 ]; then
report_capability "iptables -S (IPTABLES_S)" $IPTABLES_S
report_capability "iptables --wait option (WAIT_OPTION)" $WAIT_OPTION
report_capability "iptables-restore --wait option (RESTORE_WAIT_OPTION)" $RESTORE_WAIT_OPTION
else
report_capability "ip6tables -S (IPTABLES_S)" $IPTABLES_S
report_capability "ip6tables --wait option (WAIT_OPTION)" $WAIT_OPTION
report_capability "ip6tables-restore --wait option (RESTORE_WAIT_OPTION)" $RESTORE_WAIT_OPTION
fi
report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER
@@ -3417,6 +3422,7 @@ report_capabilities_unsorted1() {
report_capability1 CPU_FANOUT
report_capability1 NETMAP_TARGET
report_capability1 NFLOG_SIZE
report_capability1 RESTORE_WAIT_OPTION
report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER
@@ -3721,7 +3727,7 @@ ipcalc_command() {
valid_address $address || fatal_error "Invalid IP address: $address"
[ -z "$vlsm" ] && fatal_error "Missing VLSM"
[ "x$address" = "x$vlsm" ] && "Invalid VLSM"
[ "x$address" = "x$vlsm" ] && fatal_error "Invalid VLSM"
[ $vlsm -gt 32 ] && fatal_error "Invalid VLSM: /$vlsm"
address=$address/$vlsm

View File

@@ -269,53 +269,48 @@ loadmodule() # $1 = module name, $2 - * arguments
{
local modulename
modulename=$1
shift
local moduleoptions
moduleoptions=$*
local modulefile
local suffix
if [ -d /sys/module/ ]; then
if ! list_search $modulename $DONT_LOAD; then
if [ ! -d /sys/module/$modulename ]; then
shift
for suffix in $MODULE_SUFFIX ; do
for directory in $moduledirectories; do
modulefile=$directory/${modulename}.${suffix}
if [ -f $modulefile ]; then
case $moduleloader in
insmod)
insmod $modulefile $*
;;
*)
modprobe $modulename $*
;;
esac
break 2
for directory in $moduledirectories; do
for modulefile in $directory/${modulename}.*; do
if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
return
fi
done
done
;;
*)
modprobe -q $modulename $moduleoptions
;;
esac
fi
fi
elif ! list_search $modulename $DONT_LOAD $MODULES; then
shift
for suffix in $MODULE_SUFFIX ; do
for directory in $moduledirectories; do
modulefile=$directory/${modulename}.${suffix}
if [ -f $modulefile ]; then
case $moduleloader in
insmod)
insmod $modulefile $*
;;
*)
modprobe $modulename $*
;;
esac
break 2
for directory in $moduledirectories; do
for modulefile in $directory/${modulename}.*; do
if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
return
fi
done
done
;;
*)
modprobe -q $modulename $moduleoptions
;;
esac
fi
}
@@ -338,8 +333,6 @@ reload_kernel_modules() {
moduleloader=insmod
fi
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in
+*)
@@ -394,8 +387,6 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
moduleloader=insmod
fi
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in
+*)

View File

@@ -159,8 +159,9 @@ shorewall_stop () {
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
echo_notdone
fi

View File

@@ -66,6 +66,10 @@ start () {
printf "Initializing \"Shorewall-based firewalls\": "
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
for PRODUCT in $PRODUCTS; do
setstatedir
retval=$?
@@ -120,6 +124,15 @@ stop () {
done
if [ $retval -eq 0 ]; then
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
rm -f $lockfile
success
else

View File

@@ -126,7 +126,9 @@ stop () {
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
}

View File

@@ -116,7 +116,9 @@ shorewall_stop () {
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi

View File

@@ -126,7 +126,9 @@ shorewall_stop () {
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
}

View File

@@ -104,7 +104,9 @@ shorewall_stop () {
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi

View File

@@ -28,7 +28,7 @@
#
# On the target system (the system where the firewall program is to run):
#
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
#
# Now move the capabilities file to the compilation system. The file must
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
@@ -38,7 +38,6 @@
#
# IPTABLES - iptables
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
#
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
# used during firewall compilation, then the generated firewall program will likewise not

View File

@@ -107,6 +107,11 @@ if ( $command & $REAP_OPT ) {
$duration .= '--rttl ' if $command & $TTL_OPT;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "-m recent --rcheck ${duration}--hitcount $hitcount" );
$action = 'ACCEPT';
}
if ( $command & $RESET_CMD ) {
require_capability 'MARK_ANYWHERE', '"reset"', 's';

View File

@@ -41,6 +41,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "" );
$action = 'ACCEPT';
}
if ( $destination eq 'dst' ) {
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rdest" );
} else {

View File

@@ -37,6 +37,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "" );
$action = 'ACCEPT';
}
if ( $destination eq 'dst' ) {
perl_action_helper( $action, '', '', "-m recent --name $event --set --rdest" );
} else {

View File

@@ -6,4 +6,5 @@
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - udp 3389
PARAM - - tcp 3389

View File

@@ -1345,8 +1345,6 @@ sub format_rule( $$;$ ) {
} else {
$rule .= join( '' , ' --', $_, ' ', $value );
}
next;
} elsif ( $type == EXPENSIVE ) {
#
# Only emit expensive matches now if there are '-m nfacct' or '-m recent' matches in the rule
@@ -1929,7 +1927,7 @@ sub delete_reference( $$ ) {
assert( $toref );
delete $toref->{references}{$fromref->{name}} unless --$toref->{references}{$fromref->{name}} > 0;
delete $toref->{references}{$fromref->{name}} if --$toref->{references}{$fromref->{name}} <= 0;
}
#
@@ -2067,7 +2065,7 @@ sub adjust_reference_counts( $$$ ) {
my ($toref, $name1, $name2) = @_;
if ( $toref ) {
delete $toref->{references}{$name1} unless --$toref->{references}{$name1} > 0;
delete $toref->{references}{$name1} if --$toref->{references}{$name1} <= 0;
$toref->{references}{$name2}++;
}
}
@@ -3275,8 +3273,10 @@ sub initialize_chain_table($) {
$chainref = new_nat_chain( 'DOCKER' );
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
add_commands( $chainref, '[ -f ${VARDIR}/.nat_DOCKER ] && cat ${VARDIR}/.nat_DOCKER >&3' );
$chainref = new_standard_chain( 'DOCKER-INGRESS' );
$chainref = new_standard_chain( 'DOCKER-ISOLATION' );
set_optflags( $chainref, DONT_OPTIMIZE | DONT_DELETE | DONT_MOVE );
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-INGRESS ] && cat ${VARDIR}/.filter_DOCKER-INGRESS >&3' );
add_commands( $chainref, '[ -f ${VARDIR}/.filter_DOCKER-ISOLATION ] && cat ${VARDIR}/.filter_DOCKER-ISOLATION >&3' );
}
@@ -3900,6 +3900,15 @@ sub optimize_level8( $$$ ) {
}
$combined{ $chainref1->{name} } = $chainref->{name};
#
# While rare, it is possible for a policy chain to be combined with a non-policy chain. So we need to preserve
# the policy attributes in the combined chain
#
if ( $chainref->{policychain} ) {
@{$chainref1}{qw(policychain policy)} = @{$chainref}{qw(policychain policy)} unless $chainref1->{policychain};
} elsif ( $chainref1->{policychain} ) {
@{$chainref}{qw(policychain policy)} = @{$chainref1}{qw(policychain policy)} unless $chainref->{policychain};
}
}
}
}
@@ -4826,7 +4835,7 @@ sub do_proto( $$$;$ )
$multiport = 1;
} else {
fatal_error "Missing DEST PORT" unless supplied $ports;
$ports = validate_portpair $pname , $ports;
$ports = validate_portpair $pname , $ports unless $ports =~ /^\$/;
$output .= ( $srcndst ? "-m multiport ${invert}--ports ${ports} " : "${invert}--dport ${ports} " );
}
}
@@ -5033,7 +5042,7 @@ sub do_iproto( $$$ )
$multiport = 1;
} else {
fatal_error "Missing DEST PORT" unless supplied $ports;
$ports = validate_portpair $pname , $ports;
$ports = validate_portpair $pname , $ports unless $ports =~ /^\$/;
if ( $srcndst ) {
push @output, multiport => "${invert}--ports ${ports}";
@@ -6318,7 +6327,7 @@ sub match_dest_net( $;$ ) {
return '-d ' . record_runtime_address $1, $2;
}
$net = validate_net $net, 1;
$net = validate_net $net, 1 unless $net =~ /^\$/; # Don't validate if runtime address variable
$net eq ALLIP ? '' : "-d $net ";
}
@@ -6399,7 +6408,7 @@ sub imatch_dest_net( $;$ ) {
return ( d => record_runtime_address( $1, $2, 1 ) );
}
$net = validate_net $net, 1;
$net = validate_net $net, 1 unless $net =~ /^\$/; # Don't validate if runtime address variable
$net eq ALLIP ? () : ( d => $net );
}
@@ -7058,6 +7067,8 @@ sub interface_gateway( $ ) {
sub get_interface_gateway ( $;$$ ) {
my ( $logical, $protect, $provider ) = @_;
$provider = '' unless defined $provider;
my $interface = get_physical $logical;
my $variable = interface_gateway( $interface );
my $gateway = get_interface_option( $interface, 'gateway' );
@@ -7071,9 +7082,9 @@ sub get_interface_gateway ( $;$$ ) {
}
if ( interface_is_optional $logical ) {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface));
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider));
} else {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface)
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider)
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
}
@@ -7522,6 +7533,11 @@ sub isolate_dest_interface( $$$$ ) {
$rule .= "-d $variable ";
}
} elsif ( $dest =~ /^\$/ ) {
#
# Runtime address variable
#
$dnets = $dest;
} elsif ( $family == F_IPV4 ) {
if ( $dest =~ /^(.+?):(.+)$/ ) {
$diface = $1;
@@ -8445,6 +8461,7 @@ sub save_docker_rules($) {
qq( $tool -t nat -S OUTPUT | tail -n +2 | fgrep DOCKER > \${VARDIR}/.nat_OUTPUT),
qq( $tool -t nat -S POSTROUTING | tail -n +2 | fgrep -v SHOREWALL > \${VARDIR}/.nat_POSTROUTING),
qq( $tool -t filter -S DOCKER | tail -n +2 > \${VARDIR}/.filter_DOCKER),
qq( [ -n "\$g_dockeringress" ] && $tool -t filter -S DOCKER-INGRESS | tail -n +2 > \${VARDIR}/.filter_DOCKER-INGRESS),
qq( [ -n "\$g_dockernetwork" ] && $tool -t filter -S DOCKER-ISOLATION | tail -n +2 > \${VARDIR}/.filter_DOCKER-ISOLATION)
);
@@ -8460,6 +8477,7 @@ sub save_docker_rules($) {
q( rm -f ${VARDIR}/.nat_OUTPUT),
q( rm -f ${VARDIR}/.nat_POSTROUTING),
q( rm -f ${VARDIR}/.filter_DOCKER),
q( rm -f ${VARDIR}/.filter_DOCKER-INGRESS),
q( rm -f ${VARDIR}/.filter_DOCKER-ISOLATION),
q( rm -f ${VARDIR}/.filter_FORWARD),
q(fi)
@@ -8902,9 +8920,15 @@ sub create_netfilter_load( $ ) {
my $UTILITY = $family == F_IPV4 ? 'IPTABLES_RESTORE' : 'IP6TABLES_RESTORE';
emit( '',
'if [ "$COMMAND" = reload -a -n "$g_counters" ] && chain_exists $g_sha1sum1 && chain_exists $g_sha1sum2 ; then',
' option="--counters"',
'',
'if [ "$COMMAND" = reload -a -n "$g_counters" ] && chain_exists $g_sha1sum1 && chain_exists $g_sha1sum2 ; then' );
if ( have_capability( 'RESTORE_WAIT_OPTION' ) ) {
emit( ' option="--counters --wait "' . $config{MUTEX_TIMEOUT} );
} else {
emit( ' option="--counters"' );
}
emit( '',
' progress_message "Reusing existing ruleset..."',
'',
'else'
@@ -8912,7 +8936,11 @@ sub create_netfilter_load( $ ) {
push_indent;
if ( have_capability( 'RESTORE_WAIT_OPTION' ) ) {
emit 'option="--wait "' . $config{MUTEX_TIMEOUT};
} else {
emit 'option=';
}
save_progress_message "Preparing $utility input...";
@@ -8961,6 +8989,10 @@ sub create_netfilter_load( $ ) {
enter_cmd_mode;
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode;
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
enter_cat_mode;
} else {
emit_unindented ":$name - [0:0]";
}
@@ -9065,6 +9097,11 @@ sub preview_netfilter_load() {
print( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
print "\n";
enter_cat_mode1;
} elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode1 unless $mode == CMD_MODE;
print( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
print "\n";
enter_cat_mode1;
} else {
enter_cmd_mode1 unless $mode == CMD_MODE;
print( ":$name - [0:0]\n" );
@@ -9302,6 +9339,10 @@ sub create_stop_load( $ ) {
enter_cmd_mode;
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode;
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
enter_cat_mode;
} else {
emit_unindented ":$name - [0:0]";
}
@@ -9327,7 +9368,11 @@ sub create_stop_load( $ ) {
enter_cmd_mode;
if ( have_capability( 'RESTORE_WAIT_OPTION' ) ) {
emit( '[ -n "$g_debug_iptables" ] && command=debug_restore_input || command="$' . $UTILITY . ' --wait ' . $config{MUTEX_TIMEOUT} . '"' );
} else {
emit( '[ -n "$g_debug_iptables" ] && command=debug_restore_input || command=$' . $UTILITY );
}
emit( '',
'progress_message2 "Running $command..."',

View File

@@ -109,7 +109,7 @@ sub generate_script_1( $ ) {
################################################################################
EOF
for my $exit ( qw/init start tcclear started stop stopped clear refresh refreshed restored/ ) {
for my $exit ( qw/init start tcclear started stop stopped clear refresh refreshed restored enabled disabled/ ) {
emit "\nrun_${exit}_exit() {";
push_indent;
append_file $exit or emit 'true';
@@ -209,6 +209,8 @@ sub generate_script_2() {
emit ( '[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir' );
emit ( qq([ -n "\${VARDIR:=$shorewallrc1{VARDIR}}" ]) );
emit ( qq([ -n "\${VARLIB:=$shorewallrc1{VARLIB}}" ]) );
emit ( qq([ -n "\${CONFDIR:=$shorewallrc1{CONFDIR}}" ]) );
emit ( qq([ -n "\${SHAREDIR:=$shorewallrc1{SHAREDIR}}" ]) );
emit 'TEMPFILE=';
@@ -266,7 +268,8 @@ sub generate_script_2() {
emit( '',
'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes',
);
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes]' );
emit( 'chain_exists DOCKER-INGRESS && g_dockeringress=Yes' );
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes' );
emit( '' );
}

View File

@@ -36,6 +36,7 @@ use strict;
use warnings;
use File::Basename;
use File::Temp qw/ tempfile tempdir /;
use File::Glob ':globally';
use Cwd qw(abs_path getcwd);
use autouse 'Carp' => qw(longmess confess);
use Scalar::Util 'reftype';
@@ -315,7 +316,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
#
# Config options and global settings that are to be copied to output script
#
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
#
# From parsing the capabilities file or detecting capabilities
#
@@ -414,7 +415,8 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
CPU_FANOUT => 'NFQUEUE CPU Fanout',
NETMAP_TARGET => 'NETMAP Target',
NFLOG_SIZE => '--nflog-size support',
RESTORE_WAIT_OPTION
=> 'iptables-restore --wait option',
AMANDA_HELPER => 'Amanda Helper',
FTP_HELPER => 'FTP Helper',
FTP0_HELPER => 'FTP-0 Helper',
@@ -647,6 +649,7 @@ our %eliminated = ( LOGRATE => 1,
HIGH_ROUTE_MARKS => 1,
BLACKLISTNEWONLY => 1,
CHAIN_SCRIPTS => 1,
MODULE_SUFFIX => 1,
);
#
# Variables involved in ?IF, ?ELSE ?ENDIF processing
@@ -752,7 +755,7 @@ sub initialize( $;$$) {
EXPORT => 0,
KLUDGEFREE => '',
VERSION => "5.1.5-RC1",
CAPVERSION => 50105 ,
CAPVERSION => 50106 ,
BLACKLIST_LOG_TAG => '',
RELATED_LOG_TAG => '',
MACLIST_LOG_TAG => '',
@@ -847,7 +850,6 @@ sub initialize( $;$$) {
BLACKLIST => undef,
BLACKLISTNEWONLY => undef,
DELAYBLACKLISTLOAD => undef,
MODULE_SUFFIX => undef,
DISABLE_IPV6 => undef,
DYNAMIC_ZONES => undef,
PKTTYPE=> undef,
@@ -1046,6 +1048,7 @@ sub initialize( $;$$) {
CPU_FANOUT => undef,
NETMAP_TARGET => undef,
NFLOG_SIZE => undef,
RESTORE_WAIT_OPTION => undef,
AMANDA_HELPER => undef,
FTP_HELPER => undef,
@@ -4285,7 +4288,7 @@ sub which( $ ) {
# Load the kernel modules defined in the 'modules' file.
#
sub load_kernel_modules( ) {
my $moduleloader = which( 'modprobe' ) || ( which 'insmod' );
my $moduleloader = which( 'modprobe' ) || which( 'insmod' );
my $modulesdir = $config{MODULESDIR};
@@ -4318,25 +4321,20 @@ sub load_kernel_modules( ) {
close LSMOD;
$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};
MODULE:
while ( read_a_line( NORMAL_READ ) ) {
fatal_error "Invalid modules file entry" unless ( $currentline =~ /^loadmodule\s+([a-zA-Z]\w*)\s*(.*)$/ );
my ( $module, $arguments ) = ( $1, $2 );
unless ( $loadedmodules{ $module } ) {
for my $directory ( @moduledirectories ) {
for my $suffix ( @suffixes ) {
my $modulefile = "$directory/$module.$suffix";
if ( -f $modulefile ) {
if ( $moduleloader eq 'insmod' ) {
system ("insmod $modulefile $arguments" );
} else {
system( "modprobe $module $arguments" );
}
if ( $moduleloader =~ /modprobe$/ ) {
system( "modprobe -q $module $arguments" );
$loadedmodules{ $module } = 1;
} else {
for my $directory ( @moduledirectories ) {
for my $modulefile ( <$directory/$module.*> ) {
system ("insmod $modulefile $arguments" );
$loadedmodules{ $module } = 1;
next MODULE;
}
}
}
@@ -4948,6 +4946,10 @@ sub Cpu_Fanout() {
have_capability( 'NFQUEUE_TARGET' ) && qt1( "$iptables -A $sillyname -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout" );
}
sub Restore_Wait_Option() {
length( `${iptables}-restore --wait < /dev/null 2>&1` ) == 0;
}
our %detect_capability =
( ACCOUNT_TARGET =>\&Account_Target,
AMANDA_HELPER => \&Amanda_Helper,
@@ -5028,6 +5030,7 @@ our %detect_capability =
REALM_MATCH => \&Realm_Match,
REAP_OPTION => \&Reap_Option,
RECENT_MATCH => \&Recent_Match,
RESTORE_WAIT_OPTION => \&Restore_Wait_Option,
RPFILTER_MATCH => \&RPFilter_Match,
SANE_HELPER => \&SANE_Helper,
SANE0_HELPER => \&SANE0_Helper,
@@ -5195,6 +5198,8 @@ sub determine_capabilities() {
$capabilities{CPU_FANOUT} = detect_capability( 'CPU_FANOUT' );
$capabilities{NETMAP_TARGET} = detect_capability( 'NETMAP_TARGET' );
$capabilities{NFLOG_SIZE} = detect_capability( 'NFLOG_SIZE' );
$capabilities{RESTORE_WAIT_OPTION}
= detect_capability( 'RESTORE_WAIT_OPTION' );
unless ( have_capability 'CT_TARGET' ) {
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
@@ -6061,7 +6066,6 @@ sub get_configuration( $$$$ ) {
#
# get_capabilities requires that the true settings of these options be established
#
default 'MODULE_PREFIX', 'ko ko.gz o o.gz gz';
default_yes_no 'LOAD_HELPERS_ONLY' , 'Yes';
if ( ! $export && $> == 0 ) {
@@ -6247,7 +6251,7 @@ sub get_configuration( $$$$ ) {
$config{LOG_VERBOSITY} = -1;
}
default_yes_no 'ADD_IP_ALIASES' , 'Yes';
default_yes_no 'ADD_IP_ALIASES' , $family == F_IPV4 ? 'Yes' : '';
default_yes_no 'ADD_SNAT_ALIASES' , '';
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
@@ -6833,6 +6837,12 @@ sub get_configuration( $$$$ ) {
}
}
if ( supplied( $val = $config{MUTEX_TIMEOUT} ) ) {
fatal_error "Invalid value ($val) for MUTEX_TIMEOUT" unless $val && $val =~ /^\d+$/;
} else {
$config{MUTEX_TIMEOUT} = 60;
}
add_variables %config;
while ( my ($var, $val ) = each %renamed ) {

View File

@@ -667,6 +667,7 @@ sub create_docker_rules() {
my $chainref = $filter_table->{FORWARD};
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', );
if ( my $dockerref = known_interface('docker0') ) {

View File

@@ -941,7 +941,17 @@ sub handle_nat_rule( $$$$$$$$$$$$$ ) {
} else {
$server = $1 if $family == F_IPV6 && $server =~ /^\[(.+)\]$/;
fatal_error "Invalid server IP address ($server)" if $server eq ALLIP || $server eq NILIP;
my @servers = validate_address $server, 1;
my @servers;
if ( ( $server =~ /^([&%])(.+)/ ) ) {
$server = record_runtime_address( $1, $2 );
$server =~ s/ $//;
@servers = ( $server );
} else {
@servers = validate_address $server, 1;
}
$server = join ',', @servers;
}

View File

@@ -502,7 +502,7 @@ sub process_a_provider( $ ) {
if ( ( $gw = lc $gateway ) eq 'detect' ) {
fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared;
$gateway = get_interface_gateway( $interface, undef, 1 );
$gateway = get_interface_gateway( $interface, undef, $number );
$gatewaycase = 'detect';
set_interface_option( $interface, 'gateway', 'detect' );
} elsif ( $gw eq 'none' ) {
@@ -1088,7 +1088,10 @@ CEOF
emit( "setup_${dev}_tc" ) if $tcdevices->{$interface};
}
emit( qq(rm -f \${VARDIR}/${physical}_disabled) );
emit( qq(rm -f \${VARDIR}/${physical}_disabled),
$pseudo ? "run_enabled_exit ${physical} ${interface}" : "run_enabled_exit ${physical} ${interface} ${table}"
);
emit_started_message( '', 2, $pseudo, $table, $number );
if ( get_interface_option( $interface, 'used_address_variable' ) || get_interface_option( $interface, 'used_gateway_variable' ) ) {
@@ -1233,12 +1236,14 @@ CEOF
"qt \$TC qdisc del dev $physical ingress\n" ) if $tcdevices->{$interface};
}
emit( "echo 1 > \${VARDIR}/${physical}.status" );
emit( "echo 1 > \${VARDIR}/${physical}.status",
$pseudo ? "run_disabled_exit ${physical} ${interface}" : "run_disabled_exit ${physical} ${interface} ${table}"
);
if ( $pseudo ) {
emit( "progress_message2 \" Optional Interface $table stopped\"" );
emit( "progress_message2 \"Optional Interface $table stopped\"" );
} else {
emit( "progress_message2 \" Provider $table ($number) stopped\"" );
emit( "progress_message2 \"Provider $table ($number) stopped\"" );
}
pop_indent;

View File

@@ -216,6 +216,10 @@ our %statetable;
# Tracks which of the state match actions (action.Invalid, etc.) that is currently being expanded
#
our $statematch;
#
# Remembers NAT-oriented columns from top-level action invocations
#
our %nat_columns;
#
# Action/Inline options
@@ -384,6 +388,8 @@ sub initialize( $ ) {
);
}
%nat_columns = ( dest => '-', proto => '-', ports => '-' );
############################################################################
# Initialize variables moved from the Tc module in Shorewall 5.0.7 #
############################################################################
@@ -1652,6 +1658,19 @@ sub merge_inline_source_dest( $$ ) {
$body || '';
}
#
# This one is used by perl_action_helper()
#
sub merge_action_column( $$ ) {
my ( $body, $invocation ) = @_;
if ( supplied( $body ) && $body ne '-' ) {
$body;
} else {
$invocation;
}
}
sub merge_macro_column( $$ ) {
my ( $body, $invocation ) = @_;
@@ -2510,6 +2529,8 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
my $exceptionrule = '';
my $usergenerated;
my $prerule = '';
my %save_nat_columns = %nat_columns;
my $generated = 0;
#
# Subroutine for handling MARK and CONNMARK.
#
@@ -2591,7 +2612,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$current_param = $param unless $param eq '' || $param eq 'PARAM';
my $generated = process_macro( $basictarget,
$generated = process_macro( $basictarget,
$chainref,
$rule . $raw_matches,
$matches1,
@@ -2614,9 +2635,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$wildcard );
$macro_nest_level--;
return $generated;
goto EXIT;
} elsif ( $actiontype & NFQ ) {
$action = handle_nfqueue( $param,
1 # Allow 'bypass'
@@ -2688,6 +2707,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
REDIRECT => sub () {
my $z = $actiontype & NATONLY ? '' : firewall_zone;
if ( $dest eq '-' ) {
if ( $family == F_IPV4 ) {
$dest = ( $inchain ) ? '' : join( '', $z, '::' , $ports =~ /[:,]/ ? '' : $ports );
@@ -2816,6 +2836,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
}
}
}
#
# Isolate and validate source and destination zones
#
@@ -2909,7 +2930,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
#
if ( $destref->{type} & BPORT ) {
unless ( $sourceref->{bridge} eq $destref->{bridge} || single_interface( $sourcezone ) eq $destref->{bridge} ) {
return 0 if $wildcard;
goto EXIT if $wildcard;
fatal_error "Rules with a DESTINATION Bridge Port zone must have a SOURCE zone on the same bridge";
}
}
@@ -2924,7 +2945,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
my $policy = $chainref->{policy};
if ( $policy eq 'NONE' ) {
return 0 if $wildcard;
goto EXIT if $wildcard;
fatal_error "Rules may not override a NONE policy";
}
#
@@ -2933,9 +2954,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
if ( $optimize == 1 && $section == NEW_SECTION ) {
my $loglevel = $filter_table->{$chainref->{policychain}}{loglevel};
if ( $loglevel ne '' ) {
return 0 if $target eq "${policy}:${loglevel}";
goto EXIT if $target eq "${policy}:${loglevel}";
} else {
return 0 if $basictarget eq $policy;
goto EXIT if $basictarget eq $policy;
}
}
#
@@ -2980,6 +3001,21 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
my $actionchain; # Name of the action chain
if ( $actiontype & ACTION ) {
#
# Save NAT-oriented column contents
#
@nat_columns{'dest', 'proto', 'ports' } = ( $dest,
$proto eq '-' ? $nat_columns{proto} : $proto,
$ports eq '-' ? $nat_columns{ports} : $ports );
#
# Push the current column array onto the column stack
#
my @savecolumns = @columns;
#
# And store the (modified) columns into the columns array for use by perl_action[_tcp]_helper. We
# only need the NAT-oriented columns
#
@columns = ( undef , undef, $dest, $proto, $ports);
#
# Handle 'section' option
#
@@ -3023,6 +3059,8 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
}
$action = $basictarget; # Remove params, if any, from $action.
@columns = @savecolumns;
} elsif ( $actiontype & INLINE ) {
#
# process_inline() will call process_rule() recursively for each rule in the action body
@@ -3039,7 +3077,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$actionresult = 0;
my $generated = process_inline( $basictarget,
$generated = process_inline( $basictarget,
$chainref,
$prerule . $rule,
$matches1 . $raw_matches,
@@ -3066,7 +3104,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$macro_nest_level--;
return $generated;
goto EXIT;
}
#
# Generate Fixed part of the rule
@@ -3252,7 +3290,14 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref );
}
return 1;
$generated = 1;
EXIT:
{
%nat_columns = %save_nat_columns;
}
return $generated;
}
@@ -3405,6 +3450,37 @@ sub perl_action_helper($$;$$) {
merge_target( $ref, $target ),
'', # CurrentParam
@columns );
} else {
if ( ( $targets{$target} || 0 ) & NATRULE ) {
$result = process_rule( $chainref,
$matches,
$matches1,
merge_target( $actions{$action}, $target ),
'', # Current Param
'-', # Source
merge_action_column( # Dest
$columns[2],
$nat_columns{dest}
),
merge_action_column( #Proto
$columns[3],
$nat_columns{proto}
),
merge_action_column( #Ports
$columns[4],
$nat_columns{ports}),
'-', # Source Port(s)
'-', # Original Dest
'-', # Rate Limit
'-', # User
'-', # Mark
'-', # Connlimit
'-', # Time
'-', # Headers,
'-', # condition,
'-', # helper,
0, # Wildcard
);
} else {
$result = process_rule( $chainref,
$matches,
@@ -3427,6 +3503,8 @@ sub perl_action_helper($$;$$) {
'-', # helper,
0, # Wildcard
);
}
allow_optimize( $chainref );
}
#
@@ -3493,6 +3571,7 @@ sub perl_action_tcp_helper($$) {
'-', # helper,
0, # Wildcard
);
allow_optimize( $chainref );
}
#
@@ -5286,7 +5365,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
$interfaces = $1;
} elsif ( $dest =~ /^([^:]+):([^:]*)$/ ) {
my ( $one, $two ) = ( $1, $2 );
if ( $2 =~ /\./ || $2 =~ /^%/ ) {
if ( $2 =~ /\./ || $2 =~ /^[+%!]/ ) {
$interfaces = $one;
$destnets = $two;
} else {

View File

@@ -701,6 +701,40 @@ sub haveipseczones() {
0;
}
#
# Returns 1 if the two interfaces passed are related
#
sub interface_match( $$ ) {
my ( $piface, $ciface ) = @_;
return 1 if $piface eq $ciface;
my ( $pifaceref, $cifaceref ) = @interfaces{$piface, $ciface};
return 1 if $piface eq $cifaceref->{bridge};
return 1 if $ciface eq $pifaceref->{bridge};
if ( $minroot ) {
if ( $piface =~ /\+$/ ) {
my $root = $pifaceref->{root};
my $rlength = length( $root );
while ( length( $ciface ) >= $rlength ) {
return 1 if $ciface eq $root;
chop $ciface;
}
} elsif ( $ciface =~ /\+$/ ) {
my $root = $cifaceref->{root};
my $rlength = length( $root );
while ( length( $piface ) >= $rlength ) {
return 1 if $piface eq $root;
chop $piface;
}
}
}
0;
}
#
# Report about zones.
#
@@ -738,7 +772,7 @@ sub zone_report()
if ( $family == F_IPV4 ) {
progress_message_nocompress " $iref->{physical}:$grouplist";
} else {
progress_message_nocompress " $iref->{physical}:<$grouplist>";
progress_message_nocompress " $iref->{physical}:[$grouplist]";
}
$printed = 1;
}
@@ -747,6 +781,17 @@ sub zone_report()
}
}
PARENT:
for my $p ( @{$zoneref->{parents}} ) {
for my $pi ( keys ( %{$zones{$p}{interfaces}} ) ) {
for my $ci ( keys( %{$zoneref->{interfaces}} ) ) {
next PARENT if interface_match( $pi, $ci );
}
}
warning_message "Zone $zone is defined as a sub-zone of $p, yet the two zones have no interface in common";
}
unless ( $printed ) {
fatal_error "No bridge has been associated with zone $zone" if $type & BPORT && ! $zoneref->{bridge};
warning_message "*** $zone is an EMPTY ZONE ***" unless $type == FIREWALL;
@@ -1575,9 +1620,7 @@ sub known_interface($)
#
# We have wildcard interfaces -- see if this interface matches one of their roots
#
while ( length $iface > $minroot ) {
chop $iface;
while ( length $iface >= $minroot ) {
if ( my $i = $roots{$iface} ) {
#
# Found one
@@ -1599,6 +1642,8 @@ sub known_interface($)
};
return $interfaceref;
}
chop $iface;
}
}

View File

@@ -421,7 +421,7 @@ restore_default_route() # $1 = USE_DEFAULT_RT
conditionally_flush_conntrack() {
if [ -n "$g_purge" ]; then
if [ -n $(mywhich conntrack) ]; then
if [ -n "$(mywhich conntrack)" ]; then
conntrack -F
else
error_message "WARNING: The '-p' option requires the conntrack utility which does not appear to be installed on this system"
@@ -899,7 +899,7 @@ detect_dynamic_gateway() { # $1 = interface
#
# Detect the gateway through an interface
#
detect_gateway() # $1 = interface
detect_gateway() # $1 = interface $2 = table number
{
local interface
interface=$1
@@ -912,6 +912,8 @@ detect_gateway() # $1 = interface
# Maybe there's a default route through this gateway already
#
[ -n "$gateway" ] || gateway=$(find_gateway $($IP -4 route list dev $interface | grep ^default))
[ -z "$gateway" -a -n "$2" ] && gateway=$(find_gateway $($IP -4 route list dev $interface table $2 | grep ^default))
#
# Last hope -- is there a load-balancing route through the interface?
#

View File

@@ -127,6 +127,7 @@ g_counters=
g_compiled=
g_file=
g_docker=
g_dockeringress=
g_dockernetwork=
g_forcereload=
@@ -418,9 +419,12 @@ case "$COMMAND" in
[ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then
COMMAND=disable
detect_configuration $1
COMMAND=enable disable_provider $1 Yes
COMMAND=disable enable_provider $1 Yes
disable_provider $1 Yes
COMMAND=enable
detect_configuration $1
enable_provider $1 Yes
fi
mutex_off
status=0

View File

@@ -205,8 +205,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No
MUTEX_TIMEOUT=60

View File

@@ -216,8 +216,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No
MUTEX_TIMEOUT=60

View File

@@ -213,8 +213,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No
MUTEX_TIMEOUT=60

View File

@@ -216,8 +216,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No
MUTEX_TIMEOUT=60

View File

@@ -0,0 +1,12 @@
#
# Shorewall -- /etc/shorewall/disabled
#
# Add commands below that you want executed when an optional
# interface is successfully disabled using the 'disable' command
#
# When the commands are invoked:
#
# $1 contains the physical name of the interface
# $2 contains the logical name of the interface
# $3 contains the name of the provider associated with the interface,
if any

View File

@@ -0,0 +1,12 @@
#
# Shorewall -- /etc/shorewall/enabled
#
# Add commands below that you want executed when an optional
# interface is successfully enabled using the 'enable' command
#
# When the commands are invoked:
#
# $1 contains the physical name of the interface
# $2 contains the logical name of the interface
# $3 contains the name of the provider associated with the interface,
if any

View File

@@ -205,8 +205,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX=ko
MULTICAST=No
MUTEX_TIMEOUT=60

View File

@@ -616,8 +616,14 @@ run_install $OWNERSHIP -m 0644 params.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/c
if [ -f ${DESTDIR}${CONFDIR}/$PRODUCT/params ]; then
chmod 0644 ${DESTDIR}${CONFDIR}/$PRODUCT/params
else
case "$SPARSE" in
[Vv]ery)
;;
*)
run_install $OWNERSHIP -m 0600 params${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/params
echo "Parameter file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/params"
;;
esac
fi
if [ $PRODUCT = shorewall ]; then
@@ -693,10 +699,16 @@ fi
run_install $OWNERSHIP -m 0644 conntrack ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
run_install $OWNERSHIP -m 0644 conntrack.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack ]; then
case "$SPARSE" in
[Vv]ery)
;;
*)
if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack ]; then
run_install $OWNERSHIP -m 0600 conntrack${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack
echo "Conntrack file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/conntrack"
fi
fi
;;
esac
#
# Install the Mangle file

View File

@@ -1556,10 +1556,10 @@ remote_reload_command() # $* = original arguments less the command.
progress_message "Getting Capabilities on system $system..."
if [ $g_family -eq 4 ]; then
if ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
if ! rsh_command "MODULESDIR=$MODULESDIR IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed"
fi
elif ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
elif ! rsh_command "MODULESDIR=$MODULESDIR IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed"
fi
fi

View File

@@ -104,9 +104,7 @@ loc eth2 -</programlisting>
<para>You may use wildcards here by specifying a prefix followed by
the plus sign ("+"). For example, if you want to make an entry that
applies to all PPP interfaces, use 'ppp+'; that would match ppp0,
ppp1, ppp2, … Please note that the '+' means '<emphasis
role="bold">one</emphasis> or more additional characters' so 'ppp'
does not match 'ppp+'.</para>
ppp1, ppp2, …</para>
<para>When using Shorewall versions before 4.1.4, care must be
exercised when using wildcards where there is another zone that uses

View File

@@ -51,7 +51,7 @@
<para>The <replaceable>modulename</replaceable> names a kernel module
(without suffix). Shorewall will search for modules based on your
MODULESDIR and MODULE_SUFFIX settings in <ulink
MODULESDIR setting in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(8). The
<replaceable>moduleoption</replaceable>s are passed to modprobe (if
installed) or to insmod.</para>

View File

@@ -214,7 +214,14 @@
BALANCE_PROVIDERS=Yes, <option>balance=1</option> is assumed
unless the <option>fallback</option>, <option>loose</option>,
<option>load</option> or <option>tproxy</option> option is
specified.</para>
specified.I</para>
<caution>
<para>In IPV6, the <option>balance</option> option does not
cause balanced default routes to be created; it rather
causes a sequence of default routes with different metrics
to be created. </para>
</caution>
</listitem>
</varlistentry>
@@ -337,6 +344,14 @@
<para>Prior to Shorewall 4.4.24, the option is ignored with a
warning message if USE_DEFAULT_RT=Yes in
<filename>shorewall.conf</filename>.</para>
<caution>
<para>In IPV6, specifying the <option>fallback</option>
option on multiple providers does not cause balanced
fallback routes to be created; it rather causes a sequence
of fallback routes with different metrics to be
created.</para>
</caution>
</listitem>
</varlistentry>

View File

@@ -673,7 +673,7 @@
address changed to 206.124.146.177.</para>
<programlisting> #ACTION SOURCE DEST
SNAT(206.124.146.177) - eth0+myset[dst]</programlisting>
SNAT(206.124.146.177) - eth0:+myset[dst]</programlisting>
</listitem>
</varlistentry>

View File

@@ -406,8 +406,9 @@
<listitem>
<para>Formerly named AUTO_COMMENT. If set, if there is not a current
comment when a macro is invoked, the behavior is as if the first
line of the macro file was "COMMENT &lt;macro name&gt;". The
AUTO_COMMENT option has a default value of 'Yes'.</para>
line of the macro file was "COMMENT &lt;macro name&gt;". If not
specified, the AUTO_COMMENT option has a default value of
'Yes'.</para>
</listitem>
</varlistentry>
@@ -473,7 +474,7 @@
command, then the compilation step is skipped and the compiled
script that executed the last <command>start</command>, <emphasis
role="bold">reload</emphasis> or <command>restart</command> command
is used. The default is AUTOMAKE=No.</para>
is used. If not specified, the default is AUTOMAKE=No.</para>
<para>The setting of the AUTOMAKE option is ignored if the
<command>start</command>, <emphasis role="bold">reload</emphasis> or
@@ -1891,18 +1892,6 @@ LOG:info:,bar net fw</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">MODULE_SUFFIX=</emphasis>[<emphasis
role="bold">"</emphasis><emphasis>extension</emphasis> ...<emphasis
role="bold">"</emphasis>]</term>
<listitem>
<para>The value of this option determines the possible file
extensions of kernel modules. The default value is "ko ko.gz ko.xz o
o.gz o.xz gz xz".</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis
role="bold">MODULESDIR=</emphasis>[[+]<emphasis>pathname</emphasis>[<emphasis
@@ -2212,8 +2201,9 @@ LOG:info:,bar net fw</programlisting>
</listitem>
</itemizedlist>
<para>The default value is zero which disables all
optimizations.</para>
<para>In versions prior to 5.1.0, the default value is zero which
disables all optimizations. Beginning with Shorewall 5.1.0, the
default value is All which enables all optimizations.</para>
</listitem>
</varlistentry>

View File

@@ -28,7 +28,7 @@
#
# On the target system (the system where the firewall program is to run):
#
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
#
# Now move the capabilities file to the compilation system. The file must
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
@@ -38,7 +38,6 @@
#
# IPTABLES - iptables
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
#
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
# used during firewall compilation, then the generated firewall program will likewise not

View File

@@ -8,6 +8,7 @@
Description=Shorewall IPv6 firewall (lite)
Wants=network-online.target
After=network-online.target
After=shorewall-lite.service
Conflicts=ip6tables.service firewalld.service
[Service]

View File

@@ -7,6 +7,7 @@
Description=Shorewall IPv6 firewall (lite)
Wants=network-online.target
After=network-online.target
After=shorewall-lite.service
Conflicts=ip6tables.service firewalld.service
[Service]

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60
OPTIMIZE=All

View File

@@ -191,8 +191,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60
OPTIMIZE=All

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60
OPTIMIZE=All

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60
OPTIMIZE=All

View File

@@ -0,0 +1,12 @@
#
# Shorewall6 -- /etc/shorewall6/disabled
#
# Add commands below that you want executed when an optional
# interface is successfully disabled using the 'disable' command
#
# When the commands are invoked:
#
# $1 contains the physical name of the interface
# $2 contains the logical name of the interface
# $3 contains the name of the provider associated with the interface,
if any

View File

@@ -0,0 +1,12 @@
#
# Shorewall6 -- /etc/shorewall6/enabled
#
# Add commands below that you want executed when an optional
# interface is successfully enabled using the 'enable' command
#
# When the commands are invoked:
#
# $1 contains the physical name of the interface
# $2 contains the logical name of the interface
# $3 contains the name of the provider associated with the interface,
if any

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No
MODULE_SUFFIX=ko
MUTEX_TIMEOUT=60
OPTIMIZE=All

View File

@@ -7,6 +7,7 @@
Description=Shorewall IPv6 firewall
Wants=network-online.target
After=network-online.target
After=shorewall.service
Conflicts=ip6tables.service firewalld.service
[Service]

View File

@@ -8,6 +8,7 @@
Description=Shorewall IPv6 firewall
Wants=network-online.target
After=network-online.target
After=shorewall.service
Conflicts=ip6tables.service firewalld.service
[Service]

View File

@@ -475,10 +475,8 @@ root@gateway:~# </programlisting>
<section>
<title>Automatic Blacklisting</title>
<para>This example is taken from <ulink
url="http://www.briandowney.net/blog/2009/08/20/firewalling-brute-force-attempts-with-iptables/">this
article</ulink> which explains the nice benefits of this approach. This
example is for ssh, but it can be adapted for any application.</para>
<para>This example is for ssh, but it can be adapted for any
application.</para>
<para>The name SSH has been changed to SSHLIMIT so as not to override
the Shorewall macro of the same name.</para>

View File

@@ -776,12 +776,7 @@ SNAT(<emphasis role="bold">130.151.100.69</emphasis>) 192.168.1.0/24 eth1:19
<para>That rule (and the second one in the previous bullet) only
works of course if you have a static external IP address. If you
have a dynamic IP address then include this in
<filename>/etc/shorewall/params</filename>.</para>
<programlisting><command>ETH0_IP=$(find_first_interface_address eth0)</command> </programlisting>
<para>and make your DNAT rule:</para>
have a dynamic IP address then make your DNAT rule:</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST
@@ -793,34 +788,17 @@ SNAT(<emphasis role="bold">130.151.100.69</emphasis>) 192.168.1.0/24 eth1:19
?SECTION NEW
DNAT loc loc:192.168.1.5 tcp www - <emphasis
role="bold">$ETH0_IP</emphasis></programlisting>
role="bold">&amp;eth0</emphasis></programlisting>
<para>Using this technique, you will want to configure your
DHCP/PPPoE/PPTP/… client to automatically restart Shorewall each
time that you get a new IP address.</para>
DHCP/PPPoE/PPTP/… client to automatically reload Shorewall each time
that you get a new IP address.</para>
<note>
<para>If your local interface is a bridge, see <link
linkend="faq2e">FAQ 2e</link> for additional configuration
steps.</para>
</note>
<note>
<para>For optional interfaces, use the function <emphasis
role="bold">find_first_interface_address_if_any()</emphasis>
rather than <emphasis
role="bold">find_first_interface_address()</emphasis>. The former
will return 0.0.0.0 if the interface has no configured IP address;
the latter terminates the calling program.</para>
</note>
<note id="Call">
<para>If you run Shorewall-lite on your firewall, you must use the
following in the firewall's configuration directory
<filename>params</filename> file:</para>
<programlisting><command>ETH0_IP=$(ssh root@firewall "/sbin/shorewall-lite call find_first_interface_address eth0")</command></programlisting>
</note>
</listitem>
</itemizedlist>
@@ -928,14 +906,8 @@ MASQUERADE 192.168.1.0/24 eth2:192.168.1.2 tcp www</programlisting>
<emphasis role="bold">DNAT loc dmz:192.168.2.4 tcp 80 - 206.124.146.176</emphasis></programlisting>
<para>If your external IP address is dynamic, then you must do the
following:</para>
<para>In <filename>/etc/shorewall/params</filename>:</para>
<programlisting><command>ETH0_IP=`find_first_interface_address eth0`</command> </programlisting>
<para>and make your DNAT rule:</para>
<para>If your external IP address is dynamic, then you must make your
DNAT rule:</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST
@@ -947,7 +919,7 @@ MASQUERADE 192.168.1.0/24 eth2:192.168.1.2 tcp www</programlisting>
?SECTION NEW
DNAT loc dmz:192.168.2.4 tcp 80 - <emphasis
role="bold">$ETH0_IP</emphasis></programlisting>
role="bold">&amp;eth0</emphasis></programlisting>
<warning>
<para>With dynamic IP addresses, you probably don't want to use
@@ -956,21 +928,6 @@ DNAT loc dmz:192.168.2.4 tcp 80 - <emphasi
save</command> and <command>shorewall[-lite]
restore</command></ulink>.</para>
</warning>
<note>
<para>For optional interfaces, use the function <emphasis
role="bold">find_first_interface_address_if_any()</emphasis> rather
than <emphasis
role="bold">find_first_interface_address()</emphasis>. The former
will return 0.0.0.0 if the interface has no configured IP address;
the latter terminates the calling program.</para>
</note>
<note>
<para>If you use Shorewall-lite, then you need to configure the
params file in the firewall's configuration directory as described
<link linkend="Call">above</link>.</para>
</note>
</section>
<section id="faq2c">

View File

@@ -387,7 +387,7 @@
<listitem>
<para>Directory where the Shorewall Perl modules are installed.
Then will be installed in this directory under the sub-directory
They will be installed in this directory under the sub-directory
Shorewall. Default is distribution-specific.</para>
</listitem>
</varlistentry>
@@ -597,7 +597,7 @@
...</member>
</simplelist>
<para>The possible values for option are the same as those shone above
<para>The possible values for option are the same as those shown above
in the shorewallrc file. They may be specified in either upper or
lower case and may optionally be prefixed by '--'. To facilitate use
with the rpm %configure script, the following options are
@@ -634,7 +634,7 @@
</varlistentry>
</variablelist>
<para>Note that %configure may dsgenerate option/value pairs that are
<para>Note that %configure may generate option/value pairs that are
incompatible with the <command>configure</command> script. The current
%configure macro is:</para>

View File

@@ -43,6 +43,12 @@
While Shorewall also separates the address families in this way, it is
possible for Shorewall and Shorewall6 to share almost all of the
configuration files. This article gives an example.</para>
<caution>
<para>What is shown here currently works best with Debian and
derivatives, or when the tarball installer is used and the SPARSE option
is enabled when running configure[.pl].</para>
</caution>
</section>
<section>
@@ -66,14 +72,38 @@
<para>Here are the contents of /etc/shorewall/ and /etc/shorewal6/:</para>
<programlisting>root@gateway:/etc# ls shorewall shorewall6
<programlisting>root@gateway:/etc# ls -l shorewall shorewall6
shorewall:
action.Mirrors conntrack interfaces mangle params providers rtrules shorewall.conf started zones
actions hosts isusable mirrors policy proxyarp rules snat tunnels
total 88
-rw-r--r-- 1 root root 201 Mar 19 08:43 action.Mirrors
-rw-r--r-- 1 root root 109 Jun 29 15:13 actions
-rw-r--r-- 1 root root 655 Jun 29 15:13 conntrack
-rw-r--r-- 1 root root 107 Jul 1 10:40 hosts
-rw-r--r-- 1 root root 867 Jul 1 10:50 interfaces
-rw-r--r-- 1 root root 107 Jun 29 15:14 isusable
-rw-r--r-- 1 root root 497 Jul 1 10:42 mangle
-rw-r--r-- 1 root root 7 Jul 6 09:24 masq
-rw-r--r-- 1 root root 1290 Jun 29 15:16 mirrors
-rw-r--r-- 1 root root 2650 Jul 2 08:05 params
-rw-r--r-- 1 root root 645 Jun 28 10:04 policy
-rw-r--r-- 1 root root 1828 Jul 1 15:43 providers
-rw-r--r-- 1 root root 398 Mar 18 20:18 proxyarp
-rw-r--r-- 1 root root 702 Jul 1 10:42 rtrules
-rw-r--r-- 1 root root 6214 Jul 2 08:45 rules
lrwxrwxrwx 1 root root 29 Jul 6 12:42 shorewall6.conf -&gt; ../shorewall6/shorewall6.conf
-rw-r--r-- 1 root root 5571 Jun 25 18:09 shorewall.conf
-rw-r--r-- 1 root root 1084 Jul 1 10:42 snat
-rw-r--r-- 1 root root 181 Jun 29 15:12 started
-rw-r--r-- 1 root root 437 Jun 28 10:45 tunnels
-rw-r--r-- 1 root root 928 Jun 29 08:25 zones
shorewall6:
shorewall6.conf
root@gateway:/etc#</programlisting>
total 12
-rw------- 1 root root 954 Jul 6 12:48 conntrack
lrwxrwxrwx 1 root root 20 Jul 6 16:35 mirrors -&gt; ../shorewall/mirrors
lrwxrwxrwx 1 root root 19 Jul 6 12:48 params -&gt; ../shorewall/params
-rw-r--r-- 1 root root 5328 Jul 6 12:45 shorewall6.conf
root@gateway:/etc# </programlisting>
<para>The various configuration files are described in the sections that
follow. Note that in all cases, these files use the <ulink
@@ -87,11 +117,15 @@ root@gateway:/etc#</programlisting>
address families. The key setting is CONFIG_PATH in
shorewall6.conf:</para>
<programlisting>CONFIG_PATH="${CONFDIR}/shorewall6:<emphasis role="bold">${CONFDIR}/shorewall:</emphasis>/usr/share/shorewall6:${SHAREDIR}/shorewall"A</programlisting>
<programlisting>CONFIG_PATH="<emphasis role="bold">${CONFDIR}/shorewall:</emphasis>/usr/share/shorewall6:${SHAREDIR}/shorewall"</programlisting>
<para>Any Shorewall6 configuration file not found in
/etc/shorewall/shorewall6/ will be searched for in
/etc/shorewall/.</para>
<para><filename>/etc/shorewall6/</filename> is only used for processing
the <filename>params</filename> and <filename>shorewall6.conf</filename>
files. <filename>/etc/shorewall6/conntrack</filename> is installed when
SPARSE=Yes, but is not used.</para>
<para>The /etc/shorewall/shorewall6.conf symbolic link is required once
the above CONFIG_PATH setting is in effect.</para>
<section>
<title>shorewall.conf</title>
@@ -309,7 +343,7 @@ UNTRACKED_LOG_LEVEL=
###############################################################################
# L O C A T I O N O F F I L E S A N D D I R E C T O R I E S
###############################################################################
CONFIG_PATH="${CONFDIR}/shorewall6:${CONFDIR}/shorewall:/usr/share/shorewall6:${SHAREDIR}/shorewall"
CONFIG_PATH="${CONFDIR}/shorewall:/usr/share/shorewall6:${SHAREDIR}/shorewall"
GEOIPDIR=/usr/share/xt_geoip/LE
IP6TABLES=
IP=
@@ -427,12 +461,12 @@ ZONE_BITS=0
<para>Because addresses and interfaces are different between the two
address families, they cannot be hard-coded in the configuration files.
/etc/shorewall/params is used to set shell variables whose contents will
vary between Shorewall and Shorewall6. In the params file and in
run-time extension files, the shell variable <emphasis
role="bold">g_family</emphasis> can be used to determine which address
family to use; if IPv4, then $g_family will expand to 4 and if IPv6,
$g_family will expand to 6.</para>
<filename>/etc/shorewall/params</filename> is used to set shell
variables whose contents will vary between Shorewall and Shorewall6. In
the <filename>params</filename> file and in run-time extension files,
the shell variable <emphasis role="bold">g_family</emphasis> can be used
to determine which address family to use; if IPv4, then $g_family will
expand to 4 and if IPv6, $g_family will expand to 6.</para>
<para>The contents of /etc/shorewall/params is as follows:</para>
@@ -474,7 +508,7 @@ else
LISTS=[2001:470:b:227::42] # IP address of lists.shorewall.net (MX and HTTPS)
MAIL=[2001:470:b:227::45] # IP address of mail.shorewall.net (IMAPS and HTTPS)
SERVER=[2001:470:b:227::43] # IP address of www.shorewall.org (HTTP, FTP and RSYNC)
PROXY=Yes # Use TPROXY for local web access
PROXY=
ALL=[::]/0 # Entire address space
LOC_ADDR=[2601:601:8b00:bf0::1] # IP address of the local LAN interface
FAST_GATEWAY=fe80::22e5:2aff:feb7:f2cf # Default gateway through the IF_FAST interface
@@ -646,7 +680,7 @@ Tproxy { NUMBER=3, INTERFACE=lo, OPTIONS=tproxy }
?else
{ SOURCE=2001:470:A:227::/64, PROVIDER=HE, PRIORITY=1000! }
{ SOURCE=2001:470:B:227::/64, PROVIDER=HE, PRIORITY=11000 }
{ SOURCE=2601:601:8b00:bf0::/56 PROVIDER=IPv6Fast, PRIORITY=11000 }
{ SOURCE=2601:601:8b00:bf0::/60 PROVIDER=IPv6Fast, PRIORITY=11000 }
?endif
</programlisting>
</section>
@@ -885,7 +919,7 @@ Mirrors(ACCEPT:none) { SOURCE=net, DEST=dmz:$SERVER, PROTO=tcp, DPORT=873 }
SNAT(70.90.191.123) { SOURCE=!70.90.191.120/29, DEST=PROD_IF, COMMENT="Masquerade Local Network" }
SNAT(172.20.1.253) { SOURCE=172.20.3.0/24, DEST=LOC_IF:172.20.1.100 }
?else
SNAT(&amp;PROD_IF) { SOURCE=2601:601:8b00:bf0::56, DEST=PROD_IF }
SNAT(&amp;PROD_IF) { SOURCE=2601:601:8b00:bf0::/60, DEST=PROD_IF }
SNAT(&amp;FAST_IF) { SOURCE=2001:470:b:227::/64,2001:470:a:227::2, DEST=FAST_IF }
?endif
</programlisting>

View File

@@ -147,7 +147,7 @@
<para>To integrate with NetworkManager and ifup/ifdown, additional steps
are required. You probably don't want to enable this feature if you run a
link status monitor like swping or LSM.</para>
link status monitor like FOOLSM.</para>
<orderedlist numeration="loweralpha">
<listitem>

View File

@@ -426,7 +426,8 @@ Tproxy 1 - - lo - tproxy</programli
DIVERT eth0 0.0.0.0/0 tcp - 80
TPROXY(3129) eth1 0.0.0.0/0 tcp 80</programlisting>
<para>Corresponding <filename>/etc/shorewall/mangle</filename> are:</para>
<para>Corresponding <filename>/etc/shorewall/tcrules</filename>
are:</para>
<programlisting>#MARK SOURCE DEST PROTO DPORT SPORT
DIVERT eth0 0.0.0.0/0 tcp - 80

View File

@@ -253,7 +253,7 @@ eth0:0 192.168.1.0/24 206.124.146.178-206.124.146.180</program
<filename>/etc/shorewall/snat</filename> is:</para>
<programlisting>#ACTION SOURCE DEST PROTO PORT
SNAT(206.124.146.178-206.24.146.80) 192.168.1.0/24 eth0</programlisting>
SNAT(206.124.146.178-206.24.146.180) 192.168.1.0/24 eth0</programlisting>
<para>The above would create three IP addresses:</para>

View File

@@ -18,7 +18,7 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright>
<year>2001-2016</year>
<year>2001-2017</year>
<holder>Thomas M. Eastep</holder>
</copyright>
@@ -583,9 +583,9 @@ ACCEPT net:\
</row>
<row>
<entry>conntrack (formerly notrack)</entry>
<entry>conntrack</entry>
<entry>source,dest,proto,dport,sport,user,switch</entry>
<entry>action,source,dest,proto,dport,sport,user,switch</entry>
</row>
<row>

View File

@@ -234,6 +234,18 @@ cat -</programlisting>
can be used to augment or replace functions in the standard CLI
libraries.</para>
</listitem>
<listitem>
<para><filename>enabled</filename> -- Added in Shorewall 5.1.6.
Invoked when an optional interface or provider is successfully enabled
using the <command>enable</command> command.</para>
</listitem>
<listitem>
<para><filename>disabled</filename> -- Added in Shorewall 5.1.6.
Invoked when an optional interface or provider is successfully
disabled using the <command>disable</command> command.</para>
</listitem>
</itemizedlist>
<para><emphasis role="bold">If your version of Shorewall doesn't have the
@@ -274,6 +286,18 @@ cat -</programlisting>
<entry/>
</row>
<row>
<entry>disable</entry>
<entry>disable</entry>
</row>
<row>
<entry>enable</entry>
<entry>enable</entry>
</row>
<row>
<entry>init</entry>
@@ -446,20 +470,14 @@ cat -</programlisting>
<itemizedlist>
<listitem>
<para>CONFDIR - The configuration directory. Will be <filename
class="directory">/etc/shorewall</filename>, <filename
class="directory">/etc/shorewall6/</filename>, <filename
class="directory">/etc/shorewall-lite</filename>, or <filename
class="directory">/etc/shorewall6-lite</filename> depending on
which product is running.</para>
class="directory">/etc/</filename>.
The running product is defined in the g_product variable.</para>
</listitem>
<listitem>
<para>SHAREDIR - The product shared directory. Will be <filename
class="directory">/usr/share/shorewall</filename>, <filename
class="directory">/usr/share/shorewall6/</filename>, <filename
class="directory">/usr/share/shorewall-lite</filename>, or
<filename class="directory">/usr/share/shorewall6-lite</filename>
depending on which product is running.</para>
class="directory">/usr/share</filename>.
The running product is defined in the g_product variable.</para>
</listitem>
<listitem>
@@ -508,25 +526,37 @@ cat -</programlisting>
<row>
<entry>initdone</entry>
<entry>init</entry>
<entry>disable</entry>
</row>
<row>
<entry>maclog</entry>
<entry>isusable</entry>
<entry>enable</entry>
</row>
<row>
<entry>Per-chain (including those associated with
actions)</entry>
<entry>start</entry>
<entry>init</entry>
</row>
<row>
<entry>postcompile</entry>
<entry>isusable</entry>
</row>
<row>
<entry/>
<entry>start</entry>
</row>
<row>
<entry/>
<entry>started</entry>
</row>
@@ -575,6 +605,44 @@ cat -</programlisting>
</tgroup>
</informaltable></para>
<para>The contents of each run-time script is placed in a shell
function, so you can declare local variables and can use the
<command>return</command> command. The functions generated from the
<filename>enable</filename> and <filename>disable</filename> scripts are
passed three arguments:</para>
<variablelist>
<varlistentry>
<term>$1</term>
<listitem>
<para>Physical name of the interface that was enabled or
disabled.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$2</term>
<listitem>
<para>Logical name of the interface.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$3</term>
<listitem>
<para>Name of the Provider, if any, associated with the
interface.</para>
</listitem>
</varlistentry>
</variablelist>
<para>As described above, the function generated from the
<filename>isusable</filename> script is passed a single argument that
names a network interface.</para>
<para>With the exception of postcompile, compile-time extension scripts
are executed using the Perl 'eval `cat
&lt;<emphasis>file</emphasis>&gt;`' mechanism. Be sure that each script