Compare commits

..

65 Commits

Author SHA1 Message Date
Tom Eastep
e626b77097 Correct policy zone exclusion handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-21 09:31:13 -08:00
Tom Eastep
15dd14e167 Correct link to Roberto's repository
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-08 10:47:43 -08:00
Tom Eastep
83b586c192 More document changes
- Include Linuxfest presentation titles

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-08 10:45:09 -08:00
Matt Darfeuille
d3fcb29f0d Use proper function name for warning messages
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-07 10:44:46 -08:00
Tom Eastep
a4ed419aba Add new manpages to Manpages web page
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-07 10:42:23 -08:00
Tom Eastep
e548043e96 Remove modules files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-06 14:17:10 -08:00
Tom Eastep
443a4223c2 Remove pre-2.6.20 helpers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-06 14:11:48 -08:00
Tom Eastep
8f42a6a72b Remove LOAD_HELPERS_ONLY
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-03 10:04:19 -08:00
Tom Eastep
0982fec513 Remove superfluous whitespace from Providers.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-02-01 12:44:44 -08:00
Tom Eastep
f5262dd050 Correct typo in shorewall-providers(5)
- RESTORE_DEFAULT_OPTION -> RESTORE_DEFAULT_GATEWAY
2019-02-01 12:44:00 -08:00
Tom Eastep
8dcfd86f3a Document compiler globals
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-24 08:26:27 -08:00
Tom Eastep
edc9e25f25 Deprecate 'all[+]-'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-23 12:35:07 -08:00
Tom Eastep
ef11ae834d Drop documentation for all-
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-22 15:53:33 -08:00
Tom Eastep
9f423412d8 Allow zone exclusion in the policy file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-22 12:35:23 -08:00
Tom Eastep
7f7fef3a4e Disallow 'all' in a policy zone list
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-21 10:00:36 -08:00
Tom Eastep
b9d0821acb Make $update global in Config.pm
- Only save raw image if we are updating

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-20 11:06:40 -08:00
Tom Eastep
857539c8b1 Update lib.runtime copyright
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 13:09:42 -08:00
Tom Eastep
429070d107 Update Chains.pm and Compiler.pm copyrights
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 12:28:27 -08:00
Tom Eastep
89725c530f Change limit of 'wait' option setting to 300 seconds (5 minutes)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-16 11:50:33 -08:00
Tom Eastep
8e5f67797a Allow INLINE() in the accounting file to accept '+' in inline matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-14 14:52:18 -08:00
Tom Eastep
0eb0bace9a Update more copyrights
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-09 11:57:41 -08:00
Tom Eastep
fab8cc055b Remove unused local variable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 14:25:09 -08:00
Tom Eastep
bef8ec09b3 Insist that '+' (if present) be the first non-blank character in IL matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 13:55:02 -08:00
Tom Eastep
cf330afbd9 Allow inline matches in the conntrack file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-08 13:09:00 -08:00
Tom Eastep
49731da807 Update copyright dates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-04 10:14:27 -08:00
Tom Eastep
f3ecbc185c Add Netmanager gateway detection
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-03 11:22:15 -08:00
Tom Eastep
a71a44346e Document the provider table contents
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-02 15:27:38 -08:00
Tom Eastep
4d278f4c20 Clarify [no]hostroute in shorewall-providers(5).
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2019-01-02 15:08:38 -08:00
Tom Eastep
45ec24ea42 Add comments to the Zones module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-30 14:10:28 -08:00
Tom Eastep
bf3880ae59 Add some comments to the Misc module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-30 12:41:55 -08:00
Tom Eastep
9e838e6d04 Add Tuomo Soini's WUDO macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-19 14:57:38 -08:00
Tom Eastep
d096db6a94 Add/modify comments in Chains.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-19 09:19:26 -08:00
Tom Eastep
636d82414f Merge branch '5.2.1' 2018-12-16 10:34:34 -08:00
Tom Eastep
cb3273b13b Revert "Allow leading 's' & 'd' to be omitted when specifying two rates"
This reverts commit 23bc6f1ab5.
2018-12-16 10:06:34 -08:00
Tom Eastep
f0c75b5119 Update RATE documentation in shorewall-rules(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-16 10:06:00 -08:00
Tom Eastep
23bc6f1ab5 Allow leading 's' & 'd' to be omitted when specifying two rates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-16 09:47:45 -08:00
Roberto C. Sánchez
54e6412c49 Fix documentation typos 2018-12-15 15:34:45 -08:00
Tom Eastep
1465035aa4 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2018-12-15 14:57:21 -08:00
Tom Eastep
8473bf2200 Clean up macros contributed by Vincas Dargis
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-15 10:31:57 -08:00
Tom Eastep
0fe45b8f46 Merge branch 'tor' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:25:22 -08:00
Tom Eastep
a4c87149c9 Merge branch 'oncrpc_macro' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:24:56 -08:00
Tom Eastep
83359b098d Merge branch 'bitcoin' of ssh://teastep@git.code.sf.net/u/talkless/shorewall 2018-12-15 10:21:14 -08:00
Tom Eastep
3239fb3eb9 Merge branch '5.2.1' 2018-12-15 09:56:14 -08:00
Roberto C. Sánchez
096f59b5bc Fix documentation typos 2018-12-15 11:02:07 -05:00
Vincas Dargis
9260be402b Add Tor macros
Add macros for various Tor Anonimity Network ports
2018-12-15 13:08:06 +02:00
Vincas Dargis
7bf7000941 Add Bitcoin macros
Add macros for various Bitcoin daemon ports.
2018-12-15 12:35:52 +02:00
Vincas Dargis
840f8b904d Add ONC RPC macro
Add macro for handling ONC RPC calls, for rpcinbd on Linux.
2018-12-15 12:10:03 +02:00
Tom Eastep
61ac08dc7f Correct handling of netmask when two rates are specified in the RATE col.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 14:16:26 -08:00
Tom Eastep
f65b10c375 Remove dead/silly code from Shorewall::Chains::use_input/output_chain()
- combine the two into a single function use_interface_chain().

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 13:54:36 -08:00
Tom Eastep
35c7f304f7 Correct log name for untracked chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 11:00:27 -08:00
Tom Eastep
467544801e Clean up of Chains.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 10:59:31 -08:00
Tom Eastep
7cfe9ec272 Correct log name for untracked chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 10:58:26 -08:00
Tom Eastep
6908a4bcf7 Issue warning when ULOG is used.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-14 09:00:42 -08:00
Tom Eastep
be2110b47e Revert "Remove ULOG support"
This reverts commit 061ce3d781.
2018-12-14 08:54:07 -08:00
Tom Eastep
ad6401da8c Cleanup of Config.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-13 15:32:39 -08:00
Tom Eastep
2b6d657fb0 Add UDP tip to DNAT solutions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-13 10:33:11 -08:00
Tom Eastep
668cb6deda Make 'status -i' work when there are no providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-11 13:44:31 -08:00
Tom Eastep
ddd8576ced Merge branch '5.2.1' 2018-12-09 11:07:44 -08:00
Tom Eastep
98aad094fb Correct typo in Anti-Spoofing.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-12-09 11:07:10 -08:00
Tom Eastep
8ed644a0ec Correct HELPER requires error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-28 11:00:41 -08:00
Tom Eastep
86b82c53cf Correct HELPER requires error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-28 10:59:53 -08:00
Tom Eastep
061ce3d781 Remove ULOG support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-15 14:59:29 -08:00
Tom Eastep
45f8d31021 Don't try to load ipt_ULOG
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-15 14:33:25 -08:00
Tom Eastep
03d2088cf7 Implement SW_CONFDIR support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-11-06 15:40:26 -08:00
Tom Eastep
6534201284 Fix assertion failure during 'check -r' when DOCKER=Yes
- avoid unnecessary mode transitions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2018-10-31 15:30:03 -07:00
65 changed files with 852 additions and 910 deletions

View File

@@ -411,7 +411,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
[ -d $directory ] && moduledirectories="$moduledirectories $directory" [ -d $directory ] && moduledirectories="$moduledirectories $directory"
done done
[ -n "$LOAD_HELPERS_ONLY" ] && modules=$(find_file helpers) || modules=$(find_file modules) modules=$(find_file helpers)
if [ -f $modules -a -n "$moduledirectories" ]; then if [ -f $modules -a -n "$moduledirectories" ]; then
[ -d /sys/module/ ] || MODULES=$(lsmod | cut -d ' ' -f1) [ -d /sys/module/ ] || MODULES=$(lsmod | cut -d ' ' -f1)

View File

@@ -426,6 +426,11 @@ echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shor
if [ -f modules ]; then if [ -f modules ]; then
install_file modules ${DESTDIR}${SHAREDIR}/$PRODUCT/modules 0600 install_file modules ${DESTDIR}${SHAREDIR}/$PRODUCT/modules 0600
echo "Modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/modules" echo "Modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/modules"
for f in modules.*; do
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
done
fi fi
if [ -f helpers ]; then if [ -f helpers ]; then
@@ -433,11 +438,6 @@ if [ -f helpers ]; then
echo "Helper modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers" echo "Helper modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers"
fi fi
for f in modules.*; do
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
done
# #
# Install the Man Pages # Install the Man Pages
# #

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.Bitcoin
#
# Macro for handling Bitcoin P2P traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 8333

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.BitcoinRPC
#
# Macro for handling Bitcoin RPC traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 8332

View File

@@ -0,0 +1,9 @@
#
# Shorewall --/usr/share/shorewall/macro.BitcoinZMQ
#
# Macro for handling Bitcoin ZMQ traffic
# See https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 28332

View File

@@ -0,0 +1,8 @@
#
# Shorewall -- /usr/share/shorewall/macro.ONCRPC
#
# This macro handles ONC RCP traffic (for rpcbind on Linux, etc).
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp,udp 111

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.Tor
#
# Macro for handling Tor Onion Network traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9001

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorBrowserBundle
#
# Macro for handling Tor Onion Network traffic provided by Tor Browser Bundle
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9150

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorControl
#
# Macro for handling Tor Controller Applications traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9051

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorDirectory
#
# Macro for handling Tor Directory traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9030

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorSocks
#
# Macro for handling Tor Socks Proxy traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9050

View File

@@ -0,0 +1,9 @@
# Shorewall -- /usr/share/shorewall/macro.WUDO
#
# This macro handles WUDO (Windows Update Delivery Optimization)
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 7680

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -201,6 +201,13 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
my $prerule = ''; my $prerule = '';
my $rule2 = 0; my $rule2 = 0;
my $jump = 0; my $jump = 0;
my $raw_matches = get_inline_matches(1);
if ( $raw_matches =~ s/^\s*+// ) {
$prerule = $raw_matches;
} else {
$rule .= $raw_matches;
}
unless ( $action eq 'COUNT' ) { unless ( $action eq 'COUNT' ) {
if ( $action eq 'DONE' ) { if ( $action eq 'DONE' ) {
@@ -242,9 +249,7 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
$rule .= do_nfacct( $_ ); $rule .= do_nfacct( $_ );
} }
} }
} elsif ( $action eq 'INLINE' ) { } elsif ( $action ne 'INLINE' ) {
$rule .= get_inline_matches(1);
} else {
( $action, my $cmd ) = split /:/, $action; ( $action, my $cmd ) = split /:/, $action;
if ( $cmd ) { if ( $cmd ) {

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -186,13 +186,12 @@ our %EXPORT_TAGS = (
input_chain input_chain
input_option_chain input_option_chain
zone_input_chain zone_input_chain
use_input_chain use_interface_chain
output_chain output_chain
output_option_chain output_option_chain
prerouting_chain prerouting_chain
postrouting_chain postrouting_chain
zone_output_chain zone_output_chain
use_output_chain
masq_chain masq_chain
syn_flood_chain syn_flood_chain
mac_chain mac_chain
@@ -431,13 +430,14 @@ our $VERSION = 'MODULEVERSION';
# Untracked - =<z1-z2> # Untracked - =<z1-z2>
# #
our %chain_table; our %chain_table;
our $raw_table; our $raw_table; # Reference to $chain_table{raw}
our $nat_table; our $nat_table; # Reference to $chain_table{nat}
our $mangle_table; our $mangle_table; # Reference to $chain_table{mangle}
our $filter_table; our $filter_table; # Reference to $chain_table{filter}
our $export;
our %renamed; our $export; # True if we are compiling for export
our %nfobjects; our %renamed; # Maps chain renaming during optimization
our %nfobjects; # Records nfacct objects
# #
# Target Types # Target Types
@@ -465,10 +465,10 @@ use constant { STANDARD => 0x1, #defined by Netfilter
IPTABLES => 0x100000, #IPTABLES or IP6TABLES IPTABLES => 0x100000, #IPTABLES or IP6TABLES
TARPIT => 0x200000, #TARPIT TARPIT => 0x200000, #TARPIT
FILTER_TABLE => 0x1000000, FILTER_TABLE => 0x1000000, #Target allowed in the filter table
MANGLE_TABLE => 0x2000000, MANGLE_TABLE => 0x2000000, #Target allowed in the mangle table
RAW_TABLE => 0x4000000, RAW_TABLE => 0x4000000, #Target allowed in the raw table
NAT_TABLE => 0x8000000, NAT_TABLE => 0x8000000, #Target allowed in the nat table
}; };
# #
# Valid Targets -- value is a combination of one or more of the above # Valid Targets -- value is a combination of one or more of the above
@@ -687,15 +687,15 @@ our %ipset_exists;
# #
# The following constants and hash are used to classify keys in a rule hash # The following constants and hash are used to classify keys in a rule hash
# #
use constant { UNIQUE => 1, use constant { UNIQUE => 1, # Simple header matches - only allowed once per rule
TARGET => 2, TARGET => 2, # Rule target or its options
EXCLUSIVE => 4, EXCLUSIVE => 4, # 'state' or 'conntrack --ctstate'
MATCH => 8, MATCH => 8, # Currently means 'policy ...'
CONTROL => 16, CONTROL => 16, # Unsed internally by the compiler - does not contribute to the iptables rule
COMPLEX => 32, COMPLEX => 32, # Currently means 'contrack --cstate'
NFACCT => 64, NFACCT => 64, # nfacct match
EXPENSIVE => 128, EXPENSIVE => 128, # Has high rule-processing cost in the kernel
RECENT => 256, RECENT => 256, # recent match
}; };
our %opttype = ( rule => CONTROL, our %opttype = ( rule => CONTROL,
@@ -741,6 +741,9 @@ our %opttype = ( rule => CONTROL,
targetopts => TARGET, targetopts => TARGET,
); );
#
# These allow the user to specify long option names in raw ip[6]tables input
#
our %aliases = ( protocol => 'p', our %aliases = ( protocol => 'p',
source => 's', source => 's',
destination => 'd', destination => 'd',
@@ -760,7 +763,7 @@ our %isocodes;
use constant { ISODIR => '/usr/share/xt_geoip/LE' }; use constant { ISODIR => '/usr/share/xt_geoip/LE' };
our %switches; our %switches; # Recoreds switches (conditions)
# #
# Rather than initializing globals in an INIT block or during declaration, # Rather than initializing globals in an INIT block or during declaration,
@@ -786,7 +789,9 @@ sub initialize( $$$ ) {
$filter_table = $chain_table{filter}; $filter_table = $chain_table{filter};
%renamed = (); %renamed = ();
# #
# Used to sequence chain names in each table. # Used to sequence chain names in each table. $hard is true on the initial call to this function and
# false, when this function is called a second time to re-initialize before generating stopped ip[6]tables-
# restore input
# #
%chainseq = () if $hard; %chainseq = () if $hard;
# #
@@ -1746,6 +1751,10 @@ sub add_rule($$;$) {
# #
# New add_rule implementation # New add_rule implementation
# #
#
# Push a set of matches into an irule (a rule using the new hash representation)
#
sub push_matches { sub push_matches {
my $ruleref = shift; my $ruleref = shift;
@@ -1912,6 +1921,9 @@ sub compare_values( $$ ) {
} }
} }
#
# Add an irule with matches but no target
#
sub add_irule( $;@ ) { sub add_irule( $;@ ) {
my ( $chainref, @matches ) = @_; my ( $chainref, @matches ) = @_;
@@ -2325,7 +2337,7 @@ sub invalid_log($$) {
# Name of the untracked chain between an ordered pair of zones # Name of the untracked chain between an ordered pair of zones
# #
sub untracked_log($$) { sub untracked_log($$) {
'&' . &rules_log(@_); '=' . &rules_log(@_);
} }
# #
@@ -2431,10 +2443,11 @@ sub zone_input_chain($) {
} }
# #
# Returns true if we're to use the interface's input chain # Returns true if we're to use the interface's input or chain, depending on the second argument
# (use_input_chain or use_output_chain).
# #
sub use_input_chain($$) { sub use_interface_chain($$) {
my ( $interface, $chainref ) = @_; my ( $interface, $which ) = @_;
my $interfaceref = find_interface($interface); my $interfaceref = find_interface($interface);
my $nets = $interfaceref->{nets}; my $nets = $interfaceref->{nets};
# #
@@ -2462,17 +2475,11 @@ sub use_input_chain($$) {
# the zone has multiple interfaces # the zone has multiple interfaces
# and this interface has option rules # and this interface has option rules
# #
return 1 if $interfaceref->{options}{use_input_chain} && keys %{ zone_interfaces( $zone ) } > 1; return 1 if $interfaceref->{options}{$which} && keys %{ zone_interfaces( $zone ) } > 1;
# #
# Interface associated with a single zone -- use the zone's input chain if it has one # Interface associated with a single zone -- use the zone's input chain if it has one
# #
return 0 if $chainref; return 0;
#
# Use the <zone>->fw rules chain if it is referenced.
#
$chainref = $filter_table->{rules_chain( $zone, firewall_zone )};
! ( $chainref->{referenced} || $chainref->{is_policy} )
} }
# #
@@ -2509,41 +2516,6 @@ sub zone_output_chain($) {
$_[0] . '_output'; $_[0] . '_output';
} }
#
# Returns true if we're to use the interface's output chain
#
sub use_output_chain($$) {
my ( $interface, $chainref) = @_;
my $interfaceref = find_interface($interface);
my $nets = $interfaceref->{nets};
#
# We must use the interfaces's chain if the interface is associated with multiple Zones
#
return 1 if ( keys %{interface_zones $interface} ) > 1;
#
# Use interface's chain if there are multiple nets on the interface
#
return 1 if $nets > 1;
#
# Use interface's chain if it is a bridge with ports
#
return 1 if $interfaceref->{ports};
#
# Don't need it if it isn't associated with any zone
#
return 0 unless $nets;
#
# Interface associated with a single zone -- use the zone's output chain if it has one
#
return 0 if $chainref;
#
# Use the fw-><zone> rules chain if it is referenced.
#
$chainref = $filter_table->{rules_chain( firewall_zone , $interfaceref->{zone} )};
! ( $chainref->{referenced} || $chainref->{is_policy} )
}
# #
# Masquerade Chain for an interface # Masquerade Chain for an interface
# #
@@ -2753,6 +2725,12 @@ sub add_expanded_jump( $$$$ ) {
add_reference( $chainref, $toref ) while --$splitcount > 0; add_reference( $chainref, $toref ) while --$splitcount > 0;
} }
#
# Utility function used by add_ijump() and add_ijump_extended().
# Returns a reference to the added rule. Return may be reference
# to the dummy rule if the chain was already complete (last rule
# is a simple jump to a terminating target).
#
sub add_ijump_internal( $$$$$;@ ) { sub add_ijump_internal( $$$$$;@ ) {
my ( $fromref, $jump, $to, $expandports, $origin, @matches ) = @_; my ( $fromref, $jump, $to, $expandports, $origin, @matches ) = @_;
@@ -2800,16 +2778,26 @@ sub add_ijump_internal( $$$$$;@ ) {
$expandports ? handle_port_ilist( $fromref, $ruleref, 1 ) : push_irule( $fromref, $ruleref ); $expandports ? handle_port_ilist( $fromref, $ruleref, 1 ) : push_irule( $fromref, $ruleref );
} }
#
# Add an jump to the end of a chain
#
sub add_ijump( $$$;@ ) { sub add_ijump( $$$;@ ) {
my ( $fromref, $jump, $to, @matches ) = @_; my ( $fromref, $jump, $to, @matches ) = @_;
add_ijump_internal( $fromref, $jump, $to, 0, '', @matches ); add_ijump_internal( $fromref, $jump, $to, 0, '', @matches );
} }
#
# Like add_ijump() but also accepts an origin of the jump (the config file and line number
# that caused the jump to be generated).
#
sub add_ijump_extended( $$$$;@ ) { sub add_ijump_extended( $$$$;@ ) {
my ( $fromref, $jump, $to, $origin, @matches ) = @_; my ( $fromref, $jump, $to, $origin, @matches ) = @_;
add_ijump_internal( $fromref, $jump, $to, 0, $origin, @matches ); add_ijump_internal( $fromref, $jump, $to, 0, $origin, @matches );
} }
#
# Insert a jump at a zero-relative index into a chain.
#
sub insert_ijump( $$$$;@ ) { sub insert_ijump( $$$$;@ ) {
my ( $fromref, $jump, $to, $index, @matches ) = @_; my ( $fromref, $jump, $to, $index, @matches ) = @_;
@@ -2881,6 +2869,9 @@ sub delete_jumps ( $$ ) {
} }
} }
#
# Reset the passed flag(s) in the passed chain
#
sub reset_optflags( $$ ) { sub reset_optflags( $$ ) {
my ( $chain, $flags ) = @_; my ( $chain, $flags ) = @_;
@@ -2893,6 +2884,9 @@ sub reset_optflags( $$ ) {
$chainref; $chainref;
} }
#
# Set the passed flag(s) in the passed chain
#
sub set_optflags( $$ ) { sub set_optflags( $$ ) {
my ( $chain, $flags ) = @_; my ( $chain, $flags ) = @_;
@@ -3007,6 +3001,10 @@ sub accounting_chainrefs() {
grep $_->{accounting} , values %$filter_table; grep $_->{accounting} , values %$filter_table;
} }
#
# Ensure the existance of a chain in the mangle table and return
# a reference to its chain table entry
#
sub ensure_mangle_chain($;$$) { sub ensure_mangle_chain($;$$) {
my ( $chain, $number, $restriction ) = @_; my ( $chain, $number, $restriction ) = @_;
@@ -3017,6 +3015,10 @@ sub ensure_mangle_chain($;$$) {
$chainref; $chainref;
} }
#
# Ensure the existance of a chain in the nat table and return
# a reference to its chain table entry
sub ensure_nat_chain($) { sub ensure_nat_chain($) {
my $chain = $_[0]; my $chain = $_[0];
@@ -3025,6 +3027,10 @@ sub ensure_nat_chain($) {
$chainref; $chainref;
} }
#
# Ensure the existance of a chain in the raw table and return
# a reference to its chain table entry
#
sub ensure_raw_chain($) { sub ensure_raw_chain($) {
my $chain = $_[0]; my $chain = $_[0];
@@ -3048,12 +3054,18 @@ sub new_builtin_chain($$$)
$chainref; $chainref;
} }
#
# Create a chain in the filter table, returning a reference to its chain table entry
#
sub new_standard_chain($) { sub new_standard_chain($) {
my $chainref = new_chain 'filter' ,$_[0]; my $chainref = new_chain 'filter' ,$_[0];
$chainref->{referenced} = 1; $chainref->{referenced} = 1;
$chainref; $chainref;
} }
#
# Create a new action chain, returning a reference to its chain table entry
#
sub new_action_chain($$) { sub new_action_chain($$) {
my $chainref = &new_chain( @_ ); my $chainref = &new_chain( @_ );
$chainref->{referenced} = 1; $chainref->{referenced} = 1;
@@ -3061,12 +3073,18 @@ sub new_action_chain($$) {
$chainref; $chainref;
} }
#
# Create a chain in the nat table, returning a reference to its chain table entry
#
sub new_nat_chain($) { sub new_nat_chain($) {
my $chainref = new_chain 'nat' ,$_[0]; my $chainref = new_chain 'nat' ,$_[0];
$chainref->{referenced} = 1; $chainref->{referenced} = 1;
$chainref; $chainref;
} }
#
# Create a new manual chain, returning a reference to its chain table entry
#
sub new_manual_chain($) { sub new_manual_chain($) {
my $chain = $_[0]; my $chain = $_[0];
fatal_error "Chain name ($chain) too long" if length $chain > 29; fatal_error "Chain name ($chain) too long" if length $chain > 29;
@@ -3077,6 +3095,9 @@ sub new_manual_chain($) {
$chainref; $chainref;
} }
#
# Ensure the existance of a manual chain and return a reference to its chain table entry
#
sub ensure_manual_chain($) { sub ensure_manual_chain($) {
my $chain = $_[0]; my $chain = $_[0];
my $chainref = $filter_table->{$chain} || new_manual_chain($chain); my $chainref = $filter_table->{$chain} || new_manual_chain($chain);
@@ -3086,6 +3107,9 @@ sub ensure_manual_chain($) {
sub log_irule_limit( $$$$$$$$@ ); sub log_irule_limit( $$$$$$$$@ );
#
# Ensure the existance of the blacklist logging chain (blacklog)
#
sub ensure_blacklog_chain( $$$$$ ) { sub ensure_blacklog_chain( $$$$$ ) {
my ( $target, $disposition, $level, $tag, $audit ) = @_; my ( $target, $disposition, $level, $tag, $audit ) = @_;
@@ -3104,6 +3128,9 @@ sub ensure_blacklog_chain( $$$$$ ) {
'blacklog'; 'blacklog';
} }
#
# Ensure the existance of the audited blacklist logging chain (A_blacklog)
#
sub ensure_audit_blacklog_chain( $$$ ) { sub ensure_audit_blacklog_chain( $$$ ) {
my ( $target, $disposition, $level ) = @_; my ( $target, $disposition, $level ) = @_;
@@ -3125,7 +3152,6 @@ sub ensure_audit_blacklog_chain( $$$ ) {
# #
# Create and populate the passed AUDIT chain if it doesn't exist. Return chain name # Create and populate the passed AUDIT chain if it doesn't exist. Return chain name
# #
sub ensure_audit_chain( $;$$$ ) { sub ensure_audit_chain( $;$$$ ) {
my ( $target, $action, $tgt, $table ) = @_; my ( $target, $action, $tgt, $table ) = @_;
@@ -3162,7 +3188,6 @@ sub ensure_audit_chain( $;$$$ ) {
# #
# Return the appropriate target based on whether the second argument is 'audit' # Return the appropriate target based on whether the second argument is 'audit'
# #
sub require_audit($$;$) { sub require_audit($$;$) {
my ($action, $audit, $tgt ) = @_; my ($action, $audit, $tgt ) = @_;
@@ -5078,7 +5103,9 @@ sub do_proto( $$$;$ )
$output; $output;
} }
#
# Generate a mac address match
#
sub do_mac( $ ) { sub do_mac( $ ) {
my $mac = $_[0]; my $mac = $_[0];
@@ -5091,6 +5118,9 @@ sub do_mac( $ ) {
"-m mac ${invert}--mac-source $mac "; "-m mac ${invert}--mac-source $mac ";
} }
#
# Version of do_proto() that generates an irule match rather than an iptables text match
#
sub do_iproto( $$$ ) sub do_iproto( $$$ )
{ {
my ($proto, $ports, $sports ) = @_; my ($proto, $ports, $sports ) = @_;
@@ -5286,6 +5316,9 @@ sub do_iproto( $$$ )
@output; @output;
} }
#
# Generate a mac address match in irule format.
#
sub do_imac( $ ) { sub do_imac( $ ) {
my $mac = $_[0]; my $mac = $_[0];
@@ -5348,7 +5381,6 @@ sub verify_small_mark( $ ) {
# #
# Generate an appropriate -m [conn]mark match string for the contents of a MARK column # Generate an appropriate -m [conn]mark match string for the contents of a MARK column
# #
sub do_test ( $$ ) sub do_test ( $$ )
{ {
my ($testval, $mask) = @_; my ($testval, $mask) = @_;
@@ -5391,8 +5423,8 @@ sub do_ratelimit( $$ ) {
my @rates = split_list3 $rates, 'rate'; my @rates = split_list3 $rates, 'rate';
if ( @rates == 2 ) { if ( @rates == 2 ) {
$rates[0] = 's:' . $rates[0] unless $rates[0] =~ /^s:/; $rates[0] = 's:' . $rates[0] unless $rates[0] =~ /^s(?:\/\d+)?:/;
$rates[1] = 'd:' . $rates[1] unless $rates[1] =~ /^d:/; $rates[1] = 'd:' . $rates[1] unless $rates[1] =~ /^d(?:\/\d+)?:/;
} elsif ( @rates > 2 ) { } elsif ( @rates > 2 ) {
fatal error "Only two rates may be specified"; fatal error "Only two rates may be specified";
} }
@@ -5503,6 +5535,9 @@ sub do_connlimit( $ ) {
} }
} }
#
# Create a calendar match
#
sub do_time( $ ) { sub do_time( $ ) {
my ( $time ) = @_; my ( $time ) = @_;
@@ -5541,6 +5576,11 @@ sub do_time( $ ) {
$result; $result;
} }
#
# Resolve a user/group name to the appropriate numeric id. Only do the resolution
# if we are not compiling for export, since remote name->id mapping is likely to
# be different.
#
sub resolve_id( $$ ) { sub resolve_id( $$ ) {
my ( $id, $type ) = @_; my ( $id, $type ) = @_;
@@ -5604,8 +5644,6 @@ sub do_user( $ ) {
# #
# Create a "-m tos" match for the passed TOS # Create a "-m tos" match for the passed TOS
# #
# This helper is also used during tos file processing
#
sub decode_tos( $$ ) { sub decode_tos( $$ ) {
my ( $tos, $set ) = @_; my ( $tos, $set ) = @_;
@@ -6142,6 +6180,9 @@ sub get_interface_address( $;$ );
sub get_interface_gateway ( $;$$ ); sub get_interface_gateway ( $;$$ );
#
# Verify and record a runtime address variable
#
sub record_runtime_address( $$;$$ ) { sub record_runtime_address( $$;$$ ) {
my ( $addrtype, $interface, $protect, $provider ) = @_; my ( $addrtype, $interface, $protect, $provider ) = @_;
@@ -6632,6 +6673,9 @@ sub match_ipsec_in( $$ ) {
@match; @match;
} }
#
# Match Dest IPSEC
#
sub match_ipsec_out( $$ ) { sub match_ipsec_out( $$ ) {
my ( $zone , $hostref ) = @_; my ( $zone , $hostref ) = @_;
my @match; my @match;
@@ -6656,7 +6700,7 @@ sub match_ipsec_out( $$ ) {
} }
# #
# Handle a unidirectional IPSEC Options # Handle unidirectional IPSEC Options
# #
sub do_ipsec_options($$$) sub do_ipsec_options($$$)
{ {
@@ -6733,7 +6777,7 @@ sub do_ipsec($$) {
} }
# #
# Generate a log message # Generate a logging rule
# #
sub log_rule_limit( $$$$$$$$;$ ) { sub log_rule_limit( $$$$$$$$;$ ) {
my ($level, $chainref, $chn, $dispo, $limit, $tag, $command, $matches, $origin ) = @_; my ($level, $chainref, $chn, $dispo, $limit, $tag, $command, $matches, $origin ) = @_;
@@ -6929,6 +6973,9 @@ sub log_irule_limit( $$$$$$$$@ ) {
} }
} }
#
# Wrappers for the above that use the global default log limit
#
sub log_rule( $$$$ ) { sub log_rule( $$$$ ) {
my ( $level, $chainref, $disposition, $matches ) = @_; my ( $level, $chainref, $disposition, $matches ) = @_;
@@ -8516,7 +8563,7 @@ sub add_interface_options( $ ) {
# We may have to generate part of the input at run-time. The rules array in each chain # We may have to generate part of the input at run-time. The rules array in each chain
# table entry may contain both rules or shell source, determined by the contents of the 'mode' # table entry may contain both rules or shell source, determined by the contents of the 'mode'
# member. We alternate between writing the rules into the temporary file to be passed to # member. We alternate between writing the rules into the temporary file to be passed to
# iptables-restore (CAT_MODE) and and writing shell source into the generated script (CMD_MODE). # iptables-restore (CAT_MODE) and writing shell source into the generated script (CMD_MODE).
# #
# The following two functions are responsible for the mode transitions. # The following two functions are responsible for the mode transitions.
# #
@@ -8531,6 +8578,18 @@ sub enter_cmd_mode() {
$mode = CMD_MODE; $mode = CMD_MODE;
} }
#
# These two assure that we're in a particular mode
#
sub ensure_cat_mode() {
enter_cat_mode unless $mode == CAT_MODE;
}
sub ensure_cmd_mode() {
enter_cmd_mode unless $mode == CMD_MODE;
}
# #
# Emits the passed rule (input to iptables-restore) or command # Emits the passed rule (input to iptables-restore) or command
# #
@@ -8546,7 +8605,7 @@ sub emitr( $$ ) {
# #
# A rule # A rule
# #
enter_cat_mode unless $mode == CAT_MODE; ensure_cat_mode;
if ( $file_comments && ( my $origin = $ruleref->{origin} ) ) { if ( $file_comments && ( my $origin = $ruleref->{origin} ) ) {
emit_unindented '# ' . $origin; emit_unindented '# ' . $origin;
@@ -8557,7 +8616,7 @@ sub emitr( $$ ) {
# #
# A command # A command
# #
enter_cmd_mode unless $mode == CMD_MODE; ensure_cmd_mode;
if ( exists $ruleref->{cmd} ) { if ( exists $ruleref->{cmd} ) {
emit join( '', ' ' x $ruleref->{cmdlevel}, $ruleref->{cmd} ); emit join( '', ' ' x $ruleref->{cmdlevel}, $ruleref->{cmd} );
@@ -8590,6 +8649,14 @@ sub enter_cmd_mode1() {
$mode = CMD_MODE; $mode = CMD_MODE;
} }
sub ensure_cat_mode1() {
enter_cat_mode1 unless $mode == CAT_MODE;
}
sub ensure_cmd_mode1() {
enter_cmd_mode1 unless $mode == CMD_MODE;
}
sub emitr1( $$ ) { sub emitr1( $$ ) {
my ( $chainref, $ruleref ) = @_; my ( $chainref, $ruleref ) = @_;
@@ -8598,14 +8665,14 @@ sub emitr1( $$ ) {
# #
# A rule # A rule
# #
enter_cat_mode1 unless $mode == CAT_MODE; ensure_cat_mode1;
print format_rule( $chainref, $ruleref ) . "\n"; print format_rule( $chainref, $ruleref ) . "\n";
} else { } else {
# #
# A command # A command
# #
enter_cmd_mode1 unless $mode == CMD_MODE; ensure_cmd_mode1;
if ( exists $ruleref->{cmd} ) { if ( exists $ruleref->{cmd} ) {
emitstd $ruleref->{cmd}; emitstd $ruleref->{cmd};
@@ -9076,7 +9143,7 @@ sub create_nfobjects() {
} }
# #
# #
# Generate the netfilter input # Generate the input to ip[6]tables-restore or to 'ip[6]tables -R'
# #
sub create_netfilter_load( $ ) { sub create_netfilter_load( $ ) {
my $test = shift; my $test = shift;
@@ -9159,29 +9226,26 @@ sub create_netfilter_load( $ ) {
if ( $name =~ /^DOCKER/ ) { if ( $name =~ /^DOCKER/ ) {
if ( $name eq 'DOCKER' ) { if ( $name eq 'DOCKER' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' ); emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-ISOLATION' ) { } elsif ( $name eq 'DOCKER-ISOLATION' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' ); emit( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) { } elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
enter_cmd_mode; ensure_cmd_mode;
emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) ); emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-INGRESS' ) { } elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' ); emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-USER' ) { } elsif ( $name eq 'DOCKER-USER' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' ); emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
enter_cat_mode;
} else { } else {
ensure_cat_mode;
emit_unindented ":$name - [0:0]"; emit_unindented ":$name - [0:0]";
} }
} else { } else {
ensure_cat_mode;
emit_unindented ":$name - [0:0]"; emit_unindented ":$name - [0:0]";
} }
@@ -9199,17 +9263,19 @@ sub create_netfilter_load( $ ) {
# #
# Then emit the rules # Then emit the rules
# #
ensure_cat_mode;
for my $chainref ( @chains ) { for my $chainref ( @chains ) {
emitr( $chainref, $_ ) for @{$chainref->{rules}}; emitr( $chainref, $_ ) for @{$chainref->{rules}};
} }
# #
# Commit the changes to the table # Commit the changes to the table
# #
enter_cat_mode unless $mode == CAT_MODE; ensure_cat_mode;
emit_unindented 'COMMIT'; emit_unindented 'COMMIT';
} }
enter_cmd_mode; ensure_cmd_mode;
pop_indent, emit "fi\n"; pop_indent, emit "fi\n";
# #
@@ -9274,33 +9340,31 @@ sub preview_netfilter_load() {
assert( $chainref->{cmdlevel} == 0 , $name ); assert( $chainref->{cmdlevel} == 0 , $name );
if ( $name =~ /^DOCKER/ ) { if ( $name =~ /^DOCKER/ ) {
if ( $name eq 'DOCKER' ) { if ( $name eq 'DOCKER' ) {
enter_cmd_mode1; ensure_cmd_mode1;
print( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' ); print( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
print "\n"; print "\n";
} elsif ( $name eq 'DOCKER-ISOLATION' ) { } elsif ( $name eq 'DOCKER-ISOLATION' ) {
enter_cmd_mode1 unless $mode == CMD_MODE; ensure_cmd_mode1;
print( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' ); print( '[ "$g_dockernetwork" = One ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
print "\n"; print "\n";
enter_cat_mode1;
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) { } elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
enter_cmd_mode1 unless $mode == CMD_MODE; ensure_cmd_mode1;
emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) ); print( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
enter_cat_mode1; print "\n";
} elsif ( $name eq 'DOCKER-INGRESS' ) { } elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode1 unless $mode == CMD_MODE; ensure_cmd_mode1;
print( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' ); print( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
print "\n"; print "\n";
enter_cat_mode1;
} elsif ( $name eq 'DOCKER-USER' ) { } elsif ( $name eq 'DOCKER-USER' ) {
enter_cmd_mode1 unless $mode == CMD_MODE; ensure_cmd_mode1;
print( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' ); print( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
print "\n"; print "\n";
enter_cat_mode1; } else {
} else { ensure_cmd_mode1;
enter_cmd_mode1 unless $mode == CMD_MODE;
print( ":$name - [0:0]\n" ); print( ":$name - [0:0]\n" );
} }
} else { } else {
ensure_cat_mode1;
print( ":$name - [0:0]\n" ); print( ":$name - [0:0]\n" );
} }
@@ -9310,13 +9374,15 @@ sub preview_netfilter_load() {
# #
# Then emit the rules # Then emit the rules
# #
ensure_cat_mode1;
for my $chainref ( @chains ) { for my $chainref ( @chains ) {
emitr1($chainref, $_ ) for @{$chainref->{rules}}; emitr1($chainref, $_ ) for @{$chainref->{rules}};
} }
# #
# Commit the changes to the table # Commit the changes to the table
# #
enter_cat_mode1 unless $mode == CAT_MODE; ensure_cat_mode1;
print "COMMIT\n"; print "COMMIT\n";
} }
@@ -9376,29 +9442,26 @@ sub create_stop_load( $ ) {
assert( $chainref->{cmdlevel} == 0 , $name ); assert( $chainref->{cmdlevel} == 0 , $name );
if ( $name =~ /^DOCKER/ ) { if ( $name =~ /^DOCKER/ ) {
if ( $name eq 'DOCKER' ) { if ( $name eq 'DOCKER' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' ); emit( '[ -n "$g_docker" ] && echo ":DOCKER - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-ISOLATION' ) { } elsif ( $name eq 'DOCKER-ISOLATION' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' ); emit( '[ -n "$g_dockernetwork" ] && echo ":DOCKER-ISOLATION - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name =~ /^DOCKER-ISOLATION-/ ) { } elsif ( $name =~ /^DOCKER-ISOLATION-/ ) {
enter_cmd_mode; ensure_cmd_mode;
emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) ); emit( qq([ "\$g_dockernetwork" = Two ] && echo ":$name - [0:0]" >&3) );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-INGRESS' ) { } elsif ( $name eq 'DOCKER-INGRESS' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' ); emit( '[ -n "$g_dockeringress" ] && echo ":DOCKER-INGRESS - [0:0]" >&3' );
enter_cat_mode;
} elsif ( $name eq 'DOCKER-USER' ) { } elsif ( $name eq 'DOCKER-USER' ) {
enter_cmd_mode; ensure_cmd_mode;
emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' ); emit( '[ -n "$g_dockeruser" ] && echo ":DOCKER-USER - [0:0]" >&3' );
enter_cat_mode;
} else { } else {
ensure_cat_mode;
emit_unindented ":$name - [0:0]"; emit_unindented ":$name - [0:0]";
} }
} else { } else {
ensure_cat_mode;
emit_unindented ":$name - [0:0]"; emit_unindented ":$name - [0:0]";
} }
@@ -9408,6 +9471,8 @@ sub create_stop_load( $ ) {
# #
# Then emit the rules # Then emit the rules
# #
ensure_cat_mode;
for my $chainref ( @chains ) { for my $chainref ( @chains ) {
emitr( $chainref, $_ ) for @{$chainref->{rules}}; emitr( $chainref, $_ ) for @{$chainref->{rules}};
} }

View File

@@ -4,7 +4,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -47,13 +47,13 @@ our @EXPORT = qw( compiler );
our @EXPORT_OK = qw( $export ); our @EXPORT_OK = qw( $export );
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
our $export; our $export; # True when compiling for export
our $test; our $test; # True when running regression tests
our $family; our $family; # IP address family (4 or 6)
our $have_arptables; our $have_arptables; # True if we have arptables rules
# #
# Initilize the package-globals in the other modules # Initilize the package-globals in the other modules
@@ -384,7 +384,7 @@ sub generate_script_3() {
save_progress_message 'Initializing...'; save_progress_message 'Initializing...';
if ( $export || $config{EXPORTMODULES} ) { if ( $export || $config{EXPORTMODULES} ) {
my $fn = find_file( $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules' ); my $fn = find_file( 'helpers' );
if ( -f $fn && ( $config{EXPORTMODULES} || ( $export && ! $fn =~ "^$globals{SHAREDIR}/" ) ) ) { if ( -f $fn && ( $config{EXPORTMODULES} || ( $export && ! $fn =~ "^$globals{SHAREDIR}/" ) ) ) {
emit 'echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir'; emit 'echo MODULESDIR=\"$MODULESDIR\" > ${VARDIR}/.modulesdir';

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -396,7 +396,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
# #
# Config options and global settings that are to be copied to output script # Config options and global settings that are to be copied to output script
# #
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/; our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
# #
# From parsing the capabilities file or detecting capabilities # From parsing the capabilities file or detecting capabilities
# #
@@ -523,13 +523,17 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
CAPVERSION => 'Capability Version', CAPVERSION => 'Capability Version',
KERNELVERSION => 'Kernel Version', KERNELVERSION => 'Kernel Version',
); );
#
# Keeps track of which capabilities were used or required - Key is capability name
#
our %used; our %used;
use constant { use constant {
USED => 1, USED => 1,
REQUIRED => 2 }; REQUIRED => 2 };
#
# Common Protocols
#
use constant { use constant {
ICMP => 1, ICMP => 1,
TCP => 6, TCP => 6,
@@ -541,7 +545,7 @@ use constant {
UDPLITE => 136, UDPLITE => 136,
}; };
# #
# Optimization masks # Optimization masks (OPTIMIZE option)
# #
use constant { use constant {
OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains() OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains()
@@ -550,7 +554,9 @@ use constant {
OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1 OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1
OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories. OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories.
}; };
#
# Map helpers to protocols
#
our %helpers = ( amanda => UDP, our %helpers = ( amanda => UDP,
ftp => TCP, ftp => TCP,
irc => TCP, irc => TCP,
@@ -625,7 +631,7 @@ our %config_files = ( #accounting => 1,
# #
our @auditoptions = qw( BLACKLIST_DISPOSITION MACLIST_DISPOSITION TCP_FLAGS_DISPOSITION ); our @auditoptions = qw( BLACKLIST_DISPOSITION MACLIST_DISPOSITION TCP_FLAGS_DISPOSITION );
# #
# Directories to search for configuration files # Directories to search for configuration files (CONFIG_PATH option)
# #
our @config_path; our @config_path;
# #
@@ -648,10 +654,12 @@ our %compiler_params;
# Action parameters # Action parameters
# #
our %actparams; our %actparams;
our $parmsmodified; our $parmsmodified; # True of the current action has modified its parameters
our $usedcaller; our $usedcaller; # True if $CALLER has been acceseed in the current action
our $inline_matches; our $inline_matches; # Inline matches from the current rule
#
# File handling
#
our $currentline; # Current config file line image our $currentline; # Current config file line image
our $rawcurrentline; # Current config file line with no variable expansion our $rawcurrentline; # Current config file line with no variable expansion
our $currentfile; # File handle reference our $currentfile; # File handle reference
@@ -669,12 +677,14 @@ our $comments_allowed; # True if [?]COMMENT is allowed in the current file
our $nocomment; # When true, ignore [?]COMMENT in the current file our $nocomment; # When true, ignore [?]COMMENT in the current file
our $sr_comment; # When true, $comment should only be applied to the current rule our $sr_comment; # When true, $comment should only be applied to the current rule
our $warningcount; # Used to suppress duplicate warnings about missing COMMENT support our $warningcount; # Used to suppress duplicate warnings about missing COMMENT support
our $ulogcount; # Used to suppress duplicate warnings about ULOG support
our $directive_callback; # Function to call in compiler_directive our $directive_callback; # Function to call in compiler_directive
our $shorewall_dir; # Shorewall Directory; if non-empty, search here first for files. our $shorewall_dir; # Shorewall Directory; if non-empty, search here first for files.
our $debug; # Global debugging flag our $debug; # Global debugging flag
our $confess; # If true, use Carp to report errors with stack trace. our $confess; # If true, use Carp to report errors with stack trace.
our $update; # True if this is an update
our $family; # Protocol family (4 or 6) our $family; # Protocol family (4 or 6)
our $export; # True when compiling for export our $export; # True when compiling for export
@@ -722,18 +732,19 @@ our %converted = (
# #
# Eliminated options # Eliminated options
# #
our %eliminated = ( LOGRATE => 1, our %eliminated = ( LOGRATE => 1,
LOGBURST => 1, LOGBURST => 1,
EXPORTPARAMS => 1, EXPORTPARAMS => 1,
LEGACY_FASTSTART => 1, LEGACY_FASTSTART => 1,
IPSECFILE => 1, IPSECFILE => 1,
WIDE_TC_MARKS => 1, WIDE_TC_MARKS => 1,
HIGH_ROUTE_MARKS => 1, HIGH_ROUTE_MARKS => 1,
BLACKLISTNEWONLY => 1, BLACKLISTNEWONLY => 1,
CHAIN_SCRIPTS => 1, CHAIN_SCRIPTS => 1,
MODULE_SUFFIX => 1, MODULE_SUFFIX => 1,
MAPOLDACTIONS => 1, MAPOLDACTIONS => 1,
INLINE_MATCHES => 1, INLINE_MATCHES => 1,
LOAD_HELPERS_ONLY => 1,
); );
# #
# Variables involved in ?IF, ?ELSE ?ENDIF processing # Variables involved in ?IF, ?ELSE ?ENDIF processing
@@ -747,10 +758,11 @@ our $ifstack;
# [0] - Keyword (IF, ELSEIF, ELSE or ENDIF) # [0] - Keyword (IF, ELSEIF, ELSE or ENDIF)
# [1] - True if the outermost IF evaluated to false # [1] - True if the outermost IF evaluated to false
# [2] - True if the the last unterminated IF evaluated to false # [2] - True if the the last unterminated IF evaluated to false
# [3] = The line number of the directive
# #
# From .shorewallrc # From .shorewallrc
# #
our ( %shorewallrc, %shorewallrc1 ); our ( %shorewallrc, %shorewallrc1 ); # Shorewallrc setting from local system and from remote firewall respectively
# #
# read_a_line options # read_a_line options
# #
@@ -828,6 +840,7 @@ sub initialize( $;$$$) {
$comment = ''; $comment = '';
$sr_comment = ''; $sr_comment = '';
$warningcount = 0; $warningcount = 0;
$ulogcount = 0;
# #
# Misc Globals # Misc Globals
# #
@@ -969,7 +982,6 @@ sub initialize( $;$$$) {
OPTIMIZE_ACCOUNTING => undef, OPTIMIZE_ACCOUNTING => undef,
ACCOUNTING_TABLE => undef, ACCOUNTING_TABLE => undef,
DYNAMIC_BLACKLIST => undef, DYNAMIC_BLACKLIST => undef,
LOAD_HELPERS_ONLY => undef,
REQUIRE_INTERFACE => undef, REQUIRE_INTERFACE => undef,
FORWARD_CLEAR_MARK => undef, FORWARD_CLEAR_MARK => undef,
COMPLETE => undef, COMPLETE => undef,
@@ -1180,6 +1192,7 @@ sub initialize( $;$$$) {
$debug = 0; $debug = 0;
$confess = 0; $confess = 0;
$update = 0;
%params = (); %params = ();
@@ -1291,7 +1304,7 @@ sub initialize( $;$$$) {
$compiletime =~ s/ +/ /g; $compiletime =~ s/ +/ /g;
} }
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my @moabbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
sub add_ipset( $ ) { sub add_ipset( $ ) {
$ipsets{$_[0]} = 1; $ipsets{$_[0]} = 1;
@@ -1391,7 +1404,7 @@ sub info_message
if ( $log ) { if ( $log ) {
@localtime = localtime; @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
} }
if ( $confess ) { if ( $confess ) {
@@ -1419,7 +1432,7 @@ sub warning_message
if ( $log ) { if ( $log ) {
@localtime = localtime; @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
} }
if ( $confess ) { if ( $confess ) {
@@ -1544,7 +1557,7 @@ sub fatal_error {
if ( $log ) { if ( $log ) {
our @localtime = localtime; our @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
if ( $confess ) { if ( $confess ) {
print $log longmess( " ERROR: @_$currentlineinfo\n" ); print $log longmess( " ERROR: @_$currentlineinfo\n" );
@@ -1567,6 +1580,9 @@ sub fatal_error {
} }
} }
#
# This one is used for reporting syntax errors in embedded Perl code
#
sub fatal_error1 { sub fatal_error1 {
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
@@ -1574,7 +1590,7 @@ sub fatal_error1 {
if ( $log ) { if ( $log ) {
our @localtime = localtime; our @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
if ( $debug ) { if ( $debug ) {
print $log longmess( " ERROR: @_\n" ); print $log longmess( " ERROR: @_\n" );
@@ -1684,7 +1700,7 @@ sub emit {
if ( $script || $debug ) { if ( $script || $debug ) {
# #
# 'compile' as opposed to 'check' # 'compile' (as opposed to 'check') or debugging (CLI 'trace' command)
# #
for ( @_ ) { for ( @_ ) {
unless ( /^\s*$/ ) { unless ( /^\s*$/ ) {
@@ -1845,12 +1861,15 @@ sub progress_message {
@localtime = localtime unless $havelocaltime; @localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "${leading}${line}\n"; print $log "${leading}${line}\n";
} }
} }
} }
#
# This one doesn't compress out superfluous white space
#
sub progress_message_nocompress { sub progress_message_nocompress {
my $havelocaltime = 0; my $havelocaltime = 0;
@@ -1864,7 +1883,7 @@ sub progress_message_nocompress {
@localtime = localtime unless $havelocaltime; @localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n"; print $log "@_\n";
} }
} }
@@ -1885,7 +1904,7 @@ sub progress_message2 {
@localtime = localtime unless $havelocaltime; @localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n"; print $log "@_\n";
} }
} }
@@ -1906,7 +1925,7 @@ sub progress_message3 {
@localtime = localtime unless $havelocaltime; @localtime = localtime unless $havelocaltime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log "@_\n"; print $log "@_\n";
} }
} }
@@ -2077,7 +2096,7 @@ sub set_debug( $$ ) {
# #
sub find_file($) sub find_file($)
{ {
my ( $filename, $nosearch ) = @_; my ( $filename ) = @_;
return $filename if $filename =~ '/'; return $filename if $filename =~ '/';
@@ -2094,8 +2113,12 @@ sub find_file($)
"$config_path[0]$filename"; "$config_path[0]$filename";
} }
#
# Search the CONFIG_PATH for a file that is writable. Ignore directories where sample/default files are installed,
# because users have a bad habit of including those in the CONFIG_PATH
#
sub find_writable_file($) { sub find_writable_file($) {
my ( $filename, $nosearch ) = @_; my ( $filename ) = @_;
return $filename if $filename =~ '/'; return $filename if $filename =~ '/';
@@ -2117,6 +2140,9 @@ sub supplied( $ ) {
defined $val && $val ne ''; defined $val && $val ne '';
} }
#
# This one is used for determining if an action argument has been passed (excludes '-')
#
sub passed( $ ) { sub passed( $ ) {
my $val = shift; my $val = shift;
@@ -2135,7 +2161,7 @@ sub split_list( $$;$ ) {
} }
# #
# This version handles parenthetical list elements with embedded commas. It removes the parentheses # This version handles parenthetical list elements containing embedded commas. It removes the parentheses
# #
sub split_list1( $$;$ ) { sub split_list1( $$;$ ) {
my ($list, $type, $keepparens ) = @_; my ($list, $type, $keepparens ) = @_;
@@ -2519,7 +2545,7 @@ sub split_line2( $$;$$$ ) {
} }
# #
# Same as above, only it splits the raw current line # Same as above, only it splits the raw current line (line prior to variable expansion)
# #
sub split_rawline2( $$;$$$ ) { sub split_rawline2( $$;$$$ ) {
my $savecurrentline = $currentline; my $savecurrentline = $currentline;
@@ -2627,6 +2653,7 @@ sub do_open_file( $ ) {
# - Maximum value allowed in ?FORMAT directives # - Maximum value allowed in ?FORMAT directives
# - ?COMMENT allowed in this file # - ?COMMENT allowed in this file
# - Ignore ?COMMENT in ths file # - Ignore ?COMMENT in ths file
# - Default file format
# #
sub open_file( $;$$$$ ) { sub open_file( $;$$$$ ) {
my ( $fname, $mf, $ca, $nc, $cf ) = @_; my ( $fname, $mf, $ca, $nc, $cf ) = @_;
@@ -2719,7 +2746,7 @@ sub clear_currentfilename() {
} }
# #
# Process an ?IF, ?ELSIF, ?ELSE or ?END directive # Utility functions for processing compiler directives
# #
# #
@@ -2746,7 +2773,7 @@ sub directive_warning( $$$$ ) {
if ( $log ) { if ( $log ) {
@localtime = localtime; @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log " WARNING: $_[0]\n"; print $log " WARNING: $_[0]\n";
} }
@@ -2771,7 +2798,7 @@ sub directive_info( $$$$ ) {
if ( $log ) { if ( $log ) {
@localtime = localtime; @localtime = localtime;
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; printf $log '%s %2d %02d:%02d:%02d ', $moabbr[$localtime[4]], @localtime[3,2,1,0];
print $log " INFO: $_[0]\n"; print $log " INFO: $_[0]\n";
} }
@@ -3523,7 +3550,7 @@ sub shorewall {
# We do this processing in read_a_line() rather than in the higher-level routines because # We do this processing in read_a_line() rather than in the higher-level routines because
# Embedded Shell/Perl scripts are processed out of read_a_line(). If we were to defer announcement # Embedded Shell/Perl scripts are processed out of read_a_line(). If we were to defer announcement
# until we get back to the caller of read_a_line(), we could issue error messages about parsing and # until we get back to the caller of read_a_line(), we could issue error messages about parsing and
# running scripts in the file before we'd even indicated that we are processing it. # running scripts in the file before we'd even reported that we are processing it.
# #
sub first_entry( $ ) { sub first_entry( $ ) {
$first_entry = shift; $first_entry = shift;
@@ -3700,6 +3727,7 @@ sub push_action_params( $$$$$$ ) {
# Return: # Return:
# 1 if the popped parameters were modified # 1 if the popped parameters were modified
# 2 if the action used @CALLER # 2 if the action used @CALLER
# 3 if both
# #
sub pop_action_params( $ ) { sub pop_action_params( $ ) {
my $oldparms = shift; my $oldparms = shift;
@@ -3710,6 +3738,10 @@ sub pop_action_params( $ ) {
$return; $return;
} }
#
# This is called when a DEFAULTS line is found in an action body. It supplies default values
# for those paramaters that were not passed, or that were passed as '-'.
#
sub default_action_params { sub default_action_params {
my $action = shift; my $action = shift;
my ( $val, $i ); my ( $val, $i );
@@ -3723,6 +3755,9 @@ sub default_action_params {
fatal_error "Too Many arguments to action $action" if defined $actparams{$i}; fatal_error "Too Many arguments to action $action" if defined $actparams{$i};
} }
#
# This function allows embedded Perl in actions to retreive the action paramaters
#
sub get_action_params( $ ) { sub get_action_params( $ ) {
my $num = shift; my $num = shift;
@@ -3738,6 +3773,9 @@ sub get_action_params( $ ) {
@return; @return;
} }
#
# Helper for A_* actions
#
sub setup_audit_action( $ ) { sub setup_audit_action( $ ) {
my ( $action ) = @_; my ( $action ) = @_;
@@ -3757,26 +3795,44 @@ sub get_action_logging() {
@actparams{ 'loglevel', 'logtag' }; @actparams{ 'loglevel', 'logtag' };
} }
#
# Allow embedded Perl in Actions to get the name of the action chain
#
sub get_action_chain() { sub get_action_chain() {
$actparams{0}; $actparams{0};
} }
#
# Get the action name from an action file
#
sub get_action_chain_name() { sub get_action_chain_name() {
$actparams{chain}; $actparams{chain};
} }
#
# This allows an action to make subsequent log messages refer to the invoker of the action rather than the
# action itself
#
sub set_action_name_to_caller() { sub set_action_name_to_caller() {
$actparams{chain} = $actparams{caller}; $actparams{chain} = $actparams{caller};
} }
#
# Get the current action's disposition
#
sub get_action_disposition() { sub get_action_disposition() {
$actparams{disposition}; $actparams{disposition};
} }
#
# Set the current action disposition for subsequent logging
#
sub set_action_disposition($) { sub set_action_disposition($) {
$actparams{disposition} = $_[0]; $actparams{disposition} = $_[0];
} }
#
# Alter the value of one of the current actions parameters
#
sub set_action_param( $$ ) { sub set_action_param( $$ ) {
my $i = shift; my $i = shift;
@@ -3843,6 +3899,9 @@ sub expand_variables( \$ ) {
} }
} }
#
# Expand variables from shorewallrc in the current passed line
#
sub expand_shorewallrc_variables( \$ ) { sub expand_shorewallrc_variables( \$ ) {
my ( $lineref, $count ) = ( $_[0], 0 ); my ( $lineref, $count ) = ( $_[0], 0 );
# $1 $2 $3 - $4 # $1 $2 $3 - $4
@@ -3886,7 +3945,7 @@ sub handle_first_entry() {
# - Handle embedded SHELL and PERL scripts # - Handle embedded SHELL and PERL scripts
# - Expand shell variables from %params and %ENV. # - Expand shell variables from %params and %ENV.
# - Handle INCLUDE <filename> # - Handle INCLUDE <filename>
# - Handle ?IF, ?ELSE, ?ENDIF # - Handle ?SECTION
# #
sub read_a_line($) { sub read_a_line($) {
@@ -3964,9 +4023,9 @@ sub read_a_line($) {
# #
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
# #
# Save Raw Image # Save Raw Image if we are updating
# #
$rawcurrentline = $currentline; $rawcurrentline = $currentline if $update;
# #
# Expand Shell Variables using %params and %actparams # Expand Shell Variables using %params and %actparams
# #
@@ -4009,6 +4068,9 @@ sub read_a_line($) {
} }
} }
#
# Process the passed shorewallrc file, populating %shorewallrc
#
sub process_shorewallrc( $$ ) { sub process_shorewallrc( $$ ) {
my ( $shorewallrc , $product ) = @_; my ( $shorewallrc , $product ) = @_;
@@ -4029,6 +4091,12 @@ sub process_shorewallrc( $$ ) {
fatal_error "Failed to open $shorewallrc: $!"; fatal_error "Failed to open $shorewallrc: $!";
} }
#
# Older files may contain VARDIR= rather than VARLIB= to specify the directory
# where each product maintains its own state directory. This was confusing,
# because in the shell context, VARDIR points to the current product's state
# directory.
#
if ( supplied $shorewallrc{VARDIR} ) { if ( supplied $shorewallrc{VARDIR} ) {
if ( ! supplied $shorewallrc{VARLIB} ) { if ( ! supplied $shorewallrc{VARLIB} ) {
$shorewallrc{VARLIB} = $shorewallrc{VARDIR}; $shorewallrc{VARLIB} = $shorewallrc{VARDIR};
@@ -4091,12 +4159,19 @@ sub default_yes_no ( $$;$ ) {
$result; $result;
} }
#
# This one is used for options that are supported by IPv4 but not IPv6. It issues a
# warning message if the option is specified in shorewall6.conf.
#
sub default_yes_no_ipv4 ( $$ ) { sub default_yes_no_ipv4 ( $$ ) {
my ( $var, $val ) = @_; my ( $var, $val ) = @_;
default_yes_no( $var, $val ); default_yes_no( $var, $val );
warning_message "$var=Yes is ignored for IPv6" if $family == F_IPV6 && $config{$var}; warning_message "$var=Yes is ignored for IPv6" if $family == F_IPV6 && $config{$var};
} }
#
# This function handles options that have a numeric value.
#
sub numeric_option( $$$ ) { sub numeric_option( $$$ ) {
my ( $option, $default, $min ) = @_; my ( $option, $default, $min ) = @_;
@@ -4114,6 +4189,9 @@ sub numeric_option( $$$ ) {
$config{$option} = $val; $config{$option} = $val;
} }
#
# Returns a 32-bit value with the low order n bits set, where n is the passed argument.
#
sub make_mask( $ ) { sub make_mask( $ ) {
0xffffffff >> ( 32 - $_[0] ); 0xffffffff >> ( 32 - $_[0] );
} }
@@ -4214,6 +4292,10 @@ sub validate_level( $;$ ) {
if ( $value =~ /^(NFLOG|ULOG)$/ ) { if ( $value =~ /^(NFLOG|ULOG)$/ ) {
my $olevel = $value; my $olevel = $value;
if ( $value eq 'ULOG' ) {
warning_message "ULOG is deprecated in favor of NFLOG. Support for ULOG will be removed in a future release" unless $ulogcount++;
}
if ( $qualifier =~ /^[(](.*)[)]$/ ) { if ( $qualifier =~ /^[(](.*)[)]$/ ) {
my @options = split /,/, $1; my @options = split /,/, $1;
my $prefix = lc $olevel; my $prefix = lc $olevel;
@@ -4289,7 +4371,7 @@ sub default_log_level( $$ ) {
} }
# #
# Check a tri-valued variable # Check a tri-valued option ("on", "of" and "keep")
# #
sub check_trivalue( $$ ) { sub check_trivalue( $$ ) {
my ( $var, $default) = @_; my ( $var, $default) = @_;
@@ -4371,7 +4453,7 @@ sub load_kernel_modules( ) {
push @moduledirectories, $_ if -d $_; push @moduledirectories, $_ if -d $_;
} }
if ( $moduleloader && @moduledirectories && open_file( $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules' ) ) { if ( $moduleloader && @moduledirectories && open_file( 'helpers' ) ) {
my %loadedmodules; my %loadedmodules;
$loadedmodules{$_}++ for split_list( $config{DONT_LOAD}, 'module' ); $loadedmodules{$_}++ for split_list( $config{DONT_LOAD}, 'module' );
@@ -4425,7 +4507,8 @@ sub determine_kernelversion() {
} }
# #
# Capability Reporting and detection. # Capability Reporting and detection. Each of the following functions detect the
# availability of the related capability.
# #
sub Nat_Enabled() { sub Nat_Enabled() {
qt1( "$iptables $iptablesw -t nat -L -n" ); qt1( "$iptables $iptablesw -t nat -L -n" );
@@ -5140,7 +5223,7 @@ sub have_capability( $;$ ) {
$setting = $capabilities{ $capability } = detect_capability( $capability ) unless defined $setting; $setting = $capabilities{ $capability } = detect_capability( $capability ) unless defined $setting;
$used{$capability} = $required ? 2 : 1 if $setting; $used{$capability} = $required ? REQUIRED : USED if $setting;
$setting; $setting;
} }
@@ -5169,111 +5252,6 @@ sub determine_capabilities() {
qt1( "$iptables $iptablesw -A $sillyname -m state --state ESTABLISHED,RELATED -j ACCEPT");; qt1( "$iptables $iptablesw -A $sillyname -m state --state ESTABLISHED,RELATED -j ACCEPT");;
$globals{KLUDGEFREE} = $capabilities{KLUDGEFREE} = detect_capability 'KLUDGEFREE'; $globals{KLUDGEFREE} = $capabilities{KLUDGEFREE} = detect_capability 'KLUDGEFREE';
unless ( $config{ LOAD_HELPERS_ONLY } ) {
#
# Using 'detect_capability()' is a bit less efficient than calling the individual detection
# functions but it ensures that %detect_capability is initialized properly.
#
$capabilities{NAT_ENABLED} = detect_capability( 'NAT_ENABLED' );
$capabilities{PERSISTENT_SNAT} = detect_capability( 'PERSISTENT_SNAT' );
$capabilities{NAT_INPUT_CHAIN} = detect_capability( 'NAT_INPUT_CHAIN' );
$capabilities{MANGLE_ENABLED} = detect_capability( 'MANGLE_ENABLED' );
if ( $capabilities{CONNTRACK_MATCH} = detect_capability( 'CONNTRACK_MATCH' ) ) {
$capabilities{NEW_CONNTRACK_MATCH} = detect_capability( 'NEW_CONNTRACK_MATCH' );
$capabilities{OLD_CONNTRACK_MATCH} = detect_capability( 'OLD_CONNTRACK_MATCH' );
} else {
$capabilities{NEW_CONNTRACK_MATCH} = '';
$capabilities{OLD_CONNTRACK_MATCH} = '';
}
$capabilities{ MULTIPORT } = detect_capability( 'MULTIPORT' );
$capabilities{XMULTIPORT} = detect_capability( 'XMULTIPORT' );
$capabilities{EMULTIPORT} = detect_capability( 'EMULTIPORT' );
$capabilities{POLICY_MATCH} = detect_capability( 'POLICY_MATCH' );
if ( $capabilities{PHYSDEV_MATCH} = detect_capability( 'PHYSDEV_MATCH' ) ) {
$capabilities{PHYSDEV_BRIDGE} = detect_capability( 'PHYSDEV_BRIDGE' );
} else {
$capabilities{PHYSDEV_BRIDGE} = '';
}
$capabilities{IPRANGE_MATCH} = detect_capability( 'IPRANGE_MATCH' );
$capabilities{RECENT_MATCH} = detect_capability( 'RECENT_MATCH' );
$capabilities{REAP_OPTION} = detect_capability( 'REAP_OPTION' );
$capabilities{OWNER_MATCH} = detect_capability( 'OWNER_MATCH' );
$capabilities{OWNER_NAME_MATCH}
= detect_capability( 'OWNER_NAME_MATCH' );
$capabilities{CONNMARK_MATCH} = detect_capability( 'CONNMARK_MATCH' );
$capabilities{XCONNMARK_MATCH} = detect_capability( 'XCONNMARK_MATCH' );
$capabilities{IPP2P_MATCH} = detect_capability( 'IPP2P_MATCH' );
$capabilities{OLD_IPP2P_MATCH} = detect_capability( 'OLD_IPP2P_MATCH' );
$capabilities{LENGTH_MATCH} = detect_capability( 'LENGTH_MATCH' );
$capabilities{ENHANCED_REJECT} = detect_capability( 'ENHANCED_REJECT' );
$capabilities{COMMENTS} = detect_capability( 'COMMENTS' );
$capabilities{OLD_HL_MATCH} = detect_capability( 'OLD_HL_MATCH' );
$capabilities{HASHLIMIT_MATCH} = detect_capability( 'HASHLIMIT_MATCH' );
$capabilities{MARK} = detect_capability( 'MARK' );
$capabilities{XMARK} = detect_capability( 'XMARK' );
$capabilities{EXMARK} = detect_capability( 'EXMARK' );
$capabilities{CONNMARK} = detect_capability( 'CONNMARK' );
$capabilities{XCONNMARK} = detect_capability( 'XCONNMARK' );
$capabilities{CLASSIFY_TARGET} = detect_capability( 'CLASSIFY_TARGET' );
$capabilities{IPMARK_TARGET} = detect_capability( 'IPMARK_TARGET' );
$capabilities{TPROXY_TARGET} = detect_capability( 'TPROXY_TARGET' );
$capabilities{MANGLE_FORWARD} = detect_capability( 'MANGLE_FORWARD' );
$capabilities{RAW_TABLE} = detect_capability( 'RAW_TABLE' );
$capabilities{IPSET_MATCH} = detect_capability( 'IPSET_MATCH' );
$capabilities{ADDRTYPE} = detect_capability( 'ADDRTYPE' );
$capabilities{TCPMSS_MATCH} = detect_capability( 'TCPMSS_MATCH' );
$capabilities{NFQUEUE_TARGET} = detect_capability( 'NFQUEUE_TARGET' );
$capabilities{REALM_MATCH} = detect_capability( 'REALM_MATCH' );
$capabilities{CONNLIMIT_MATCH} = detect_capability( 'CONNLIMIT_MATCH' );
$capabilities{TIME_MATCH} = detect_capability( 'TIME_MATCH' );
$capabilities{GOTO_TARGET} = detect_capability( 'GOTO_TARGET' );
$capabilities{LOG_TARGET} = detect_capability( 'LOG_TARGET' );
$capabilities{ULOG_TARGET} = detect_capability( 'ULOG_TARGET' );
$capabilities{NFLOG_TARGET} = detect_capability( 'NFLOG_TARGET' );
$capabilities{LOGMARK_TARGET} = detect_capability( 'LOGMARK_TARGET' );
$capabilities{FLOW_FILTER} = detect_capability( 'FLOW_FILTER' );
$capabilities{FWMARK_RT_MASK} = detect_capability( 'FWMARK_RT_MASK' );
$capabilities{MARK_ANYWHERE} = detect_capability( 'MARK_ANYWHERE' );
$capabilities{ACCOUNT_TARGET} = detect_capability( 'ACCOUNT_TARGET' );
$capabilities{HEADER_MATCH} = detect_capability( 'HEADER_MATCH' );
$capabilities{AUDIT_TARGET} = detect_capability( 'AUDIT_TARGET' );
$capabilities{IPSET_V5} = detect_capability( 'IPSET_V5' );
$capabilities{CONDITION_MATCH} = detect_capability( 'CONDITION_MATCH' );
$capabilities{IPTABLES_S} = detect_capability( 'IPTABLES_S' );
$capabilities{BASIC_FILTER} = detect_capability( 'BASIC_FILTER' );
$capabilities{BASIC_EMATCH} = detect_capability( 'BASIC_EMATCH' );
$capabilities{CT_TARGET} = detect_capability( 'CT_TARGET' );
$capabilities{STATISTIC_MATCH} = detect_capability( 'STATISTIC_MATCH' );
$capabilities{IMQ_TARGET} = detect_capability( 'IMQ_TARGET' );
$capabilities{DSCP_MATCH} = detect_capability( 'DSCP_MATCH' );
$capabilities{DSCP_TARGET} = detect_capability( 'DSCP_TARGET' );
$capabilities{GEOIP_MATCH} = detect_capability( 'GEOIP_MATCH' );
$capabilities{RPFILTER_MATCH} = detect_capability( 'RPFILTER_MATCH' );
$capabilities{NFACCT_MATCH} = detect_capability( 'NFACCT_MATCH' );
$capabilities{CHECKSUM_TARGET} = detect_capability( 'CHECKSUM_TARGET' );
$capabilities{ARPTABLESJF} = detect_capability( 'ARPTABLESJF' );
$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' );
$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';
}
}
} }
# #
@@ -5337,6 +5315,9 @@ sub ensure_config_path() {
} }
if ( $shorewall_dir ) { if ( $shorewall_dir ) {
#
# A directory has been specified -- place it at the front of the CONFIG_PATH
#
$shorewall_dir = getcwd if $shorewall_dir =~ m|^(\./*)+$|; $shorewall_dir = getcwd if $shorewall_dir =~ m|^(\./*)+$|;
$shorewall_dir .= '/' unless $shorewall_dir =~ m|/$|; $shorewall_dir .= '/' unless $shorewall_dir =~ m|/$|;
unshift @config_path, $shorewall_dir if $shorewall_dir ne $config_path[0]; unshift @config_path, $shorewall_dir if $shorewall_dir ne $config_path[0];
@@ -5371,7 +5352,8 @@ sub conditional_quote( $ ) {
} }
# #
# Update the shorewall[6].conf file. Save the current file with a .bak suffix. # 'update' default values are sometimes different from the normal defaut value, to provide
# backward compatibility.
# #
sub update_default($$) { sub update_default($$) {
my ( $var, $val ) = @_; my ( $var, $val ) = @_;
@@ -5392,6 +5374,9 @@ sub transfer_permissions( $$ ) {
} }
} }
#
# Update the shorewall[6].conf file. Save the current file with a .bak suffix.
#
sub update_config_file( $ ) { sub update_config_file( $ ) {
my ( $annotate ) = @_; my ( $annotate ) = @_;
@@ -5608,8 +5593,8 @@ EOF
# #
# Small functions called by get_configuration. We separate them so profiling is more useful # Small functions called by get_configuration. We separate them so profiling is more useful
# #
sub process_shorewall_conf( $$ ) { sub process_shorewall_conf( $ ) {
my ( $update, $annotate ) = @_; my ( $annotate ) = @_;
my $file = find_file "$product.conf"; my $file = find_file "$product.conf";
my @vars; my @vars;
@@ -5790,7 +5775,7 @@ sub unsupported_yes_no_warning( $ ) {
} }
# #
# Process the params file # Process the params file. Actually processing is done by the 'getparams' program in $LIBEXECDIR/shorewall/.
# #
sub get_params( $ ) { sub get_params( $ ) {
my $export = $_[0]; my $export = $_[0];
@@ -5925,7 +5910,7 @@ sub get_params( $ ) {
# #
delete $params{$_}; delete $params{$_};
} else { } else {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' ) { unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' || $_ eq 'SW_LOGGERTAG' || $_ eq 'SW_CONFDIR' ) {
fatal_error "The variable name $_ is reserved and may not be set in the params file" fatal_error "The variable name $_ is reserved and may not be set in the params file"
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_}; if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
} }
@@ -6190,7 +6175,7 @@ sub convert_to_version_5_2() {
# #
sub get_configuration( $$$ ) { sub get_configuration( $$$ ) {
my ( $export, $update, $annotate ) = @_; ( my $export, $update, my $annotate ) = @_;
$globals{EXPORT} = $export; $globals{EXPORT} = $export;
@@ -6252,7 +6237,7 @@ sub get_configuration( $$$ ) {
get_params( $export ); get_params( $export );
process_shorewall_conf( $update, $annotate ); process_shorewall_conf( $annotate );
ensure_config_path; ensure_config_path;
@@ -6260,11 +6245,6 @@ sub get_configuration( $$$ ) {
unshift @INC, @config_path; unshift @INC, @config_path;
#
# get_capabilities requires that the true settings of these options be established
#
default_yes_no 'LOAD_HELPERS_ONLY' , 'Yes';
if ( ! $export && $> == 0 ) { if ( ! $export && $> == 0 ) {
get_capabilities($have_capabilities); get_capabilities($have_capabilities);
} }
@@ -6317,8 +6297,6 @@ sub get_configuration( $$$ ) {
$capabilities{$_} = 0 for grep /_HELPER/ , keys %capabilities; $capabilities{$_} = 0 for grep /_HELPER/ , keys %capabilities;
} }
report_capabilities unless $config{LOAD_HELPERS_ONLY};
# #
# Now initialize the used capabilities hash # Now initialize the used capabilities hash
# #
@@ -7056,8 +7034,6 @@ sub get_configuration( $$$ ) {
} }
convert_to_version_5_2 if $update; convert_to_version_5_2 if $update;
cleanup_iptables if $sillyname && ! $config{LOAD_HELPERS_ONLY};
} }
# #
@@ -7196,6 +7172,9 @@ sub generate_aux_config() {
finalize_aux_config; finalize_aux_config;
} }
#
# Generate a report of the fwmark layout
#
sub dump_mark_layout() { sub dump_mark_layout() {
sub dumpout( $$$$$ ) { sub dumpout( $$$$$ ) {
my ( $name, $bits, $min, $max, $mask ) = @_; my ( $name, $bits, $min, $max, $mask ) = @_;

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -66,6 +66,9 @@ sub initialize( $ ) {
$family = shift; $family = shift;
} }
#
# Warn that the tos file is no longer supported
#
sub process_tos() { sub process_tos() {
if ( my $fn = open_file 'tos' ) { if ( my $fn = open_file 'tos' ) {
@@ -145,6 +148,9 @@ sub setup_ecn()
} }
} }
#
# Add a logging rule followed by a jump
#
sub add_rule_pair( $$$$$ ) { sub add_rule_pair( $$$$$ ) {
my ($chainref , $predicate , $target , $level, $tag ) = @_; my ($chainref , $predicate , $target , $level, $tag ) = @_;
@@ -402,6 +408,9 @@ EOF
} }
} }
#
# Convert a routestopped file into an equivalent stoppedrules file
#
sub convert_routestopped() { sub convert_routestopped() {
if ( my $fn = open_file 'routestopped' ) { if ( my $fn = open_file 'routestopped' ) {
@@ -662,6 +671,9 @@ sub process_stoppedrules() {
$result; $result;
} }
#
# Generate the rules required when DOCKER=Yes
#
sub create_docker_rules() { sub create_docker_rules() {
add_commands( $nat_table->{PREROUTING} , '[ -n "$g_docker" ] && echo "-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER" >&3' ); add_commands( $nat_table->{PREROUTING} , '[ -n "$g_docker" ] && echo "-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER" >&3' );
@@ -703,6 +715,9 @@ sub create_docker_rules() {
sub setup_mss(); sub setup_mss();
#
# Add rules generated by .conf options and interface options
#
sub add_common_rules ( $ ) { sub add_common_rules ( $ ) {
my ( $upgrade ) = @_; my ( $upgrade ) = @_;
my $interface; my $interface;
@@ -1283,6 +1298,13 @@ my %maclist_targets = ( ACCEPT => { target => 'RETURN' , mangle => 1 } ,
REJECT => { target => 'reject' , mangle => 0 } , REJECT => { target => 'reject' , mangle => 0 } ,
DROP => { target => 'DROP' , mangle => 1 } ); DROP => { target => 'DROP' , mangle => 1 } );
#
# Create rules generated by the 'maclist' option and by entries in the maclist file.
#
# The function is called twice. The first call passes '1' and causes the maclist file
# to be processed. The second call passes '2' and generates the jumps for 'maclist'
# interfaces.
#
sub setup_mac_lists( $ ) { sub setup_mac_lists( $ ) {
my $phase = $_[0]; my $phase = $_[0];
@@ -1724,9 +1746,9 @@ sub add_interface_jumps {
add_ijump( $filter_table->{input_chain $bridge }, add_ijump( $filter_table->{input_chain $bridge },
j => $inputref , j => $inputref ,
imatch_source_dev( $interface, 1 ) imatch_source_dev( $interface, 1 )
) unless $input_jump_added{$interface} || ! use_input_chain $interface, $inputref; ) unless $input_jump_added{$interface} || ! use_interface_chain( $interface, 'use_input_chain' );
unless ( $output_jump_added{$interface} || ! use_output_chain $interface, $outputref ) { unless ( $output_jump_added{$interface} || ! use_interface_chain( $interface, 'use_output_chain') ) {
add_ijump( $filter_table->{output_chain $bridge} , add_ijump( $filter_table->{output_chain $bridge} ,
j => $outputref , j => $outputref ,
imatch_dest_dev( $interface, 1 ) ) imatch_dest_dev( $interface, 1 ) )
@@ -1735,10 +1757,10 @@ sub add_interface_jumps {
} else { } else {
add_ijump ( $filter_table->{FORWARD}, j => 'ACCEPT', imatch_source_dev( $interface) , imatch_dest_dev( $interface) ) unless $interfaceref->{nets} || ! $interfaceref->{options}{bridge}; add_ijump ( $filter_table->{FORWARD}, j => 'ACCEPT', imatch_source_dev( $interface) , imatch_dest_dev( $interface) ) unless $interfaceref->{nets} || ! $interfaceref->{options}{bridge};
add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++; add_ijump( $filter_table->{FORWARD} , j => $forwardref , imatch_source_dev( $interface ) ) if use_forward_chain( $interface, $forwardref ) && ! $forward_jump_added{$interface}++;
add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_input_chain( $interface, $inputref ) && ! $input_jump_added{$interface}++; add_ijump( $filter_table->{INPUT} , j => $inputref , imatch_source_dev( $interface ) ) if use_interface_chain( $interface, 'use_input_chain' ) && ! $input_jump_added{$interface}++;
if ( use_output_chain $interface, $outputref ) { if ( use_interface_chain( $interface, 'use_output_chain' ) ) {
add_ijump $filter_table->{OUTPUT} , j => $outputref , imatch_dest_dev( $interface ) unless get_interface_option( $interface, 'port' ) || $output_jump_added{$interface}++; add_ijump $filter_table->{OUTPUT} , j => $outputref , imatch_dest_dev( $interface ) unless get_interface_option( $interface, 'port' ) || $output_jump_added{$interface}++;
} }
} }
@@ -1927,7 +1949,7 @@ sub add_output_jumps( $$$$$$$$ ) {
my @ipsec_out_match = match_ipsec_out $zone , $hostref; my @ipsec_out_match = match_ipsec_out $zone , $hostref;
my @zone_interfaces = keys %{zone_interfaces( $zone )}; my @zone_interfaces = keys %{zone_interfaces( $zone )};
if ( @vservers || use_output_chain( $interface, $interfacechainref ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) { if ( @vservers || use_interface_chain( $interface, 'use_output_chain' ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) {
# #
# - There are vserver zones (so OUTPUT will have multiple source; or # - There are vserver zones (so OUTPUT will have multiple source; or
# - We must use the interface output chain; or # - We must use the interface output chain; or
@@ -2061,7 +2083,7 @@ sub add_input_jumps( $$$$$$$$$ ) {
my @source = imatch_source_net $net; my @source = imatch_source_net $net;
my @ipsec_in_match = match_ipsec_in $zone , $hostref; my @ipsec_in_match = match_ipsec_in $zone , $hostref;
if ( @vservers || use_input_chain( $interface, $interfacechainref ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) { if ( @vservers || use_interface_chain( $interface, 'use_input_chain' ) || ! $chain2 || ( @{$interfacechainref->{rules}} && ! $chain2ref ) ) {
# #
# - There are vserver zones (so INPUT will have multiple destinations; or # - There are vserver zones (so INPUT will have multiple destinations; or
# - We must use the interface input chain; or # - We must use the interface input chain; or
@@ -2454,6 +2476,9 @@ sub generate_matrix() {
} }
} }
#
# Generate MSS rules
#
sub setup_mss( ) { sub setup_mss( ) {
my $clampmss = $config{CLAMPMSS}; my $clampmss = $config{CLAMPMSS};
my $option; my $option;

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -90,7 +90,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
# #
# Handle early matches # Handle early matches
# #
if ( $inlinematches =~ s/s*\+// ) { if ( $inlinematches =~ s/^s*\+// ) {
$prerule = $inlinematches; $prerule = $inlinematches;
$inlinematches = ''; $inlinematches = '';
} }

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -62,23 +62,61 @@ our @routemarked_interfaces;
our %provider_interfaces; our %provider_interfaces;
our @load_providers; our @load_providers;
our $balancing; our $balancing; # True, if there are balanced providers
our $fallback; our $fallback; # True, if there are fallback providers
our $balanced_providers; our $balanced_providers; # Count of balanced providers
our $fallback_providers; our $fallback_providers; # Count of fallback providers
our $metrics; our $metrics; # True, if using statistical balancing
our $first_default_route; our $first_default_route; # True, until we generate the first 'via' clause for balanced providers
our $first_fallback_route; our $first_fallback_route; # True, until we generate the first 'via' clause for fallback providers
our $maxload; our $maxload; # Sum of 'load' values
our $tproxies; our $tproxies; # Count of tproxy providers
our %providers; our %providers; # Provider table
#
# %provider_table { <provider> => { provider => <provider name>,
# number => <provider number>,
# id => <name> or <number> depending on USE_RT_NAMES,
# rawmark => <specified mark value>,
# mark => <mark, in hex>,
# interface => <logical interface>,
# physical => <physical interface>,
# optional => {0|1},
# wildcard => <from interface>,
# gateway => <gateway>,
# gatewaycase => { 'detect', 'none', or 'specified' },
# shared => <true, if multiple providers through this interface>,
# copy => <contents of the COPY column>,
# balance => <balance count>,
# pref => <route rules preference (priority) value>,
# mtu => <mtu>,
# noautosrc => {0|1} based on [no]autosrc setting,
# track => {0|1} based on 'track' setting,
# loose => {0|1} based on 'loose' setting,
# duplicate => <contents of the DUPLICATE column>,
# address => If {shared} above, then the local IP address.
# Otherwise, the value of the 'src' option,
# mac => Mac address of gateway, if {shared} above,
# tproxy => {0|1},
# load => <load % for statistical balancing>,
# pseudo => {0|1}. 1 means this is an optional interface and not
# a real provider,
# what => 'provider' or 'interface' depending on {pseudo} above,
# hostroute => {0|1} based on [no]hostroute setting,
# rules => ( <routing rules> ),
# persistent_rules => ( <persistent routing rules> ),
# routes => ( <routes> ),
# persistent_routes => ( <persistent routes> ),
# persistent => {0|1} depending on 'persistent' setting,
# routedests => { <subnet> => 1 , ... }, (used for duplicate destination detection),
# origin => <filename and linenumber where provider/interface defined>
# }
our @providers; our @providers; # Provider names. Only declared names are included in this array.
our $family; our $family; # Address family
our $lastmark; our $lastmark; # Highest assigned mark
use constant { ROUTEMARKED_SHARED => 1, ROUTEMARKED_UNSHARED => 2 }; use constant { ROUTEMARKED_SHARED => 1, ROUTEMARKED_UNSHARED => 2 };
@@ -132,7 +170,6 @@ sub setup_route_marking() {
# #
# Clear the mark -- we have seen cases where the mark is non-zero even in the raw table chains! # Clear the mark -- we have seen cases where the mark is non-zero even in the raw table chains!
# #
if ( $config{ZERO_MARKS} ) { if ( $config{ZERO_MARKS} ) {
add_ijump( $mangle_table->{$_}, j => 'MARK', targetopts => '--set-mark 0' ) for qw/PREROUTING OUTPUT/; add_ijump( $mangle_table->{$_}, j => 'MARK', targetopts => '--set-mark 0' ) for qw/PREROUTING OUTPUT/;
} }
@@ -677,7 +714,6 @@ sub process_a_provider( $ ) {
$mark = ( $lastmark += ( 1 << $config{PROVIDER_OFFSET} ) ) if $mark eq '-' && $track; $mark = ( $lastmark += ( 1 << $config{PROVIDER_OFFSET} ) ) if $mark eq '-' && $track;
if ( $mark ne '-' ) { if ( $mark ne '-' ) {
require_capability( 'MANGLE_ENABLED' , 'Provider marks' , '' ); require_capability( 'MANGLE_ENABLED' , 'Provider marks' , '' );
if ( $tproxy && ! $local ) { if ( $tproxy && ! $local ) {
@@ -1917,18 +1953,18 @@ sub setup_providers() {
push_indent; push_indent;
emit "undo_routing";
emit "restore_default_route $config{USE_DEFAULT_RT}";
if ( $pseudoproviders ) { if ( $pseudoproviders ) {
emit ''; emit '';
emit "start_$providers{$_}->{what}_$_" for @providers; emit "start_$providers{$_}->{what}_$_" for @providers;
emit '';
} }
emit "undo_routing";
emit "restore_default_route $config{USE_DEFAULT_RT}";
my $standard_routes = @{$providers{main}{routes}} || @{$providers{default}{routes}}; my $standard_routes = @{$providers{main}{routes}} || @{$providers{default}{routes}};
if ( $config{NULL_ROUTE_RFC1918} ) { if ( $config{NULL_ROUTE_RFC1918} ) {
emit '';
setup_null_routing; setup_null_routing;
emit "\nrun_ip route flush cache" unless $standard_routes; emit "\nrun_ip route flush cache" unless $standard_routes;
} }

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2009-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2009-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -70,6 +70,13 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
my $zone; my $zone;
my $restriction = PREROUTE_RESTRICT; my $restriction = PREROUTE_RESTRICT;
my $raw_matches = get_inline_matches(0);
my $prerule = '';
if ( $raw_matches =~ /^s*+/ ) {
$prerule = $raw_matches;
$raw_matches = '';
}
if ( $chainref ) { if ( $chainref ) {
$restriction = OUTPUT_RESTRICT if $chainref->{name} eq 'OUTPUT'; $restriction = OUTPUT_RESTRICT if $chainref->{name} eq 'OUTPUT';
@@ -206,10 +213,11 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
expand_rule( $chainref , expand_rule( $chainref ,
$restriction , $restriction ,
'', $prerule,
do_proto( $proto, $ports, $sports ) . do_proto( $proto, $ports, $sports ) .
do_user ( $user ) . do_user ( $user ) .
do_condition( $switch , $chainref->{name} ), do_condition( $switch , $chainref->{name} ) .
$raw_matches ,
$source , $source ,
$dest , $dest ,
'' , '' ,
@@ -316,7 +324,7 @@ sub setup_conntrack($) {
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, user => 5, switch => 6 } ); { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, user => 5, switch => 6 } );
$action = 'NOTRACK'; $action = 'NOTRACK';
} else { } else {
( $action, $source, $dest, $protos, $ports, $sports, $user, $switch ) = split_line1 'Conntrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, switch => 7 }; ( $action, $source, $dest, $protos, $ports, $sports, $user, $switch ) = split_line2( 'Conntrack File', { action => 0, source => 1, dest => 2, proto => 3, dport => 4, sport => 5, user => 6, switch => 7 }, undef, undef, 1 );
} }
$empty = 0; $empty = 0;

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -292,6 +292,8 @@ our $mangle;
our $sticky; our $sticky;
our $excludefw;
our $divertref; # DIVERT chain our $divertref; # DIVERT chain
our %validstates = ( NEW => 0, our %validstates = ( NEW => 0,
@@ -365,6 +367,10 @@ sub initialize( $ ) {
# #
%actions = (); %actions = ();
# #
# Count of 'all[+]=' encountered
#
$excludefw = 0;
#
# Action variants actually used. Key is <action>:<loglevel>:<tag>:<caller>:<params>; value is corresponding chain name # Action variants actually used. Key is <action>:<loglevel>:<tag>:<caller>:<params>; value is corresponding chain name
# #
%usedactions = (); %usedactions = ();
@@ -672,14 +678,42 @@ sub process_a_policy1($$$$$$$) {
my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_; my ( $client, $server, $originalpolicy, $loglevel, $synparams, $connlimit, $intrazone ) = @_;
my $clientwild = ( "\L$client" =~ /^all(\+)?$/ ); my $clientwild = ( "\L$client" =~ /^all(\+)?(?:!(.+))?$/ );
my $clientexclude;
my %clientexcluded;
$intrazone ||= $clientwild && $1; if ( $clientwild ) {
$intrazone ||= $1;
if ( $clientexclude = $2 ) {
for my $client ( split_list( $clientexclude, 'zone' ) ) {
fatal_error "Undefined zone ($client)" unless defined_zone( $client );
$clientexcluded{$client} = 1;
}
$client = 'all';
}
}
fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client ); fatal_error "Undefined zone ($client)" unless $clientwild || defined_zone( $client );
my $serverwild = ( "\L$server" =~ /^all(\+)?/ ); my $serverwild = ( "\L$server" =~ /^all(\+)?(?:!(.+))?/ );
$intrazone ||= ( $serverwild && $1 ); my $serverexclude;
my %serverexcluded;
if ( $serverwild ) {
$intrazone ||= $1;
if ( $serverexclude = $2 ) {
for my $server ( split_list( $serverexclude, 'zone' ) ) {
fatal_error "Undefined zone ($server)" unless defined_zone( $server );
$serverexcluded{$server} = 1;
}
$server = 'all';
}
}
fatal_error "Undefined zone ($server)" unless $serverwild || defined_zone( $server ); fatal_error "Undefined zone ($server)" unless $serverwild || defined_zone( $server );
@@ -762,20 +796,20 @@ sub process_a_policy1($$$$$$$) {
if ( $clientwild ) { if ( $clientwild ) {
if ( $serverwild ) { if ( $serverwild ) {
for my $zone ( @zonelist ) { for my $zone ( grep( ! $clientexcluded{$_}, @zonelist ) ) {
for my $zone1 ( @zonelist ) { for my $zone1 ( grep( ! $serverexcluded{zone}, @zonelist ) ) {
set_policy_chain $zone, $zone1, $chainref, $policy, $intrazone; set_policy_chain $zone, $zone1, $chainref, $policy, $intrazone;
print_policy $zone, $zone1, $originalpolicy, $chain; print_policy $zone, $zone1, $originalpolicy, $chain;
} }
} }
} else { } else {
for my $zone ( all_zones ) { for my $zone ( grep( ! $clientexcluded{$_}, all_zones ) ) {
set_policy_chain $zone, $server, $chainref, $policy, $intrazone; set_policy_chain $zone, $server, $chainref, $policy, $intrazone;
print_policy $zone, $server, $originalpolicy, $chain; print_policy $zone, $server, $originalpolicy, $chain;
} }
} }
} elsif ( $serverwild ) { } elsif ( $serverwild ) {
for my $zone ( @zonelist ) { for my $zone ( grep( ! $serverexcluded{$_}, @zonelist ) ) {
set_policy_chain $client, $zone, $chainref, $policy, $intrazone; set_policy_chain $client, $zone, $chainref, $policy, $intrazone;
print_policy $client, $zone, $originalpolicy, $chain; print_policy $client, $zone, $originalpolicy, $chain;
} }
@@ -802,11 +836,15 @@ sub process_a_policy() {
my ( $intrazone, $clientlist, $serverlist ); my ( $intrazone, $clientlist, $serverlist );
if ( $clientlist = ( $clients =~ /,/ ) ) { if ( $clients =~ /^all(\+)?!/ ) {
$intrazone = $1;
} elsif ( $clientlist = ( $clients =~ /,/ ) ) {
$intrazone = ( $clients =~ s/\+$// ); $intrazone = ( $clients =~ s/\+$// );
} }
if ( $serverlist = ( $servers =~ /,/ ) ) { if ( $servers =~ /^all(\+)?!/ ) {
$intrazone = $1;
} elsif ( $serverlist = ( $servers =~ /,/ ) ) {
$intrazone ||= ( $servers =~ s/\+$// ); $intrazone ||= ( $servers =~ s/\+$// );
} }
@@ -816,12 +854,14 @@ sub process_a_policy() {
if ( $clientlist || $serverlist ) { if ( $clientlist || $serverlist ) {
for my $client ( split_list( $clients, 'zone' ) ) { for my $client ( split_list( $clients, 'zone' ) ) {
fatal_error "'all' is not allowed in a source zone list" if $clientlist && $client =~ /^all\b/;
for my $server ( split_list( $servers, 'zone' ) ) { for my $server ( split_list( $servers, 'zone' ) ) {
fatal_error "'all' is not allowed in a destination zone list" if $serverlist && $server =~ /^all\b/;
process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone ) if $intrazone || $client ne $server; process_a_policy1( $client, $server, $policy, $loglevel, $synparams, $connlimit, $intrazone ) if $intrazone || $client ne $server;
} }
} }
} else { } else {
process_a_policy1( $clients, $servers, $policy, $loglevel, $synparams, $connlimit, 0 ); process_a_policy1( $clients, $servers, $policy, $loglevel, $synparams, $connlimit, $intrazone );
} }
} }
@@ -2609,7 +2649,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
# #
# Handle early matches # Handle early matches
# #
if ( $raw_matches =~ s/s*\+// ) { if ( $raw_matches =~ s/^s*\+// ) {
$prerule = $raw_matches; $prerule = $raw_matches;
$raw_matches = ''; $raw_matches = '';
} }
@@ -2781,7 +2821,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } , LOG => sub { fatal_error 'LOG requires a log level' unless supplied $loglevel; } ,
HELPER => sub { HELPER => sub {
fatal_error "HELPER requires require that the helper be specified in the HELPER column" if $helper eq '-'; fatal_error "HELPER requires that a helper be specified in the HELPER column" if $helper eq '-';
fatal_error "HELPER rules may only appear in the NEW section" unless $section == NEW_SECTION; fatal_error "HELPER rules may only appear in the NEW section" unless $section == NEW_SECTION;
$action = ''; } , $action = ''; } ,
@@ -3659,6 +3699,7 @@ sub next_section() {
# #
sub build_zone_list( $$$\$\$ ) { sub build_zone_list( $$$\$\$ ) {
my ($fw, $input, $which, $intrazoneref, $wildref ) = @_; my ($fw, $input, $which, $intrazoneref, $wildref ) = @_;
my $original_input = $input;
my $any = ( $input =~ s/^any/all/ ); my $any = ( $input =~ s/^any/all/ );
my $exclude; my $exclude;
my $rest; my $rest;
@@ -3687,9 +3728,25 @@ sub build_zone_list( $$$\$\$ ) {
if ( $input eq 'all+' ) { if ( $input eq 'all+' ) {
$$intrazoneref = 1; $$intrazoneref = 1;
} elsif ( ( $input eq 'all+-' ) || ( $input eq 'all-+' ) ) { } elsif ( ( $input eq 'all+-' ) || ( $input eq 'all-+' ) ) {
unless ( $excludefw++ ) {
if ( $any ) {
warning_message "$original_input is deprecated in favor of 'any+!\$FW'";
} else {
warning_message "$original_input is deprecated in favor of 'all+!\$FW'";
}
}
$$intrazoneref = 1; $$intrazoneref = 1;
$exclude{$fw} = 1; $exclude{$fw} = 1;
} elsif ( $input eq 'all-' ) { } elsif ( $input eq 'all-' ) {
unless ( $excludefw++ ) {
if ( $any ) {
warning_message "any- is deprecated in favor of 'any!\$FW'";
} else {
warning_message "all- is deprecated in favor of 'all!\$FW'" unless $excludefw++;
}
}
$exclude{$fw} = 1; $exclude{$fw} = 1;
} else { } else {
fatal_error "Invalid $which ($input)"; fatal_error "Invalid $which ($input)";
@@ -4889,7 +4946,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
# #
# Handle early matches # Handle early matches
# #
if ( $raw_matches =~ s/s*\+// ) { if ( $raw_matches =~ s/^s*\+// ) {
$prerule = $raw_matches; $prerule = $raw_matches;
$raw_matches = ''; $raw_matches = '';
} }

View File

@@ -3,7 +3,7 @@
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
# (c) 2007,2008,2009,2010,2011-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -222,6 +222,9 @@ use constant { IN_OUT => 1,
IN => 2, IN => 2,
OUT => 3 }; OUT => 3 };
#
# Zone types
#
use constant { FIREWALL => 1, use constant { FIREWALL => 1,
IP => 2, IP => 2,
BPORT => 4, BPORT => 4,
@@ -231,6 +234,9 @@ use constant { FIREWALL => 1,
LOCAL => 64, LOCAL => 64,
}; };
#
# Interface option classification
#
use constant { SIMPLE_IF_OPTION => 1, use constant { SIMPLE_IF_OPTION => 1,
BINARY_IF_OPTION => 2, BINARY_IF_OPTION => 2,
ENUM_IF_OPTION => 3, ENUM_IF_OPTION => 3,
@@ -247,11 +253,17 @@ use constant { SIMPLE_IF_OPTION => 1,
IF_OPTION_WILDOK => 64 IF_OPTION_WILDOK => 64
}; };
#
# 'ignore' option flags
#
use constant { NO_UPDOWN => 1, use constant { NO_UPDOWN => 1,
NO_SFILTER => 2 }; NO_SFILTER => 2 };
our %validinterfaceoptions; our %validinterfaceoptions;
#
# Interface options that are implemented in /proc
#
our %procinterfaceoptions=( accept_ra => 1, our %procinterfaceoptions=( accept_ra => 1,
arp_filter => 1, arp_filter => 1,
arp_ignore => 1, arp_ignore => 1,
@@ -263,6 +275,9 @@ our %procinterfaceoptions=( accept_ra => 1,
sourceroute => 1, sourceroute => 1,
); );
#
# Options that are not allowed with unmanaged interfaces
#
our %prohibitunmanaged = ( our %prohibitunmanaged = (
blacklist => 1, blacklist => 1,
bridge => 1, bridge => 1,
@@ -281,10 +296,15 @@ our %prohibitunmanaged = (
upnp => 1, upnp => 1,
upnpclient => 1, upnpclient => 1,
); );
#
# Default values for options that admit an optional value
#
our %defaultinterfaceoptions = ( routefilter => 1 , wait => 60, accept_ra => 1 , ignore => 3, routeback => 1 ); our %defaultinterfaceoptions = ( routefilter => 1 , wait => 60, accept_ra => 1 , ignore => 3, routeback => 1 );
our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 , ignore => NO_UPDOWN | NO_SFILTER, accept_ra => 2 ); #
# Maximum value for options that accept a range of values
#
our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 300 , ignore => NO_UPDOWN | NO_SFILTER, accept_ra => 2 );
our %validhostoptions; our %validhostoptions;
@@ -701,7 +721,7 @@ sub determine_zones()
} }
# #
# Return true of we have any ipsec zones # Return true If we have any ipsec zones
# #
sub haveipseczones() { sub haveipseczones() {
for my $zoneref ( values %zones ) { for my $zoneref ( values %zones ) {
@@ -872,6 +892,9 @@ sub single_interface( $ ) {
@keys == 1 ? $keys[0] : ''; @keys == 1 ? $keys[0] : '';
} }
#
# This function adds an interface:network pair to a zone
#
sub add_group_to_zone($$$$$$) sub add_group_to_zone($$$$$$)
{ {
my ($zone, $type, $interface, $networks, $options, $inherit_options) = @_; my ($zone, $type, $interface, $networks, $options, $inherit_options) = @_;
@@ -976,6 +999,9 @@ sub find_zone( $ ) {
$zoneref; $zoneref;
} }
#
# Access functions for zone members
#
sub zone_type( $ ) { sub zone_type( $ ) {
find_zone( $_[0] )->{type}; find_zone( $_[0] )->{type};
} }
@@ -990,26 +1016,44 @@ sub zone_mark( $ ) {
$zoneref->{mark}; $zoneref->{mark};
} }
#
# Returns the zone table entry for the passed zone name
#
sub defined_zone( $ ) { sub defined_zone( $ ) {
$zones{$_[0]}; $zones{$_[0]};
} }
#
# Returns a list of all defined zones
#
sub all_zones() { sub all_zones() {
@zones; @zones;
} }
#
# Returns a list of zones in the firewall itself (the firewall zone and vserver zones)
#
sub on_firewall_zones() { sub on_firewall_zones() {
grep ( ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones ); grep ( ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
} }
#
# Returns a list of zones excluding the firewall and vserver zones
#
sub off_firewall_zones() { sub off_firewall_zones() {
grep ( ! ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones ); grep ( ! ( $zones{$_}{type} & ( FIREWALL | VSERVER ) ) , @zones );
} }
#
# Returns a list of zones excluding the firewall zones
#
sub non_firewall_zones() { sub non_firewall_zones() {
grep ( ! ( $zones{$_}{type} & FIREWALL ) , @zones ); grep ( ! ( $zones{$_}{type} & FIREWALL ) , @zones );
} }
#
# Returns the list of zones that don't contain sub-zones
#
sub all_parent_zones() { sub all_parent_zones() {
# #
# Although the firewall zone is technically a parent zone, we let the caller decide # Although the firewall zone is technically a parent zone, we let the caller decide
@@ -1018,22 +1062,37 @@ sub all_parent_zones() {
grep ( ! @{$zones{$_}{parents}} , off_firewall_zones ); grep ( ! @{$zones{$_}{parents}} , off_firewall_zones );
} }
#
# Returns a list of complex zones (ipsec or with multiple interface:subnets)
#
sub complex_zones() { sub complex_zones() {
grep( $zones{$_}{complex} , @zones ); grep( $zones{$_}{complex} , @zones );
} }
#
# Returns a list of vserver zones
#
sub vserver_zones() { sub vserver_zones() {
grep ( $zones{$_}{type} & VSERVER, @zones ); grep ( $zones{$_}{type} & VSERVER, @zones );
} }
#
# Returns the name of the firewall zone
#
sub firewall_zone() { sub firewall_zone() {
$firewall_zone; $firewall_zone;
} }
#
# Returns a list of loopback zones
#
sub loopback_zones() { sub loopback_zones() {
@loopback_zones; @loopback_zones;
} }
#
# Returns a list of local zones
#
sub local_zones() { sub local_zones() {
@local_zones; @local_zones;
} }

View File

@@ -34,6 +34,8 @@
# --debug # Print stack trace on warnings and fatal error. # --debug # Print stack trace on warnings and fatal error.
# --log=<filename> # Log file # --log=<filename> # Log file
# --log_verbosity=<number> # Log Verbosity range -1 to 2 # --log_verbosity=<number> # Log Verbosity range -1 to 2
# --test # Used by the regression library to omit versions and time/dates
# # from the generated script
# --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6 # --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6
# --preview # Preview the ruleset. # --preview # Preview the ruleset.
# --shorewallrc=<path> # Path to global shorewallrc file. # --shorewallrc=<path> # Path to global shorewallrc file.

View File

@@ -1,4 +1,4 @@
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2019 - Tom Eastep (teastep@shorewall.net)
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -897,6 +897,14 @@ detect_dynamic_gateway() { # $1 = interface
fi fi
done done
if [ -z "$gateway" -a -n "$(mywhich nmcli)" ]; then
if [ $g_family = 4 ]; then
gateway=$(nmcli --fields DHCP4.OPTION,IP4.GATEWAY device show ${1} 2> /dev/null | sed -rn '/( routers = |IP4.GATEWAY:.*[1-9])/{s/.* //;p;q}')
else
gateway=$(nmcli --terse --fields IP6.GATEWAY device show ${1} 2> /dev/null | cut -f2- -d':')
fi
fi
[ -n "$gateway" ] && echo $gateway [ -n "$gateway" ] && echo $gateway
} }

View File

@@ -191,8 +191,6 @@ IP_FORWARDING=On
KEEP_RT_TABLES=No KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -202,8 +202,6 @@ IP_FORWARDING=Off
KEEP_RT_TABLES=No KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -199,8 +199,6 @@ IP_FORWARDING=On
KEEP_RT_TABLES=No KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -202,8 +202,6 @@ IP_FORWARDING=On
KEEP_RT_TABLES=No KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -191,8 +191,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=No KEEP_RT_TABLES=No
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -16,25 +16,6 @@
# Helpers # Helpers
# #
loadmodule ip_conntrack_amanda
loadmodule ip_conntrack_ftp
loadmodule ip_conntrack_h323
loadmodule ip_conntrack_irc
loadmodule ip_conntrack_netbios_ns
loadmodule ip_conntrack_pptp
loadmodule ip_conntrack_sip
loadmodule ip_conntrack_tftp
loadmodule ip_nat_amanda
loadmodule ip_nat_ftp
loadmodule ip_nat_h323
loadmodule ip_nat_irc
loadmodule ip_nat_pptp
loadmodule ip_nat_sip
loadmodule ip_nat_snmp_basic
loadmodule ip_nat_tftp
#
# 2.6.20+ helpers
#
loadmodule nf_conntrack_ftp loadmodule nf_conntrack_ftp
loadmodule nf_conntrack_h323 loadmodule nf_conntrack_h323
loadmodule nf_conntrack_irc loadmodule nf_conntrack_irc
@@ -67,5 +48,4 @@ loadmodule ipt_LOG
loadmodule nf_log_ipv4 loadmodule nf_log_ipv4
loadmodule xt_LOG loadmodule xt_LOG
loadmodule xt_NFLOG loadmodule xt_NFLOG
loadmodule ipt_ULOG
loadmodule nfnetlink_log loadmodule nfnetlink_log

View File

@@ -466,17 +466,6 @@ if [ -z "$first_install" ]; then
fi fi
fi fi
#
# Install the Modules file
#
run_install $OWNERSHIP -m 0644 modules ${DESTDIR}${SHAREDIR}/${PRODUCT}/modules
echo "Modules file installed as ${DESTDIR}${SHAREDIR}/${PRODUCT}/modules"
for f in modules.*; do
run_install $OWNERSHIP -m 0644 $f ${DESTDIR}${SHAREDIR}/${PRODUCT}/$f
echo "Modules file $f installed as ${DESTDIR}${SHAREDIR}/${PRODUCT}/$f"
done
# #
# Install the Module Helpers file # Install the Module Helpers file
# #
@@ -1252,6 +1241,14 @@ if [ $PRODUCT = shorewall ]; then
rm -f ${DESTDIR}${SHAREDIR}/${PRODUCT}/deprecated/macro.SMTPTraps rm -f ${DESTDIR}${SHAREDIR}/${PRODUCT}/deprecated/macro.SMTPTraps
fi fi
#
# Remove unneeded modules files
#
if [ -n "$first_install" ]; then
rm -f ${DESTDIR}${SHAREDIR}/${PRODUCT}/modules*
fi
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable ${PRODUCT}.service; then if systemctl enable ${PRODUCT}.service; then

View File

@@ -300,19 +300,6 @@ get_config() {
;; ;;
esac esac
case $LOAD_HELPERS_ONLY in
Yes|yes)
;;
No|no)
LOAD_HELPERS_ONLY=
;;
*)
if [ -n "$LOAD_HELPERS_ONLY" ]; then
fatal_error "Invalid LOAD_HELPERS_ONLY setting ($LOAD_HELPERS_ONLY)"
fi
;;
esac
if [ -n "$WORKAROUNDS" ]; then if [ -n "$WORKAROUNDS" ]; then
case $WORKAROUNDS in case $WORKAROUNDS in
[Yy]es) [Yy]es)
@@ -456,6 +443,16 @@ compiler() {
ensure_root ensure_root
# #
# Let params and the compiler know the base configuration directory
#
if [ -n "$g_shorewalldir" ]; then
SW_CONFDIR="$g_shorewalldir"
else
SW_CONFDIR="$g_confdir"
fi
export SW_CONFDIR
#
# We've now set g_shorewalldir so recalculate CONFIG_PATH # We've now set g_shorewalldir so recalculate CONFIG_PATH
# #
[ -n "$g_haveconfig" ] || ensure_config_path [ -n "$g_haveconfig" ] || ensure_config_path

View File

@@ -36,7 +36,7 @@
<para>In IPv6, the format is <emphasis>a:b:c:d:e:f:g:h</emphasis> <para>In IPv6, the format is <emphasis>a:b:c:d:e:f:g:h</emphasis>
where <emphasis>a</emphasis> through <emphasis>h</emphasis> consist where <emphasis>a</emphasis> through <emphasis>h</emphasis> consist
of 1 to 4 hexidecimal digits (leading zeros may be omitted). a of 1 to 4 hexadecimal digits (leading zeros may be omitted). a
single series of 0 addresses may be omitted. For example single series of 0 addresses may be omitted. For example
2001:227:e857:1:0:0:0:0:1 may be written 2001:227:e857:1::1.</para> 2001:227:e857:1:0:0:0:0:1 may be written 2001:227:e857:1::1.</para>
</listitem> </listitem>

View File

@@ -199,7 +199,7 @@
<listitem> <listitem>
<para><ulink url="shorewall-ecn.html">/etc/shorewall/ecn</ulink> - <para><ulink url="shorewall-ecn.html">/etc/shorewall/ecn</ulink> -
disable Explicit Congestion Notification (ECN - RFC 3168) to remote disable Explicit Congestion Notification (ECN - RFC 3168) to remote
hosts or networks. Superceded by ECN entries in hosts or networks. Superseded by ECN entries in
<filename>/etc/shorewall/mangle</filename> in Shorewall 5.0.6.</para> <filename>/etc/shorewall/mangle</filename> in Shorewall 5.0.6.</para>
</listitem> </listitem>
@@ -720,7 +720,7 @@ DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }</programlisting
<refsect1> <refsect1>
<title>Time Columns</title> <title>Time Columns</title>
<para>Several of the files include a TIME colum that allows you to specify <para>Several of the files include a TIME column that allows you to specify
times when the rule is to be applied. Contents of this column is a list of times when the rule is to be applied. Contents of this column is a list of
<replaceable>timeelement</replaceable>s separated by apersands <replaceable>timeelement</replaceable>s separated by apersands
(&amp;).</para> (&amp;).</para>

View File

@@ -38,6 +38,12 @@
<filename>helpers</filename> file is used when <filename>helpers</filename> file is used when
LOAD_HELPERS_ONLY=Yes</para> LOAD_HELPERS_ONLY=Yes</para>
<important>
<para>Beginning with Shorewall 5.2.3, the LOAD_HELPERS_ONLY option has
been removed and the behavior is the same as if LOAD_HELPERS_ONLY=Yes
was specified.</para>
</important>
<para>Each record in the files has the following format:</para> <para>Each record in the files has the following format:</para>
<cmdsynopsis> <cmdsynopsis>

View File

@@ -68,32 +68,35 @@
<term><emphasis role="bold">SOURCE</emphasis> - <term><emphasis role="bold">SOURCE</emphasis> -
<emphasis>zone</emphasis>[,...[+]]|<emphasis <emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis role="bold">$FW</emphasis>|<emphasis
role="bold">all</emphasis>|<emphasis role="bold">all[+][!<replaceable>ezone</replaceable>[,...]]</emphasis></term>
role="bold">all+</emphasis></term>
<listitem> <listitem>
<para>Source zone. Must be the name of a zone defined in <ulink <para>Source zone. Must be the name of a zone defined in <ulink
url="/manpages/shorewall-zones.html">shorewall-zones</ulink>(5), url="/manpages/shorewall-zones.html">shorewall-zones</ulink>(5),
$FW, "all" or "all+".</para> $FW, "all" or "all+".</para>
<para>Support for "all+" was added in Shorewall 4.5.17. "all" does <para>Support for <emphasis role="bold">all+</emphasis> was added in
not override the implicit intra-zone ACCEPT policy while "all+" Shorewall 4.5.17. <emphasis role="bold">all</emphasis> does not
does.</para> override the implicit intra-zone ACCEPT policy while <emphasis
role="bold">all+</emphasis> does.</para>
<para>Beginning with Shorewall 5.0.12, multiple zones may be listed <para>Beginning with Shorewall 5.0.12, multiple zones may be listed
separated by commas. As above, if '+' is specified after two or more separated by commas. As above, if '+' is specified after two or more
zone names, then the policy overrides the implicit intra-zone ACCEPT zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para> the SOURCE and DEST columns.</para>
<para>Beginning with Shorewall 5.2.3, a comma-separated list of
excluded zones preceded by "!" may follow <emphasis
role="bold">all</emphasis> or <emphasis
role="bold">all+.</emphasis></para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">DEST</emphasis> - <term><emphasis role="bold">DEST</emphasis> -
<emphasis>zone</emphasis>[,...[+]]|<emphasis <emphasis>zone</emphasis>[,...[+]]|<emphasis
role="bold">$FW</emphasis>|<emphasis role="bold">$FW</emphasis>|all[+][!<replaceable>ezone</replaceable>[,...]]</term>
role="bold">all</emphasis>|<emphasis
role="bold">all+</emphasis></term>
<listitem> <listitem>
<para>Destination zone. Must be the name of a zone defined in <ulink <para>Destination zone. Must be the name of a zone defined in <ulink
@@ -112,6 +115,11 @@
zone names, then the policy overrides the implicit intra-zone ACCEPT zone names, then the policy overrides the implicit intra-zone ACCEPT
policy if the same <replaceable>zone</replaceable> appears in both policy if the same <replaceable>zone</replaceable> appears in both
the SOURCE and DEST columns.</para> the SOURCE and DEST columns.</para>
<para>Beginning with Shorewall 5.2.3, a comma-separated list of
excluded zones preceded by "!" may follow <emphasis
role="bold">all</emphasis> or <emphasis
role="bold">all+</emphasis>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -387,8 +387,10 @@
distributions but <emphasis role="bold">nohostroute</emphasis> distributions but <emphasis role="bold">nohostroute</emphasis>
(below) is appropriate for recent distributions. <emphasis (below) is appropriate for recent distributions. <emphasis
role="bold">hostroute</emphasis> may interfere with Zebra's role="bold">hostroute</emphasis> may interfere with Zebra's
ability to add routes on some distributions such as Debian ability to add routes on some distributions such as Debian 7.
7.</para> This option defaults to on when BALANCE_PROVIDERS=Yes, in
<ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -404,7 +406,9 @@
older distributions but is appropriate for recent older distributions but is appropriate for recent
distributions. <emphasis role="bold">nohostroute</emphasis> distributions. <emphasis role="bold">nohostroute</emphasis>
allows Zebra's to correctly add routes on some distributions allows Zebra's to correctly add routes on some distributions
such as Debian 7.</para> such as Debian 7. This option defaults to off when
BALANCE_PROVIDERS=Yes, in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -446,7 +450,7 @@
</note> </note>
<important> <important>
<para>RESTORE_DEFAULT_OPTION=Yes in shorewall[6].conf is not <para>RESTORE_DEFAULT_ROUTE=Yes in shorewall[6].conf is not
recommended when the <option>persistent</option> option is recommended when the <option>persistent</option> option is
used, as restoring default routes to the main routing table used, as restoring default routes to the main routing table
can prevent link status monitors such as foolsm from can prevent link status monitors such as foolsm from

View File

@@ -993,19 +993,18 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>all[+][-]</term> <term>all[+]</term>
<listitem> <listitem>
<para><emphasis role="bold">all</emphasis>, without the <para><emphasis role="bold">all</emphasis>, without the
"-" means "All Zones, including the firewall zone". If "-" means "All Zones, including the firewall zone".
the "-" is included, the firewall zone is omitted.
Normally all omits intra-zone traffic, but intra-zone Normally all omits intra-zone traffic, but intra-zone
traffic can be included specifying "+".</para> traffic can be included specifying "+".</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>any[+][-]</term> <term>any[+]</term>
<listitem> <listitem>
<para><emphasis role="bold">any</emphasis> is equivalent <para><emphasis role="bold">any</emphasis> is equivalent
@@ -1259,6 +1258,15 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>all+!$FW</term>
<listitem>
<para>All but the firewall zone and applies to intrazone
traffic.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>net:^CN</term> <term>net:^CN</term>
@@ -1349,19 +1357,18 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>all[+][-]</term> <term>all[+]</term>
<listitem> <listitem>
<para><emphasis role="bold">all</emphasis>, without the <para><emphasis role="bold">all</emphasis>, without the
"-" means "All Zones, including the firewall zone". If "-" means "All Zones, including the firewall zone".
the "-" is included, the firewall zone is omitted.
Normally all omits intra-zone traffic, but intra-zone Normally all omits intra-zone traffic, but intra-zone
traffic can be included specifying "+".</para> traffic can be included specifying "+".</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>any[+][-]</term> <term>any[+]</term>
<listitem> <listitem>
<para><emphasis role="bold">any</emphasis> is equivalent <para><emphasis role="bold">any</emphasis> is equivalent
@@ -1573,7 +1580,7 @@
<para>If the DEST <replaceable>zone</replaceable> is a bport zone, <para>If the DEST <replaceable>zone</replaceable> is a bport zone,
then either:<orderedlist numeration="loweralpha"> then either:<orderedlist numeration="loweralpha">
<listitem> <listitem>
<para>the SOURCE must be <option>all[+][-]</option>, or</para> <para>the SOURCE must be <option>all[+]</option>, or</para>
</listitem> </listitem>
<listitem> <listitem>
@@ -1900,19 +1907,21 @@
<simplelist> <simplelist>
<member>[<emphasis role="bold">-</emphasis>|[{<emphasis <member>[<emphasis role="bold">-</emphasis>|[{<emphasis
role="bold">s</emphasis>|<emphasis role="bold">s</emphasis>|<emphasis
role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[[<replaceable>name</replaceable>][(<replaceable>ht-buckets</replaceable>,<replaceable>ht-max</replaceable>)]:]<emphasis>rate</emphasis><emphasis role="bold">d</emphasis>}[/<replaceable>vlsm</replaceable>]:[<replaceable>name</replaceable>[(<replaceable>ht-buckets</replaceable>,<replaceable>ht-max</replaceable>)]:]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member> role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
<member>[<replaceable>name</replaceable>1:]<emphasis>rate1</emphasis><emphasis <member>[<emphasis
role="bold">s</emphasis>[/<replaceable>vlsm1</replaceable>]:][<replaceable>name</replaceable>1[(<replaceable>ht-buckets1</replaceable>,<replaceable>ht-max1</replaceable>)]:]<emphasis>rate1</emphasis><emphasis
role="bold">/</emphasis>{<emphasis role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2:]<emphasis>rate2</emphasis><emphasis role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<emphasis
role="bold">d</emphasis>[/<replaceable>vlsm2</replaceable>:][<replaceable>name</replaceable>2[(<replaceable>ht-buckets2</replaceable>,<replaceable>ht-max2</replaceable>)]:]<emphasis>rate2</emphasis><emphasis
role="bold">/</emphasis>{<emphasis role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis role="bold">min</emphasis>|<emphasis

View File

@@ -500,7 +500,7 @@
each listed directory is to be searched. AUTOMAKE=1 only searches each listed directory is to be searched. AUTOMAKE=1 only searches
each directory itself and is equivalent to AUTOMAKE=Yes. AUTOMAKE=2 each directory itself and is equivalent to AUTOMAKE=Yes. AUTOMAKE=2
will search each directory and its immediate sub-directories; will search each directory and its immediate sub-directories;
AUTOMAKE=3 will search each diretory, each of its immediate AUTOMAKE=3 will search each directory, each of its immediate
sub-directories, and each of their immediate sub-directories, sub-directories, and each of their immediate sub-directories,
etc.</para> etc.</para>
</listitem> </listitem>
@@ -1382,7 +1382,10 @@ net all DROP info</programlisting>then the chain name is 'net-all'
of modules loaded by shorewall to those listed in of modules loaded by shorewall to those listed in
<filename>/var/lib/shorewall[6]/helpers</filename> and those that <filename>/var/lib/shorewall[6]/helpers</filename> and those that
are actually used. When not set, or set to the empty value, are actually used. When not set, or set to the empty value,
LOAD_HELPERS_ONLY=No is assumed.</para> LOAD_HELPERS_ONLY=No is assumed in Shorewall versions 5.2.2 and
earlier. Beginning with Shorewall 5.2.3, the LOAD_HELPERS_ONLY
option is removed, and the behavior is as if LOAD_HELPERS_ONLY=Yes
had been specified.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -1,39 +0,0 @@
#
# Shorewall version 5 - Modules File
#
# /usr/share/shorewall/modules
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
#
# Essential Modules
#
INCLUDE modules.essential
#
# Other xtables modules
#
INCLUDE modules.xtables
#
# Helpers
#
INCLUDE helpers
#
# Ipset
#
INCLUDE modules.ipset
#
# Traffic Shaping
#
INCLUDE modules.tc
#
# Extensions
#
INCLUDE modules.extensions

View File

@@ -1,32 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/modules.essential
#
# Essential Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
#
# Essential Modules
#
loadmodule nfnetlink
loadmodule x_tables
loadmodule ip_tables
loadmodule iptable_filter
loadmodule iptable_mangle
loadmodule ip_conntrack
loadmodule nf_conntrack
loadmodule nf_conntrack_ipv4
loadmodule iptable_nat
loadmodule nf_nat
loadmodule nf_nat_ipv4
loadmodule iptable_raw
loadmodule xt_state
loadmodule xt_tcpudp

View File

@@ -1,59 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/modules.extensions
#
# Extensions Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule ipt_addrtype
loadmodule ipt_ah
loadmodule ipt_CLASSIFY
loadmodule ipt_CLUSTERIP
loadmodule ipt_comment
loadmodule ipt_connmark
loadmodule ipt_CONNMARK
loadmodule ipt_conntrack
loadmodule ipt_dscp
loadmodule ipt_DSCP
loadmodule ipt_ecn
loadmodule ipt_ECN
loadmodule ipt_esp
loadmodule ipt_hashlimit
loadmodule ipt_helper
loadmodule ipt_ipp2p
loadmodule ipt_iprange
loadmodule ipt_length
loadmodule ipt_limit
loadmodule ipt_mac
loadmodule ipt_mark
loadmodule ipt_MARK
loadmodule ipt_MASQUERADE
loadmodule ipt_multiport
loadmodule ipt_NETMAP
loadmodule ipt_NOTRACK
loadmodule ipt_owner
loadmodule ipt_physdev
loadmodule ipt_pkttype
loadmodule ipt_policy
loadmodule ipt_realm
loadmodule ipt_recent
loadmodule ipt_REDIRECT
loadmodule ipt_REJECT
loadmodule ipt_SAME
loadmodule ipt_sctp
loadmodule ipt_set
loadmodule ipt_state
loadmodule ipt_tcpmss
loadmodule ipt_TCPMSS
loadmodule ipt_tos
loadmodule ipt_TOS
loadmodule ipt_ttl
loadmodule ipt_TTL

View File

@@ -1,27 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/modules.ipset
#
# IP Set Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule xt_set
loadmodule ip_set
loadmodule ip_set_iphash
loadmodule ip_set_ipmap
loadmodule ip_set_ipporthash
loadmodule ip_set_iptree
loadmodule ip_set_iptreemap
loadmodule ip_set_macipmap
loadmodule ip_set_nethash
loadmodule ip_set_portmap
loadmodule ipt_SET
loadmodule ipt_set

View File

@@ -1,27 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/modules.tc
#
# Traffic Shaping Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule sch_sfq
loadmodule sch_ingress
loadmodule sch_hfsc
loadmodule sch_htb
loadmodule sch_prio
loadmodule sch_tbf
loadmodule sch_fq_codel
loadmodule cls_u32
loadmodule cls_fw
loadmodule cls_flow
loadmodule cls_basic
loadmodule act_police

View File

@@ -1,53 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/modules.xtables
#
# Xtables Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule xt_AUDIT
loadmodule xt_CLASSIFY
loadmodule xt_connmark
loadmodule xt_CONNMARK
loadmodule xt_conntrack
loadmodule xt_dccp
loadmodule xt_dscp
loadmodule xt_DSCP
loadmodule xt_hashlimit
loadmodule xt_helper
loadmodule xt_ipp2p
loadmodule xt_iprange
loadmodule xt_length
loadmodule xt_limit
loadmodule xt_mac
loadmodule xt_mark
loadmodule xt_MARK
loadmodule xt_multiport
loadmodule xt_nat
loadmodule xt_NFQUEUE
loadmodule xt_owner
loadmodule xt_physdev
loadmodule xt_pkttype
loadmodule xt_policy
loadmodule xt_sctp
loadmodule xt_tcpmss
loadmodule xt_TCPMSS
loadmodule xt_time
loadmodule xt_IPMARK
loadmodule xt_TPROXY
#
# From xtables-addons
#
loadmodule xt_condition
loadmodule xt_geoip
loadmodule xt_ipp2p
loadmodule xt_LOGMARK
loadmodule xt_RAWNAT

View File

@@ -178,8 +178,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=Yes KEEP_RT_TABLES=Yes
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -179,8 +179,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=Yes KEEP_RT_TABLES=Yes
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -178,8 +178,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=Yes KEEP_RT_TABLES=Yes
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -178,8 +178,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=Yes KEEP_RT_TABLES=Yes
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -178,8 +178,6 @@ IP_FORWARDING=Keep
KEEP_RT_TABLES=Yes KEEP_RT_TABLES=Yes
LOAD_HELPERS_ONLY=Yes
MACLIST_TABLE=filter MACLIST_TABLE=filter
MACLIST_TTL= MACLIST_TTL=

View File

@@ -1,39 +0,0 @@
#
# Shorewall6 version 5 - Modules File
#
# /usr/share/shorewall6/modules
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
#
# Essential Modules
#
INCLUDE modules.essential
#
# Other xtables modules
#
INCLUDE modules.xtables
#
# Helpers
#
INCLUDE helpers
#
# Ipset
#
INCLUDE modules.ipset
#
# Traffic Shaping
#
INCLUDE modules.tc
#
# Extensions
#
INCLUDE modules.extensions

View File

@@ -1,28 +0,0 @@
#
# Shorewall6 -- /usr/share/shorewall6/modules.essential
#
# Essential Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule nfnetlink
loadmodule x_tables
loadmodule ip6_tables
loadmodule ip6table_filter
loadmodule ip6table_mangle
loadmodule ip6table_raw
loadmodule xt_conntrack
loadmodule nf_conntrack_ipv6
loadmodule nf_nat
loadmodule nf_nat_ipv6
loadmodule xt_state
loadmodule xt_tcpudp
loadmodule ip6t_REJECT

View File

@@ -1,16 +0,0 @@
#
# Shorewall6 -- /usr/share/shorewall6/modules.extension
#
# Extensions Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule ip6_queue

View File

@@ -1,27 +0,0 @@
#
# Shorewall6 -- /usr/share/shorewall6/modules.ipset
#
# IP Set Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall6 and modify the
# copy.
#
###############################################################################
loadmodule xt_set
loadmodule ip_set
loadmodule ip_set_iphash
loadmodule ip_set_ipmap
loadmodule ip_set_ipporthash
loadmodule ip_set_iptree
loadmodule ip_set_iptreemap
loadmodule ip_set_macipmap
loadmodule ip_set_nethash
loadmodule ip_set_portmap
loadmodule ipt_SET
loadmodule ipt_set

View File

@@ -1,27 +0,0 @@
#
# Shorewall6 -- /usr/share/shorewall6/modules.tc
#
# Traffic Shaping Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule sch_sfq
loadmodule sch_ingress
loadmodule sch_htb
loadmodule sch_hfsc
loadmodule sch_prio
loadmodule sch_tbf
loadmodule sch_fq_codel
loadmodule cls_u32
loadmodule cls_fw
loadmodule cls_flow
loadmodule cls_basic
loadmodule act_police

View File

@@ -1,51 +0,0 @@
#
# Shorewall6 -- /usr/share/shorewall6/modules.xtables
#
# Xtables Modules File
#
# This file loads the modules that may be needed by the firewall.
#
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
# dependency order. i.e., if M2 depends on M1 then you must load M1
# before you load M2.
#
# If you need to modify this file, copy it to /etc/shorewall and modify the
# copy.
#
###############################################################################
loadmodule xt_AUDIT
loadmodule xt_CLASSIFY
loadmodule xt_connmark
loadmodule xt_CONNMARK
loadmodule xt_conntrack
loadmodule xt_dccp
loadmodule xt_dscp
loadmodule xt_DSCP
loadmodule xt_hashlimit
loadmodule xt_helper
loadmodule xt_iprange
loadmodule xt_length
loadmodule xt_limit
loadmodule xt_mac
loadmodule xt_mark
loadmodule xt_MARK
loadmodule xt_multiport
loadmodule xt_NFQUEUE
loadmodule xt_owner
loadmodule xt_physdev
loadmodule xt_pkttype
loadmodule xt_policy
loadmodule xt_sctp
loadmodule xt_tcpmss
loadmodule xt_TCPMSS
loadmodule xt_time
loadmodule xt_IPMARK
loadmodule xt_TPROXY
#
# From xtables-addons
#
loadmodule xt_condition
loadmodule xt_geoip
loadmodule xt_ipp2p
loadmodule xt_LOGMARK
loadmodule xt_RAWNAT

View File

@@ -85,7 +85,7 @@
server. It then sends a packet addressed to itself and from the server. server. It then sends a packet addressed to itself and from the server.
Such packets are sent back out the same interface that received them Such packets are sent back out the same interface that received them
(<firstterm>hairpin</firstterm>). In cases where the (<firstterm>hairpin</firstterm>). In cases where the
<option>routerfilter</option> option can't be used, Shorewall 4.4.20 and <option>routefilter</option> option can't be used, Shorewall 4.4.20 and
later will set up hairpinning traps (see the SFILTER_DISPOSITION and later will set up hairpinning traps (see the SFILTER_DISPOSITION and
SFILTER_LOG_LEVEL options in <ulink SFILTER_LOG_LEVEL options in <ulink
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).</para> url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).</para>

View File

@@ -244,9 +244,25 @@ DNAT net:<emphasis>address</emphasis> loc:<emphasis>local-IP-address</empha
work</title> work</title>
<para><emphasis role="bold">Answer:</emphasis> That is usually the <para><emphasis role="bold">Answer:</emphasis> That is usually the
result of one of four things:</para> result of one of five things:</para>
<itemizedlist> <itemizedlist>
<listitem>
<para>You are trying to redirect a UDP port and there is already a
conntrack table entry for the flow, created via an ACCEPT
rule.</para>
<para>Example:</para>
<programlisting> DNAT loc:192.168.0.2 dmz:192.168.1.3 udp 53</programlisting>
<para>Assuming that you have installed the
<emphasis>conntrack</emphasis> package, you can delete all such
conntrack table entries using:</para>
<programlisting> conntrack -D -s 192.168.0.2 -p udp --dport 53</programlisting>
</listitem>
<listitem> <listitem>
<para>You are trying to test from inside your firewall (no, that <para>You are trying to test from inside your firewall (no, that
won't work -- see <xref linkend="faq2"/>).</para> won't work -- see <xref linkend="faq2"/>).</para>

View File

@@ -5,7 +5,7 @@
<!--$Id: template.xml 5908 2007-04-12 23:04:36Z teastep $--> <!--$Id: template.xml 5908 2007-04-12 23:04:36Z teastep $-->
<articleinfo> <articleinfo>
<title>Shorewall 5.0 Manpages</title> <title>Shorewall 5.* Manpages</title>
<authorgroup> <authorgroup>
<author> <author>
@@ -18,7 +18,7 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate> <pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright> <copyright>
<year>2007-2017</year> <year>2007-2019</year>
<holder>Thomas M. Eastep</holder> <holder>Thomas M. Eastep</holder>
</copyright> </copyright>
@@ -53,6 +53,10 @@
<member><ulink url="manpages/shorewall-actions.html">actions</ulink> - <member><ulink url="manpages/shorewall-actions.html">actions</ulink> -
Declare user-defined actions.</member> Declare user-defined actions.</member>
<member><ulink
url="/manpages/shorewall-addresses.html">addresses</ulink> - Describes
how IP address and ports are specified in Shorewall</member>
<member><ulink url="manpages/shorewall-arprules.html">arprules</ulink> <member><ulink url="manpages/shorewall-arprules.html">arprules</ulink>
- (Added in Shorewall 4.5.12) Define arpfilter rules.</member> - (Added in Shorewall 4.5.12) Define arpfilter rules.</member>
@@ -71,6 +75,9 @@
url="manpages/shorewall-exclusion.html">exclusion</ulink> - Excluding url="manpages/shorewall-exclusion.html">exclusion</ulink> - Excluding
hosts from a network or zone</member> hosts from a network or zone</member>
<member><ulink url="/manpages/shorewall-files.html">files</ulink> -
Describes the shorewall configuration files</member>
<member><ulink url="manpages/shorewall-hosts.html">hosts</ulink> - <member><ulink url="manpages/shorewall-hosts.html">hosts</ulink> -
Define multiple zones accessed through a single interface</member> Define multiple zones accessed through a single interface</member>
@@ -96,7 +103,11 @@
Define Masquerade/SNAT (deprecated)</member> Define Masquerade/SNAT (deprecated)</member>
<member><ulink url="manpages/shorewall-modules.html">modules</ulink> - <member><ulink url="manpages/shorewall-modules.html">modules</ulink> -
Specify which kernel modules to load.</member> Specify which kernel modules to load (Removed in Shorewall
5.2.3)</member>
<member><ulink url="/manpages/shorewall-names.html">names</ulink> -
Describes object naming in Shorewall configuration files</member>
<member><ulink url="manpages/shorewall-nat.html">nat</ulink> - Define <member><ulink url="manpages/shorewall-nat.html">nat</ulink> - Define
one-to-one NAT.</member> one-to-one NAT.</member>

View File

@@ -386,6 +386,10 @@
<filename>modules</filename> or <filename>helpers</filename> file <filename>modules</filename> or <filename>helpers</filename> file
found on the CONFIG_PATH on the Administrative System during found on the CONFIG_PATH on the Administrative System during
compilation will be used.</para> compilation will be used.</para>
<para>In Shorewall 5.2.3, the LOAD_HELPERS_ONLY option was removed and
the behavior is that which was formerly obtained by setting
LOAD_HELPERS_ONLY=Yes.</para>
</section> </section>
<section id="Converting"> <section id="Converting">

View File

@@ -18,7 +18,7 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate> <pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright> <copyright>
<year>2001-2017</year> <year>2001-2019</year>
<holder>Thomas M. Eastep</holder> <holder>Thomas M. Eastep</holder>
</copyright> </copyright>
@@ -56,7 +56,7 @@
Shorewall</ulink> is required reading for being able to use this article Shorewall</ulink> is required reading for being able to use this article
effectively. For information about setting up your first Shorewall-based effectively. For information about setting up your first Shorewall-based
firewall, see the <ulink url="GettingStarted.html">Quickstart firewall, see the <ulink url="GettingStarted.html">Quickstart
Guides</ulink>.</para> Guides</ulink>.in</para>
</section> </section>
<section id="Files"> <section id="Files">
@@ -283,8 +283,8 @@
<listitem> <listitem>
<para><filename>/usr/share/shorewall/modules</filename> — Specifies <para><filename>/usr/share/shorewall/modules</filename> — Specifies
the kernel modules to be loaded during shorewall the kernel modules to be loaded during shorewall start/restart
start/restart.</para> (removed in Shorewall 5.2.3).</para>
</listitem> </listitem>
<listitem> <listitem>
@@ -802,9 +802,9 @@ DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }</programlisting
<term>INLINE</term> <term>INLINE</term>
<listitem> <listitem>
<para>INLINE, added in Shorewall 4. is available in the mangle, masq <para>INLINE, added in Shorewall 4. is available in the mangle, snat
and rules files and allows you to specify ip[6]table text following (masq) and rules files and allows you to specify ip[6]table text
a semicolon to the right of the column-oriented following two semicolons to the right of the column-oriented
specifications.</para> specifications.</para>
<para>INLINE takes one optional parameter which, if present, must be <para>INLINE takes one optional parameter which, if present, must be
@@ -852,12 +852,13 @@ INLINE net $FW ;; -m recent --rcheck 10 --hitcount 5
column=value specifications. In Shorewall 5.0.0 and later, inline column=value specifications. In Shorewall 5.0.0 and later, inline
matches are allowed in mangle, masq and rules following two adjacent matches are allowed in mangle, masq and rules following two adjacent
semicolons (";;"). If alternate input is present, the adjacent semicolons (";;"). If alternate input is present, the adjacent
semicolons should follow that input.</para> semicolons should follow that input. In Shorewall 5.2.2, this
support was extended to the conntrack file.</para>
<caution> <caution>
<para>INLINE_MATCHES=Yes is deprecated and will no longer be <para>INLINE_MATCHES=Yes is deprecated and is not supported in
supported in Shorewall 5.2 and beyond. Use two adjacent semicolons Shorewall 5.2 and beyond. Use two adjacent semicolons to introduce
to introduce inline matches.</para> inline matches.</para>
</caution> </caution>
<para>Example from the masq file that spits outgoing SNAT between <para>Example from the masq file that spits outgoing SNAT between

View File

@@ -486,6 +486,11 @@ root@lists:~# </programlisting>
<filename>/usr/share/shorewall/modules</filename>. That file does not set <filename>/usr/share/shorewall/modules</filename>. That file does not set
<emphasis role="bold">sip_direct_media=0</emphasis>.</para> <emphasis role="bold">sip_direct_media=0</emphasis>.</para>
<important>
<para>In Shorewall 5.2.3, the LOAD_HELPERS_ONLY option was removed and
the behavior is the same as if LOAD_HELPERS_ONLY=Yes.</para>
</important>
<para>If you need to modify either <para>If you need to modify either
<filename>/usr/share/shorewall/helpers</filename> or <filename>/usr/share/shorewall/helpers</filename> or
<filename>/usr/share/shorewall/modules</filename> then copy the file to <filename>/usr/share/shorewall/modules</filename> then copy the file to

View File

@@ -799,6 +799,12 @@ root@lists:~# </programlisting>
<para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para> <para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para>
<para>Modify the setting of LOAD_HELPER_ONLY as necessary.</para> <para>Modify the setting of LOAD_HELPER_ONLY as necessary.</para>
<important>
<para>In Shorewall 5.2.3, the LOAD_HELPERS_ONLY option was removed, and
the behavior is the same as if LOAD_HELPERS_ONLY=Yes was
specified.</para>
</important>
</section> </section>
<section id="DNAT"> <section id="DNAT">

View File

@@ -751,6 +751,12 @@ root@lists:~# </programlisting>
<para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para> <para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para>
<para>Modify the setting of LOAD_HELPER_ONLY as necessary.</para> <para>Modify the setting of LOAD_HELPER_ONLY as necessary.</para>
<important>
<para>In Shorewall 5.2.3, the LOAD_HELPERS_ONLY option was removed, and
the behavior is the same as if LOAD_HELPERS_ONLY=Yes was
specified.</para>
</important>
</section> </section>
<section id="DNAT"> <section id="DNAT">

View File

@@ -10,7 +10,9 @@
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate> <pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
<copyright> <copyright>
<year>2003-2009</year> <year>2003-2013</year>
<year>2019</year>
<holder>Thomas M. Eastep</holder> <holder>Thomas M. Eastep</holder>
</copyright> </copyright>
@@ -79,7 +81,7 @@
<row rowsep="0" valign="middle"> <row rowsep="0" valign="middle">
<entry>Debian apt-get sources for Shorewall: <ulink <entry>Debian apt-get sources for Shorewall: <ulink
url="http://people.connexer.com/~roberto/debian/"></ulink>http://people.connexer.com/~roberto/debian/</entry> url="http://people.connexer.com/~roberto/debian/">http://people.connexer.com/~roberto/debian/</ulink></entry>
</row> </row>
<row rowsep="0" valign="middle"> <row rowsep="0" valign="middle">
@@ -88,45 +90,51 @@
</row> </row>
<row rowsep="0" valign="middle"> <row rowsep="0" valign="middle">
<entry>Tom's 2005 LinuxFest NW Presentation: <ulink <entry>Tom's 2005 LinuxFest NW Presentation - "Shorewall and Native
IPsec" : <ulink
url="http://www.shorewall.net/LinuxFest2005.pdf">http://www.shorewall.net/LinuxFest2005.pdf</ulink></entry> url="http://www.shorewall.net/LinuxFest2005.pdf">http://www.shorewall.net/LinuxFest2005.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2006 LinuxFest NW Presentation: <ulink <entry>Tom's 2006 LinuxFest NW Presentation - "OpenVPN" : <ulink
url="http://www.shorewall.net/LinuxFest2006.pdf">http://www.shorewall.net/LinuxFest2006.pdf</ulink></entry> url="http://www.shorewall.net/LinuxFest2006.pdf">http://www.shorewall.net/LinuxFest2006.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2007 LinuxFest NW Presentation: <ulink <entry>Tom's 2007 LinuxFest NW Presentation - "Xen and the Art of
Consolidation" : <ulink
url="http://www.shorewall.net/Linuxfest-2007.pdf">http://www.shorewall.net/Linuxfest-2007.pdf</ulink></entry> url="http://www.shorewall.net/Linuxfest-2007.pdf">http://www.shorewall.net/Linuxfest-2007.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2008 LinuxFest NW Presentation: <ulink <entry>Tom's 2008 LinuxFest NW Presentation - "Kernel-mode Virtual
Machine (KVM)" : <ulink
url="http://www.shorewall.net/Linuxfest-2008.pdf">http://www.shorewall.net/Linuxfest-2008.pdf</ulink></entry> url="http://www.shorewall.net/Linuxfest-2008.pdf">http://www.shorewall.net/Linuxfest-2008.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2009 LinuxFest NW Presentation: <ulink <entry>Tom's 2009 LinuxFest NW Presentation - "Introduction to IPv6"
: <ulink
url="http://www.shorewall.net/Linuxfest-2009.pdf">http://www.shorewall.net/LinuxFestNW-2009.pdf</ulink></entry> url="http://www.shorewall.net/Linuxfest-2009.pdf">http://www.shorewall.net/LinuxFestNW-2009.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2010 LinuxFest NW Presentation: <ulink <entry>Tom's 2010 LinuxFest NW Presentation - "Managing Multiple
Internet Connections with Shorewall" : <ulink
url="http://www.shorewall.net/LinuxfestNW-2010.pdf">http://www.shorewall.net/LinuxFestNW-2010.pdf</ulink></entry> url="http://www.shorewall.net/LinuxfestNW-2010.pdf">http://www.shorewall.net/LinuxFestNW-2010.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2011 LinuxFest NW Presentation: <ulink <entry>Tom's 2011 LinuxFest NW Presentation - "LXC - Linux
Containers" : <ulink
url="http://www.shorewall.net/Linuxfest2011.pdf">http://www.shorewall.net/LinuxFest2011.pdf</ulink></entry> url="http://www.shorewall.net/Linuxfest2011.pdf">http://www.shorewall.net/LinuxFest2011.pdf</ulink></entry>
</row> </row>
<row> <row>
<entry>Tom's 2013 SeaGL Presentation: <ulink <entry>Tom's 2013 SeaGL Presentation - "AN INTRODUCTION TO LINUX
POLICY ROUTING" : <ulink
url="http://www.shorewall.net/SeaGL2013.pdf">http://www.shorewall.net/SeaGL2013.pdf</ulink></entry> url="http://www.shorewall.net/SeaGL2013.pdf">http://www.shorewall.net/SeaGL2013.pdf</ulink></entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
</informaltable> </informaltable>