Compare commits

..

55 Commits

Author SHA1 Message Date
Tom Eastep
68c0897352 Update GEOIPDIR setting info
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-17 16:30:50 -07:00
Tom Eastep
344bbeacb7 Update ipset article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-14 10:30:43 -07:00
Tom Eastep
2f56edc1ed Document TC/IPSec issue
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-02 12:23:54 -07:00
Tom Eastep
bc4c6637c3 Correct IPv6 ACK handling in Simple TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-01 17:44:55 -07:00
Tom Eastep
070efee47a Add ?FORMAT 2 to Shorewall6 tcpri file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-31 12:23:17 -07:00
Tom Eastep
d03146491b Merge branch 'master' of ssh://gitlab.com/shorewall/code 2020-07-26 09:53:16 -07:00
Tom Eastep
995a939a37 Add target file(s) 5.2.7-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-25 18:57:19 -07:00
Tom Eastep
ca19feae69 Correct tunnels file in Shared Config Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-19 09:43:09 -07:00
Tom Eastep
bc7082fb2a Merge branch '5.2.6'
# Conflicts:
#	docs/docs-targetname
#	docs/images/docs-images-targetname

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-18 17:05:51 -07:00
Tom Eastep
109ae7e038 Link the simple TC article to FAQs 97 and 97a
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-18 17:01:33 -07:00
Tom Eastep
b3ebcc8025 Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:30 -07:00
Tom Eastep
954c0185fa Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:22 -07:00
Tom Eastep
8d025e3821 Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:14 -07:00
Tom Eastep
49ba75252e Add target file(s) 5.2.6.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-12 19:46:23 -07:00
Tom Eastep
c835fead34 Add target file(s) 5.2.6.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-12 19:46:13 -07:00
Tom Eastep
ac221348c0 Add an SPORT column to the tcpri file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-09 14:15:03 -07:00
Tom Eastep
381a0ad8aa Add an IFB and SNAT/MASQUERADE section to the TC doc
- Removed the obsolete Kernel Config section

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-08 15:58:51 -07:00
Tom Eastep
4b3f9ae1e7 Clean up the connmark implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 18:23:39 -07:00
Tom Eastep
89201bd294 Add TC connmark support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 16:44:20 -07:00
Tom Eastep
b617c8d224 Rodrigo Araujo's tc connmark patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 14:28:21 -07:00
Tom Eastep
d1d8371eb8 Rules tweak
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 12:27:48 -07:00
Tom Eastep
5d58b5da72 Avoid '::' in $CONFIG_PATH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 16:00:15 -07:00
Tom Eastep
4469ddb861 Don't apply the deprecated directory more than once
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 15:38:28 -07:00
Tom Eastep
cd5409d633 Take care of '$LOG_LEVEL' during update
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 15:38:01 -07:00
Tom Eastep
2f58d4e368 Don't create a zone forwarding chain for local zones
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 09:06:03 -07:00
Tom Eastep
31844d22cd Update Shared Config article for July 2020 configuration
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 08:56:31 -07:00
Tom Eastep
628f5f0903 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-07-05 15:31:03 -07:00
Tom Eastep
ce73c783dc Avoid Perl diagnostic when updating shorewall[6].conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 15:29:34 -07:00
Tom Eastep
e7318459f1 Avoid double colons in the CONFIG_PATH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 15:27:47 -07:00
Tom Eastep
467d41f0cc Merge branch '5.2.6'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 13:23:48 -07:00
Tom Eastep
ff64539de3 Update shared config document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 13:19:15 -07:00
Tom Eastep
418f96082e Add target file(s) 5.2.6-base
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 10:48:56 -07:00
Tom Eastep
b761a6eaa0 Call optimize_policy_chains() after doing other ruleset optimization
- This insures that ACCEPT policy chains are optimized when EXPAND_POLICIES=No

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 10:40:43 -07:00
Tom Eastep
f8b7815375 Call optimize_policy_chains() after doing other ruleset optimization
- This insures that ACCEPT policy chains are optimized when EXPAND_POLICIES=No

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 09:49:28 -07:00
Tom Eastep
d643f57bc1 Add the -D option to shorewall usage output
- Also delete an incorrect -D description in shorewall(8)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-30 14:56:41 -07:00
Tom Eastep
d1c7b3d9da Add target file(s) 5.2.6-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 13:48:53 -07:00
Tom Eastep
d399fd0815 Add target file(s) 5.2.6-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 13:48:15 -07:00
Tom Eastep
3dc14e3575 Work around for Centos 7 iptables bug
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 11:27:14 -07:00
Tom Eastep
7ba6ac71e3 Delete blank line
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-28 20:41:21 -07:00
Tom Eastep
10aef23ab1 Correct handling of ";;+" in the snat file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-28 11:03:04 -07:00
Tom Eastep
e3f139bbdb Add SPORT column to the snat file (FORMAT 2)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 14:50:23 -07:00
Tom Eastep
e4f24f41fd Add target file(s) 5.2.6-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 10:25:51 -07:00
Tom Eastep
d0e4c53bd0 Add target file(s) 5.2.6-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 10:24:45 -07:00
Tom Eastep
43ac903085 Correct action dport implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 16:55:39 -07:00
Tom Eastep
28b92dae32 Update version for PORT->DPORT snat column naming
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 15:34:16 -07:00
Tom Eastep
bac493c2c5 Merge branch '5.2.5' 2020-06-26 15:31:51 -07:00
Tom Eastep
3ed1cdec94 Rename the snat PORT column to DPORT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 14:44:00 -07:00
Tom Eastep
3f5bdfd705 Process the firewall.conf file when running shorewall[6]-lite
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-25 13:32:36 -07:00
Tom Eastep
c9512dfaf8 Make 'show actions' more robust
- Show all lines, including continuation and compiler directives
- Show both actions and actions.std entries
- The actions file need not reside in /etc/shorewall[6] but may be in
  any directory on the CONFIG_PATH

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-25 11:28:08 -07:00
Matt Darfeuille
af2b7e6fc1 List supported releases
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:30:38 -07:00
Matt Darfeuille
01bfdabd5a Avoid exporting targetfiles
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:30:38 -07:00
Tom Eastep
c234a1a0ec Merge branch '5.2.5' 2020-06-20 10:02:53 -07:00
Tom Eastep
7ca18c410b Remove duplicates from the output of 'show actions'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-15 13:12:43 -07:00
Tom Eastep
e2aeed898d Add the 'dport' option to the actions file(s)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-15 13:12:06 -07:00
Tom Eastep
2eb1c88555 Omit superfluous test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-14 15:00:49 -07:00
32 changed files with 823 additions and 388 deletions

View File

@@ -1 +1 @@
5.2.5-Beta2
5.2.6-base

View File

@@ -25,7 +25,7 @@
# loaded after this one and replaces some of the functions declared here.
#
SHOREWALL_CAPVERSION=50200
SHOREWALL_CAPVERSION=50207
if [ -z "$g_basedir" ]; then
#
@@ -937,11 +937,28 @@ show_events() {
fi
}
sort_actions() {
local sep #separates sort keys from the action[.std] record
sep="##"
awk -v sep="$sep" \
'BEGIN { action = ""; ifrec = ""; nr = 0; };\
/^#/ { next; };\
/^\?(if|IF|If)/ { ifrec = $0; nr = NR; next; };\
/^( |\t|\?)/ { if ( action != "" ) print action, NR, sep $0; next; };\
{ action = $1; };\
nr != 0 { print action , nr, sep ifrec; nr = 0; };\
{ print action , NR, sep $0; }' | sort -k 1,2 | sed "s/^.*${sep}//"
}
show_actions() {
if [ -f ${g_confdir}/actions ]; then
cat ${g_sharedir}/actions.std ${g_confdir}/actions | grep -Ev '^[#?[:space:]]|^$'
local actions
actions=$(find_file actions)
if [ -f ${actions} ]; then
cat ${actions} ${g_sharedir}/actions.std | sort_actions
else
grep -Ev '^[#?[:space:]]|^$' ${g_sharedir}/actions.std
sort_actions < ${g_sharedir}/actions.std
fi
}
@@ -1108,10 +1125,6 @@ show_blacklists() {
show_bl;
}
show_actions_sorted() {
show_actions | sort -u -k 1,1
}
show_macros() {
for directory in $(split $CONFIG_PATH); do
temp=
@@ -1543,7 +1556,7 @@ show_command() {
;;
actions)
[ $# -gt 1 ] && too_many_arguments $2
eval show_actions_sorted $g_pager
eval show_actions $g_pager
return
;;
macro)
@@ -2865,6 +2878,7 @@ determine_capabilities() {
NETMAP_TARGET=
NFLOG_SIZE=
RESTORE_WAIT_OPTION=
CONNMARK_ACTION=
AMANDA_HELPER=
FTP_HELPER=
@@ -3232,6 +3246,10 @@ determine_capabilities() {
BASIC_FILTER=Yes
$TC filter add basic help 2>&1 | egrep -q match && BASIC_EMATCH=Yes
fi
if $TC action add connmark help 2>&1 | grep -q ^Usage; then
CONNMARK_ACTION=Yes
fi
fi
[ -n "$IP" ] && $IP rule add help 2>&1 | grep -q /MASK && FWMARK_RT_MASK=Yes
@@ -3375,6 +3393,7 @@ report_capabilities_unsorted() {
report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET
report_capability "--nflog-size support (NFLOG_SIZE)" $NFLOG_SIZE
report_capability "INPUT chain in nat table (NAT_INPUT_CHAIN)" $NAT_INPUT_CHAIN
report_capability "TC connmark support (CONNMARK_ACTION)" $CONNMARK_ACTION
echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
echo " Capabilities Version (CAPVERSION): $CAPVERSION"
@@ -3481,6 +3500,7 @@ report_capabilities_unsorted1() {
report_capability1 NFLOG_SIZE
report_capability1 RESTORE_WAIT_OPTION
report_capability1 NAT_INPUT_CHAIN
report_capability1 CONNMARK_ACTION
report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER
@@ -4012,7 +4032,7 @@ get_config() {
ensure_config_path
[ -f $g_firewall.conf ] && . ${VARDIR}/firewall.conf
[ -f ${VARDIR}/firewall.conf ] && . ${VARDIR}/firewall.conf
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -4346,9 +4366,9 @@ usage() # $1 = exit status
echo " add <interface>[:<host-list>] ... <zone>"
echo " allow <address> ..."
echo " blacklist <address> [ <option> ... ]"
ecko " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ <directory> ]"
ecko " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ -D ] [ <directory> ]"
echo " clear"
ecko " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ <directory name> ] [ <path name> ]"
ecko " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ -D ] [ <directory name> ] [ <path name> ]"
echo " close <source> <dest> [ <protocol> [ <port> ] ]"
echo " delete <interface>[:<host-list>] ... <zone>"
echo " disable <interface>"
@@ -4388,7 +4408,7 @@ usage() # $1 = exit status
if [ -n "$g_lite" ]; then
echo " reload [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else
echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ -D ] [ <directory> ]"
fi
if [ -z "$g_lite" ]; then
@@ -4404,7 +4424,7 @@ usage() # $1 = exit status
if [ -n "$g_lite" ]; then
echo " restart [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ -D ] [ <directory> ]"
fi
echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]"

View File

@@ -337,8 +337,15 @@ ensure_config_path() {
. $F
fi
if [ -n "$g_shorewalldir" ]; then
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
if [ -n "$g_shorewalldir" ] && [ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ];then
case $CONFIG_PATH in
:*)
CONFIG_PATH=${g_shorewalldir}${CONFIG_PATH}
;;
*)
CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
;;
esac
fi
}

View File

@@ -2118,10 +2118,6 @@
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5)
(<ulink
url="/manpages/shorewall.conf.html">shorewall6.conf</ulink>(5).</para>
<para>The <emphasis role="bold">-D </emphasis>option was added in
Shoewall 5.2.4 and causes the compiler to write a large amount of
debugging information to standard output.</para>
</listitem>
</varlistentry>

View File

@@ -894,7 +894,7 @@ sub validate_port( $$ ) {
fatal_error "The separator for a port range is ':', not '-' ($port)" if $port =~ /^\d+-\d+$/;
fatal_error "Invalid/Unknown $proto port/service ($_[1])" unless defined $value;
fatal_error "Invalid/Unknown $proto port/service ($_[1])";
}
#

View File

@@ -858,13 +858,13 @@ sub compiler {
if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) {
progress_message2 'Optimizing Ruleset...';
#
# Optimize the ruleet
#
optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK;
#
# Optimize Policy Chains
#
optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4
#
# More Optimization
#
optimize_ruleset if $config{OPTIMIZE} & OPTIMIZE_RULESET_MASK;
optimize_policy_chains if $optimize & OPTIMIZE_POLICY_MASK;
}
enable_script;
@@ -928,16 +928,16 @@ sub compiler {
optimize_level0;
if ( ( my $optimize = $config{OPTIMIZE} ) & 0x1e ) {
if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) {
progress_message2 'Optimizing Ruleset...';
#
# Optimize Policy Chains
#
optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4
#
# Ruleset Optimization
#
optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK;
#
# Optimize Policy Chains
#
optimize_policy_chains if $optimize & OPTIMIZE_POLICY_MASK;
}
enable_script if $debug;

View File

@@ -311,7 +311,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
OPTIMIZE_MASK
OPTIMIZE_POLICY_MASK
OPTIMIZE_POLICY_MASK2n4
OPTIMIZE_RULESET_MASK
OPTIMIZE_ALL
) , ] ,
@@ -503,6 +502,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
RESTORE_WAIT_OPTION
=> 'iptables-restore --wait option',
NAT_INPUT_CHAIN => 'INPUT chain in NAT table',
CONNMARK_ACTION => 'TC connmark support',
#
# Helpers
#
@@ -555,7 +555,6 @@ use constant {
#
use constant {
OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains()
OPTIMIZE_POLICY_MASK2n4 => 0x06 ,
OPTIMIZE_RULESET_MASK => 0x1C , # Call optimize_ruleset()
OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1
OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories.
@@ -885,8 +884,8 @@ sub initialize($;$$$$) {
TC_SCRIPT => '',
EXPORT => 0,
KLUDGEFREE => '',
VERSION => '5.2.4.1',
CAPVERSION => 50200 ,
VERSION => '5.2.7-Beta1',
CAPVERSION => 50207 ,
BLACKLIST_LOG_TAG => '',
RELATED_LOG_TAG => '',
MACLIST_LOG_TAG => '',
@@ -1180,6 +1179,7 @@ sub initialize($;$$$$) {
NFLOG_SIZE => undef,
RESTORE_WAIT_OPTION => undef,
NAT_INPUT_CHAIN => undef,
CONNMARK_ACTION => undef ,
AMANDA_HELPER => undef,
FTP_HELPER => undef,
@@ -4415,7 +4415,9 @@ sub validate_level( $;$ ) {
sub default_log_level( $$ ) {
my ( $level, $default ) = @_;
my $value = $config{$level};
my $value = $config{$level} || '';
$value = $config{LOG_LEVEL} if $value eq '$LOG_LEVEL'; #This can happen during update
unless ( supplied $value ) {
$config{$level} = validate_level $default, $level;
@@ -5052,6 +5054,10 @@ sub Basic_Filter() {
$tc && system( "$tc filter add basic help 2>&1 | grep -q ^Usage" ) == 0;
}
sub Connmark_Action() {
$tc && system( "$tc action add connmark help 2>&1 | grep -q ^Usage" ) == 0;
}
sub Basic_Ematch() {
$tc && have_capability( 'BASIC_FILTER' ) && system( "$tc filter add basic help 2>&1 | egrep -q match" ) == 0;
}
@@ -5181,6 +5187,7 @@ our %detect_capability =
COMMENTS => \&Comments,
CONNLIMIT_MATCH => \&Connlimit_Match,
CONNMARK => \&Connmark,
CONNMARK_ACTION => \&Connmark_Action,
CONNMARK_MATCH => \&Connmark_Match,
CONNTRACK_MATCH => \&Conntrack_Match,
CPU_FANOUT => \&Cpu_Fanout,
@@ -5374,17 +5381,12 @@ sub ensure_config_path() {
my $chop = ( $path =~ s/^:// );
$path =~ s/:+/:/g;
@config_path = split /:/, $path;
shift @config_path if $chop && ( $export || $> != 0 );
#
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
# clash on a case-insensitive filesystem.
#
push @config_path, $globals{SHAREDIR} . "/deprecated";
push @config_path, $shorewallrc{SHAREDIR}. '/shorewall/deprecated' unless $globals{PRODUCT} eq 'shorewall';
for ( @config_path ) {
$_ .= '/' unless m|/$|;
s|//|/|g;
@@ -5528,6 +5530,8 @@ sub update_config_file( $ ) {
for ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT/ ) {
my $policy = $config{ $_ };
$policy = '' unless defined $policy;
if ( $policy =~ /\bA_(?:Drop|Reject)\b/ ) {
if ( $family == F_IPV4 ) {
$policy =~ s/A_(?:Drop|Reject)/Broadcast(A_DROP),Multicast(A_DROP)/;
@@ -6317,6 +6321,14 @@ sub get_configuration( $$$ ) {
process_shorewall_conf( $update, $annotate );
ensure_config_path;
#
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
# clash on a case-insensitive filesystem.
#
push @config_path, $globals{SHAREDIR} . "/deprecated/" unless $config_path[-1] eq $globals{SHAREDIR} . "/deprecated/";
push @config_path, $shorewallrc{SHAREDIR}. '/shorewall/deprecated/' unless $globals{PRODUCT} eq 'shorewall';
$config{CONFIG_PATH} = join( ':', @config_path );
@INC = @originalinc;
@@ -6834,6 +6846,12 @@ sub get_configuration( $$$ ) {
require_capability 'AUDIT_TARGET', "SMURF_DISPOSITION=$val", 's' if $val =~ /^A_/;
if ( supplied( $val = $config{LOG_LEVEL} ) ) {
validate_level( $val );
} else {
$config{LOG_LEVEL} = 'info';
}
default_log_level 'BLACKLIST_LOG_LEVEL', '';
default_log_level 'MACLIST_LOG_LEVEL', '';
default_log_level 'TCP_FLAGS_LOG_LEVEL', '';
@@ -6842,12 +6860,6 @@ sub get_configuration( $$$ ) {
default_log_level 'INVALID_LOG_LEVEL', '';
default_log_level 'UNTRACKED_LOG_LEVEL', '';
if ( supplied( $val = $config{LOG_LEVEL} ) ) {
validate_level( $val );
} else {
$config{LOG_LEVEL} = 'info';
}
if ( supplied( $val = $config{LOG_BACKEND} ) ) {
if ( $family == F_IPV4 && $val eq 'ULOG' ) {
$val = 'ipt_ULOG';

View File

@@ -2288,12 +2288,15 @@ sub generate_matrix() {
#
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
unless ( $zoneref->{type} == LOCAL ) {
if ( @zones > 2 || $zoneref->{complex} ) {
handle_complex_zone( $zone, $zoneref );
} else {
new_standard_chain zone_forward_chain( $zone ) if @zones > 1;
}
}
}
#
# Main source-zone matrix-generation loop
#

View File

@@ -661,7 +661,7 @@ sub handle_nfqueue( $ ) {
if ( supplied $queue2 ) {
require_capability 'CPU_FANOUT', '"c"', 's' if $fanout;
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${fanout}${bypass}";
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}${fanout}";
} else {
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
}
@@ -1001,6 +1001,24 @@ sub determine_action_protocol( $$ ) {
$proto;
}
sub determine_action_dport( $$$ ) {
my ( $action, $proto, $dport ) = @_;
if ( my $actiondport = $actions{$action}{dport} ) {
if ( $dport eq '-' ) {
$dport = $actiondport;
} else {
fatal_error( "The $action action is only usable with destination port $actiondport" ) if $dport =~ /[,]/;
if ( ( my $portnum = validate_port( $proto, $dport ) ) ne '-' ) {
fatal_error( "The $action action is only usable with destination port $actiondport" ) unless $actiondport = $portnum;
$dport = $portnum;
}
}
}
$dport;
}
sub add_policy_rules( $$$$$ ) {
my ( $chainref , $target, $loglevel, $pactions, $dropmulticast ) = @_;
@@ -1015,7 +1033,11 @@ sub add_policy_rules( $$$$$ ) {
# Policy action is a regular action -- jump to the action chain
#
if ( ( my $proto = determine_action_protocol( $action, '-' ) ) ne '-' ) {
if ( my $dport = determine_action_dport( $action, $proto, '' ) ) {
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto, dport => $dport );
} else {
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto );
}
} else {
add_ijump $chainref, j => use_policy_action( $paction, $chainref->{name} );
}
@@ -1501,13 +1523,13 @@ sub external_name( $ ) {
#
# Define an Action
#
sub new_action( $$$$$$ ) {
sub new_action( $$$$$$$ ) {
my ( $action , $type, $options , $actionfile , $state, $proto ) = @_;
my ( $action , $type, $options , $actionfile , $state, $proto, $dport ) = @_;
fatal_error "Reserved action name ($action)" if reserved_name( $action );
$actions{$action} = { file => $actionfile, actchain => '' , type => $type, options => $options , state => $state, proto => $proto };
$actions{$action} = { file => $actionfile, actchain => '' , type => $type, options => $options , state => $state, proto => $proto, dport => $dport };
$targets{$action} = $type;
}
@@ -1778,7 +1800,7 @@ sub isolate_basic_target( $ ) {
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ );
sub process_snat1( $$$$$$$$$$$$ );
sub process_snat1( $$$$$$$$$$$$$ );
sub perl_action_helper( $$;$$ );
#
@@ -1972,13 +1994,17 @@ sub process_action(\$\$$) {
set_inline_matches( $matches );
}
} else {
my ( $action, $source, $dest, $protos, $port, $ipsec, $mark, $user, $condition, $origdest, $probability) =
my ( $action, $source, $dest, $protos, $port, $sport, $ipsec, $mark, $user, $condition, $origdest, $probability);
if ( $file_format == 1 ) {
( $action, $source, $dest, $protos, $port, $ipsec, $mark, $user, $condition, $origdest, $probability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
ipsec => 5,
mark => 6,
user => 7,
@@ -1989,6 +2015,28 @@ sub process_action(\$\$$) {
{},
11,
1 );
$sport = '-';
} else {
( $action, $source, $dest, $protos, $port, $sport, $ipsec, $mark, $user, $condition, $origdest, $probability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
sport => 5,
ipsec => 6,
mark => 7,
user => 8,
switch => 9,
origdest => 10,
probability => 11,
},
{},
12,
1 );
}
fatal_error 'ACTION must be specified' if $action eq '-';
@@ -2004,6 +2052,7 @@ sub process_action(\$\$$) {
$dest,
$proto,
$port,
$sport,
$ipsec,
$mark,
$user,
@@ -2102,6 +2151,7 @@ sub process_actions() {
my $state = '';
my $proto = 0;
my $dport = 0;
if ( $action =~ /:/ ) {
warning_message 'Policy Actions are now specified in /etc/shorewall/shorewall.conf';
@@ -2121,6 +2171,10 @@ sub process_actions() {
} elsif ( /^proto=(.+)$/ ) {
fatal_error "Unknown Protocol ($1)" unless defined( $proto = resolve_proto( $1 ) );
fatal_error "A protocol may not be specified on the REJECT_ACTION ($action)" if $action eq $config{REJECT_ACTION};
} elsif ( /^dport=(.+)$/ ) {
fatal_error "The 'dport' option requires the 'proto' option" unless $proto;
$dport = validate_port($proto, $1);
fatal_error "A destination port may not be specified on the REJECT_ACTION ($action)" if $action eq $config{REJECT_ACTION};
} else {
fatal_error "Invalid option ($_)" unless $options{$_};
$opts |= $options{$_};
@@ -2142,10 +2196,12 @@ sub process_actions() {
}
$proto = $actions{$action}{proto} unless $proto;
$dport = $actions{$action}{dport} unless $dport;
delete $actions{$action};
delete $targets{$action};
} elsif ( ( $actiontype & INLINE ) && ( $type == ACTION ) && $opts & NOINLINE_OPT ) {
$proto = $actions{$action}{proto} unless $proto;
$dport = $actions{$action}{dport} unless $dport;
delete $actions{$action};
delete $targets{$action};
} else {
@@ -2189,7 +2245,7 @@ sub process_actions() {
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
new_action ( $action, $type, $opts, $actionfile , $state , $proto );
new_action ( $action, $type, $opts, $actionfile , $state , $proto , $dport );
}
}
}
@@ -3068,9 +3124,11 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
if ( $actiontype & ACTION ) {
#
# Verify action 'proto', if any
# Verify action 'proto', and 'dport' if any
#
$proto = determine_action_protocol( $basictarget, $proto );
if ( ( $proto = determine_action_protocol( $basictarget, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $basictarget, $proto, $ports );
}
#
# Save NAT-oriented column contents
#
@@ -3928,9 +3986,8 @@ sub process_rules() {
#
for my $zone ( @zones ) {
my $zoneref = find_zone( $zone );
my $simple = @zones <= 2 && ! $zoneref->{complex};
unless ( @zones <= 2 && ! $zoneref->{complex} ) {
unless ( $zoneref->{type} == LOCAL || ( @zones <= 2 && ! $zoneref->{complex} ) ) {
#
# Complex zone or we have more than one non-firewall zone -- create a zone forwarding chain
#
@@ -4822,9 +4879,11 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
function => sub() {
fatal_error( qq(Action $cmd may not be used in the mangle file) ) unless $actiontype & MANGLE_TABLE;
#
# Verify action 'proto', if any
# Verify action 'proto' and 'dport' if any
#
$proto = determine_action_protocol( $cmd, $proto );
if ( ( $proto = determine_action_protocol( $cmd, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $cmd, $proto, $ports );
}
#
# Create the action:level:tag:param tuple.
#
@@ -5368,8 +5427,8 @@ sub process_mangle_rule( $ ) {
}
}
sub process_snat_inline( $$$$$$$$$$$$$$ ) {
my ($inline, $chainref, $params, $loglevel, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
sub process_snat_inline( $$$$$$$$$$$$$$$ ) {
my ($inline, $chainref, $params, $loglevel, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my ( $level,
$tag ) = split( ':', $loglevel, 2 );
@@ -5388,18 +5447,22 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
progress_message "..Expanding inline action $inlinefile...";
push_open $inlinefile, 2, 1, undef , 2;
push_open $inlinefile, 2, 1, undef , 1;
my $save_comment = push_comment;
while ( read_a_line( NORMAL_READ ) ) {
my ( $maction, $msource, $mdest, $mprotos, $mports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) =
my ( $maction, $msource, $mdest, $mprotos, $mports, $msports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability);
if ( $file_format == 1 ) {
( $maction, $msource, $mdest, $mprotos, $mports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
ipsec => 5,
mark => 6,
user => 7,
@@ -5410,6 +5473,28 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
{},
11,
1 );
$msports = '-';
} else {
( $maction, $msource, $mdest, $mprotos, $mports, $msports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
sport => 5,
ipsec => 6,
mark => 7,
user => 8,
switch => 9,
origdest => 10,
probability => 11,
},
{},
12,
1 );
}
fatal_error 'ACTION must be specified' if $maction eq '-';
@@ -5437,6 +5522,7 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
$mdest,
$proto,
merge_macro_column( $mports, $ports ),
merge_macro_column( $msports, $sports ),
merge_macro_column( $mipsec, $ipsec ),
merge_macro_column( $mmark, $mark ),
merge_macro_column( $muser, $user ),
@@ -5463,8 +5549,8 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
#
# Process a record in the snat file
#
sub process_snat1( $$$$$$$$$$$$ ) {
my ( $chainref, $origaction, $source, $dest, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
sub process_snat1( $$$$$$$$$$$$$ ) {
my ( $chainref, $origaction, $source, $dest, $proto, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $inchain;
my $inaction;
@@ -5484,7 +5570,6 @@ sub process_snat1( $$$$$$$$$$$$ ) {
my ( $action, $loglevel ) = split_action( $origaction );
my $logaction;
my $param;
#
# Handle early matches
#
@@ -5584,7 +5669,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
#
# Handle Protocol, Ports and Condition
#
$baserule .= do_proto( $proto, $ports, '' );
$baserule .= do_proto( $proto, $ports, $sports );
#
# Handle Mark
#
@@ -5831,6 +5916,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
supplied( $destnets ) && $destnets ne '-' ? $inaction || $interface ? join( ':', $interface, $destnets ) : $destnets : $inaction ? '-' : $interface,
$proto,
$ports,
$sports,
$ipsec,
$mark,
$user,
@@ -5841,9 +5927,11 @@ sub process_snat1( $$$$$$$$$$$$ ) {
if ( $actiontype & ACTION ) {
fatal_error( qq(Action $target may not be used in the snat file) ) unless $actiontype & NAT_TABLE;
#
# Verify action 'proto', if any
# Verify action 'proto' and 'dport', if any
#
$proto = determine_action_protocol( $target, $proto );
if ( ( $proto = determine_action_protocol( $target, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $target, $proto, $ports );
}
#
# Create the action:level:tag:param tuple. Since we don't allow logging out of nat POSTROUTING, we store
# the interface name in the log tag
@@ -5941,18 +6029,30 @@ sub process_snat1( $$$$$$$$$$$$ ) {
sub process_snat( )
{
my ($action, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
my ($action, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability );
if ( $file_format == 1 ) {
($action, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'snat file',
{ action => 0, source => 1, dest => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{ action => 0, source => 1, dest => 2, proto => 3, port => 4, dport => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
11, #Columns
1 ); #Allow inline matches
$sports = '-';
} else {
($action, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'snat file',
{ action => 0, source => 1, dest => 2, proto => 3, port => 4, dport => 4, sport => 5, ipsec => 6, mark => 7, user => 8, switch => 9, origdest => 10, probability => 11 },
{}, #Nopad
12, #Columns
1 ); #Allow inline matches
}
fatal_error 'ACTION must be specified' if $action eq '-';
fatal_error 'DEST must be specified' if $dest eq '-';
for my $proto ( split_list $protos, 'Protocol' ) {
process_snat1( undef, $action, $source, $dest, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
process_snat1( undef, $action, $source, $dest, $proto, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability );
}
}
@@ -5967,7 +6067,7 @@ sub setup_snat()
#
# Masq file was empty or didn't exist
#
if ( $fn = open_file( 'snat', 1, 1 ) ) {
if ( $fn = open_file( 'snat', 2, 1, undef, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty snat file" , 's'; } );
process_snat while read_a_line( NORMAL_READ );
}

View File

@@ -365,9 +365,7 @@ sub process_simple_device() {
emit( "run_tc filter add dev $physical parent $number:0 protocol all prio 1 u32" .
"\\\n match ip6 protocol 6 0xff" .
"\\\n match u8 0x05 0x0f at 0" .
"\\\n match u16 0x0000 0xffc0 at 2" .
"\\\n match u8 0x10 0xff at 33 flowid $number:1\n" );
"\\\n match u8 0x10 0xff at 53 flowid $number:1\n" );
save_progress_message_short qq(" TC Device $physical defined.");
@@ -422,8 +420,8 @@ sub validate_tc_device( ) {
fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device};
fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/;
my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize ) =
(0, 0, '', 'htb', '', 0, 0, 0, 0);
my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize, $connmark ) =
(0, 0, '', 'htb', '', 0, 0, 0, 0, 0);
if ( $options ne '-' ) {
for my $option ( split_list1 $options, 'option' ) {
@@ -458,6 +456,9 @@ sub validate_tc_device( ) {
$tsize = numeric_value( $1 );
fatal_error "Invalid tsize ($1)" unless defined $tsize;
fatal_error q('tsize' requires 'linklayer') unless $linklayer;
} elsif ( $option eq 'connmark' ) {
require_capability( 'CONNMARK_ACTION', q(The 'connmark' option), 's' );
$connmark = 1;
} else {
fatal_error "Unknown device option ($option)";
}
@@ -470,7 +471,7 @@ sub validate_tc_device( ) {
if ( @redirected ) {
fatal_error "IFB devices may not have IN-BANDWIDTH" if $inband ne '-' && $inband;
$classify = 1;
$classify = 1 unless $connmark;
for my $rdevice ( @redirected ) {
fatal_error "Invalid device name ($rdevice)" if $rdevice =~ /[:+]/;
@@ -478,6 +479,8 @@ sub validate_tc_device( ) {
fatal_error "REDIRECTED device ($rdevice) has not been defined in this file" unless $rdevref;
fatal_error "IN-BANDWIDTH must be zero for REDIRECTED devices" if $rdevref->{in_bandwidth} != 0;
}
} elsif ( $connmark ) {
fatal_error "Option connmark can only be used when setting up a IFB device";
}
$inband = process_in_bandwidth( $inband );
@@ -503,6 +506,7 @@ sub validate_tc_device( ) {
mpu => $mpu,
tsize => $tsize,
filterpri => 0,
connmark => $connmark,
} ,
push @tcdevices, $device;
@@ -661,6 +665,7 @@ sub validate_tc_class( ) {
if ( $mark ne '-' ) {
fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS};
fatal_error "MARK may not be specified for an interface with the 'classify' option" if $devref->{classify};
( $mark, my $priority ) = split/:/, $mark, 2;
@@ -1639,8 +1644,8 @@ sub process_tcfilters() {
#
# Process a tcpri record
#
sub process_tc_priority1( $$$$$$ ) {
my ( $band, $proto, $ports , $address, $interface, $helper ) = @_;
sub process_tc_priority1( $$$$$$$ ) {
my ( $band, $proto, $dports , $sports, $address, $interface, $helper ) = @_;
my $val = numeric_value $band;
@@ -1651,7 +1656,7 @@ sub process_tc_priority1( $$$$$$ ) {
$rule .= join('', '/', in_hex( $globals{TC_MASK} ) ) if have_capability( 'EXMARK' );
if ( $interface ne '-' ) {
fatal_error "Invalid combination of columns" unless $address eq '-' && $proto eq '-' && $ports eq '-';
fatal_error "Invalid combination of columns" unless $address eq '-' && $proto eq '-' && $dports eq '-' && $sports eq '-';
my $forwardref = $mangle_table->{tcfor};
@@ -1662,41 +1667,57 @@ sub process_tc_priority1( $$$$$$ ) {
my $postref = $mangle_table->{tcpost};
if ( $address ne '-' ) {
fatal_error "Invalid combination of columns" unless $proto eq '-' && $ports eq '-';
fatal_error "Invalid combination of columns" unless $proto eq '-' && $dports eq '-' && $sports eq '-';
add_rule( $postref ,
join( '', match_source_net( $address) , $rule ) ,
1 );
} else {
add_rule( $postref ,
join( '', do_proto( $proto, $ports, '-' , 0 ) , $rule ) ,
join( '', do_proto( $proto, $dports, $sports , 0 ) , $rule ) ,
1 );
if ( $ports ne '-' ) {
if ( $dports ne '-' ) {
my $protocol = resolve_proto $proto;
if ( $proto =~ /^ipp2p/ ) {
fatal_error "ipp2p may not be used when there are tracked providers and PROVIDER_OFFSET=0" if @routemarked_interfaces && $config{PROVIDER_OFFSET} == 0;
$ipp2p = 1;
}
} elsif ( $file_format == 1 ) {
add_rule( $postref ,
join( '' , do_proto( $proto, '-', $ports, 0 ) , $rule ) ,
join( '' , do_proto( $proto, '-', $dports, 0 ) , $rule ) ,
1 )
unless $proto =~ /^ipp2p/ || $protocol == ICMP || $protocol == IPv6_ICMP;
}
}
}
}
}
sub process_tc_priority() {
my ( $band, $protos, $ports , $address, $interface, $helper ) =
split_line1( 'tcpri',
{ band => 0, proto => 1, port => 2, address => 3, interface => 4, helper => 5 } );
my ( $band, $protos, $dports , $sports, $address, $interface, $helper );
if ( $file_format == 1 ) {
( $band, $protos, $dports , $address, $interface, $helper ) =
split_line2( 'tcpri',
{ band => 0, proto => 1, port => 2, dport => 2, address => 3, interface => 4, helper => 5 },
{},
6,
1 );
$sports = '-';
} else {
( $band, $protos, $dports , $sports, $address, $interface, $helper ) =
split_line2( 'tcpri',
{ band => 0, proto => 1, port => 2, dport => 2, sport => 3, address => 4, interface => 5, helper => 6 },
{},
7,
1 );
};
fatal_error 'BAND must be specified' if $band eq '-';
fatal_error "Invalid tcpri entry" if ( $protos eq '-' &&
$ports eq '-' &&
$dports eq '-' &&
$sports eq '-' &&
$address eq '-' &&
$interface eq '-' &&
$helper eq '-' );
@@ -1706,7 +1727,7 @@ sub process_tc_priority() {
fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3;
for my $proto ( split_list $protos, 'Protocol' ) {
process_tc_priority1( $band, $proto, $ports , $address, $interface, $helper );
process_tc_priority1( $band, $proto, $dports , $sports, $address, $interface, $helper );
}
}
@@ -1728,7 +1749,7 @@ sub process_tcinterfaces() {
#
sub process_tcpri() {
my $fn = find_file 'tcinterfaces';
my $fn1 = open_file 'tcpri', 1,1;
my $fn1 = open_file 'tcpri', 2,1,0,1;
if ( $fn1 ) {
first_entry
@@ -1865,7 +1886,7 @@ sub process_traffic_shaping() {
for my $rdev ( @{$devref->{redirected}} ) {
my $phyrdev = physical_name( $rdev );
emit ( "run_tc qdisc add dev $phyrdev handle ffff: ingress" );
emit( "run_tc filter add dev $phyrdev parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev $device > /dev/null" );
emit( "run_tc filter add dev $phyrdev parent ffff: protocol all u32 match u32 0 0".($devref->{'connmark'} ? ' action connmark' : '')." action mirred egress redirect dev $device > /dev/null" );
}
for my $class ( @tcclasses ) {

View File

@@ -12,8 +12,9 @@
# For information about entries in this file, type "man shorewall-snat"
#
# See https://shorewall.org/manpages/shorewall-snat.html for more information
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
?FORMAT 2
###################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
#
# Rules generated from masq file /home/teastep/shorewall/trunk/Shorewall/Samples/three-interfaces/masq by Shorewall 5.0.13-RC1 - Sat Oct 15 11:43:47 PDT 2016
#

View File

@@ -12,8 +12,9 @@
# For information about entries in this file, type "man shorewall-snat"
#
# See https://shorewall.org/manpages/shorewall-snat.html for more information
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
?FORMAT 2
###################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
#
# Rules generated from masq file /home/teastep/shorewall/trunk/Shorewall/Samples/two-interfaces/masq by Shorewall 5.0.13-RC1 - Sat Oct 15 11:41:40 PDT 2016
#

View File

@@ -1 +1 @@
5.2.5.1
5.2.7-Beta1

View File

@@ -5,5 +5,6 @@
#
# See https://shorewall.org/manpages/shorewall-snat.html for more information
#
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
?FORMAT 2
###################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY

View File

@@ -6,5 +6,6 @@
# See https://shorewall.org/simple_traffic_shaping.htm for additional
# information.
#
?FORMAT 2
###############################################################################
#BAND PROTO PORT ADDRESS INTERFACE HELPER
#BAND PROTO DPORT SPORT ADDRESS INTERFACE HELPER

View File

@@ -26,8 +26,8 @@
<title>Description</title>
<para>This file allows you to define new ACTIONS for use in rules (see
<ulink url="shorewall-rules.html">shorewall-rules(5)</ulink>).
You define the iptables rules to be performed in an ACTION in
<ulink url="shorewall-rules.html">shorewall-rules(5)</ulink>). You define
the iptables rules to be performed in an ACTION in
/etc/shorewall/action.<emphasis>action-name</emphasis>.</para>
<para>Columns are:</para>
@@ -148,8 +148,8 @@
<listitem>
<para>Added in Shorewall 5.0.7. Specifies that this action is
to be used in <ulink
url="shorewall-mangle.html">shorewall-mangle(5)</ulink>
rather than <ulink
url="shorewall-mangle.html">shorewall-mangle(5)</ulink> rather
than <ulink
url="shorewall-rules.html">shorewall-rules(5)</ulink>.</para>
</listitem>
</varlistentry>
@@ -160,11 +160,11 @@
<listitem>
<para>Added in Shorewall 5.0.13. Specifies that this action is
to be used in <ulink
url="shorewall-snat.html">shorewall-snat(5)</ulink>
rather than <ulink
url="shorewall-rules.html">shorewall-rules(5)</ulink>.
The <option>mangle</option> and <option>nat</option> options
are mutually exclusive.</para>
url="shorewall-snat.html">shorewall-snat(5)</ulink> rather
than <ulink
url="shorewall-rules.html">shorewall-rules(5)</ulink>. The
<option>mangle</option> and <option>nat</option> options are
mutually exclusive.</para>
</listitem>
</varlistentry>
@@ -212,6 +212,24 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>dport</option>=<replaceable>portorservice</replaceable></term>
<listitem>
<para>Added in Shorewall 5.2.6. Requires that the <emphasis
role="bold">proto</emphasis> option be previously given and
indicates that this action may only be applied to flows with
the specified <replaceable>protocol</replaceable> and
<replaceable>portorservice</replaceable>.
<replaceable>portorservice</replaceable> may be a valid port
number or the name of a service defined in /etc/services to be
usable with the specified <replaceable>protocol</replaceable>.
If a port or service is specified in the DPORT column of an
invocation, then it must match the named
<replaceable>portorservice</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>section</option></term>

View File

@@ -39,12 +39,26 @@
<para>If you have more than one ISP link, adding entries to this file
will <emphasis role="bold">not</emphasis> force connections to go out
through a particular link. You must use entries in <ulink
url="shorewall-rtrules.html">shorewall-rtrules</ulink>(5) or
PREROUTING entries in <ulink
url="shorewall-rtrules.html">shorewall-rtrules</ulink>(5) or PREROUTING
entries in <ulink
url="shorewall-mangle.html">shorewall-mangle</ulink>(5) to do
that.</para>
</warning>
<para>Beginning with Shorewall 5.2.6, the snat file supports two different
formats:</para>
<orderedlist>
<listitem>
<para>The SPORT (source port) column is omitted. This is the default
unless a "?FORMAT 2" compiler directive is included.</para>
</listitem>
<listitem>
<para>The SPORT column immediately follows the DPORT column.</para>
</listitem>
</orderedlist>
<para>The columns in the file are as follows.</para>
<variablelist>
@@ -68,10 +82,10 @@
<listitem>
<para>where <replaceable>action</replaceable> is an action
declared in <ulink
url="shorewall-actions.html">shorewall-actions(5)</ulink>
with the <option>nat</option> option. See <ulink
url="../Actions.html">https://shorewall.org/Actions.html</ulink> for
further information.</para>
url="shorewall-actions.html">shorewall-actions(5)</ulink> with
the <option>nat</option> option. See <ulink
url="../Actions.html">https://shorewall.org/Actions.html</ulink>
for further information.</para>
</listitem>
</varlistentry>
@@ -165,9 +179,9 @@
<para>If you specify an address here, matching packets will
have their source address set to that address. If
ADD_SNAT_ALIASES is set to Yes or yes in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5)
then Shorewall will automatically add this address to the
INTERFACE named in the first column (IPv4 only).</para>
url="shorewall.conf.html">shorewall.conf</ulink>(5) then
Shorewall will automatically add this address to the INTERFACE
named in the first column (IPv4 only).</para>
<para>You may also specify a range of up to 256 IP addresses
if you want the SNAT address to be assigned from that range in
@@ -237,10 +251,10 @@
<para>Normally Masq/SNAT rules are evaluated after those for
one-to-one NAT (defined in <ulink
url="shorewall-nat.html">shorewall-nat</ulink>(5)). If you
want the rule to be applied before one-to-one NAT rules, follow the
action name with "+": This feature should only be required if you
need to insert rules in this file that preempt entries in <ulink
url="shorewall-nat.html">shorewall-nat</ulink>(5)). If you want the
rule to be applied before one-to-one NAT rules, follow the action
name with "+": This feature should only be required if you need to
insert rules in this file that preempt entries in <ulink
url="shorewall-nat.html">shorewall-nat</ulink>(5).</para>
</listitem>
</varlistentry>
@@ -279,23 +293,23 @@
networks. Multiple interfaces may be listed when the ACTION is
MASQUERADE, but this is usually just your internet interface. If
ADD_SNAT_ALIASES=Yes in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5), you
may add ":" and a <emphasis>digit</emphasis> to indicate that you
want the alias added with that name (e.g., eth0:0). This will allow
the alias to be displayed with ifconfig. <emphasis role="bold">That
is the only use for the alias name; it may not appear in any other
place in your Shorewall configuration.</emphasis></para>
url="shorewall.conf.html">shorewall.conf</ulink>(5), you may add ":"
and a <emphasis>digit</emphasis> to indicate that you want the alias
added with that name (e.g., eth0:0). This will allow the alias to be
displayed with ifconfig. <emphasis role="bold">That is the only use
for the alias name; it may not appear in any other place in your
Shorewall configuration.</emphasis></para>
<para>Beginning with Shorewall 5.1.12, SNAT may be performed in the
nat table's INPUT chain by specifying $FW rather than one or more
interfaces. </para>
interfaces.</para>
<para>Each interface must match an entry in <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
Shorewall allows loose matches to wildcard entries in <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
For example, <filename class="devicefile">ppp0</filename> in this
file will match a <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5). For
example, <filename class="devicefile">ppp0</filename> in this file
will match a <ulink
url="shorewall-interfaces.html">shorewall-interfaces</ulink>(5)
entry that defines <filename
class="devicefile">ppp+</filename>.</para>
@@ -315,8 +329,8 @@
addresses to indicate that you only want to change the source IP
address for packets being sent to those particular destinations.
Exclusion is allowed (see <ulink
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5))
as are ipset names preceded by a plus sign '+';</para>
url="shorewall-exclusion.html">shorewall-exclusion</ulink>(5)) as
are ipset names preceded by a plus sign '+';</para>
<para>If you wish to inhibit the action of ADD_SNAT_ALIASES for this
entry then include the ":" but omit the digit:</para>
@@ -341,8 +355,7 @@
<listitem>
<para>If you wish to restrict this entry to a particular protocol
then enter the protocol name (from protocols(5)) or number here. See
<ulink
url="shorewall-rules.html">shorewall-rules(5)</ulink> for
<ulink url="shorewall-rules.html">shorewall-rules(5)</ulink> for
details.</para>
<para>Beginning with Shorewall 4.5.12, this column can accept a
@@ -356,10 +369,14 @@
</varlistentry>
<varlistentry>
<term><emphasis role="bold">PORT</emphasis> (Optional) -
<term><emphasis role="bold">{PORT|DPORT}</emphasis> (Optional) -
{-|[!]<emphasis>port-name-or-number</emphasis>[,<emphasis>port-name-or-number</emphasis>]...|+<replaceable>ipset</replaceable>}</term>
<listitem>
<para>The column was renamed to DPORT in Shorewall 5.2.6. Beginning
with that release, both PORT and DPORT are accepted in the
alternative input format,</para>
<para>If the PROTO column specifies TCP (6), UDP (17), DCCP (33),
SCTP (132) or UDPLITE (136) then you may list one or more port
numbers (or names from services(5)) or port ranges separated by
@@ -375,6 +392,27 @@
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">SPORT
{-|[!]<replaceable>port-name-or-number</replaceable>[,<replaceable>port-name-or-number</replaceable>]...|+<replaceable>ipset</replaceable>}</emphasis></term>
<listitem>
<para>FORMAT 2 only.</para>
<para>If the PROTO column specifies TCP (6), UDP (17), DCCP (33),
SCTP (132) or UDPLITE (136) then you may list one or more port
numbers (or names from services(5)) or port ranges separated by
commas.</para>
<para>Port ranges are of the form
<emphasis>lowport</emphasis>:<emphasis>highport</emphasis>.</para>
<para>An <replaceable>ipset</replaceable> name can be specified in
this column. This is intended to be used with
<firstterm>bitmap:port</firstterm> ipsets.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">IPSEC</emphasis> (Optional) -
[<emphasis>option</emphasis>[<emphasis

View File

@@ -200,6 +200,11 @@
marks. You must do all classification using CLASSIFY rules in <ulink
url="shorewall-mangle.html">shorewall-mangle</ulink>(5).</para>
<para><emphasis role="bold">connmark</emphasis> -- Added in
Shorewall 5.2.7. May only be specified if the REDIRECTED_INTERFACES
column is non-empty. It allows packet marks to be used to classify
traffic for these interfaces.</para>
<para><option>htb</option> - Use the <firstterm>Hierarchical Token
Bucket</firstterm> queuing discipline. This is the default.</para>
@@ -248,7 +253,9 @@
enter each listed interface to be passed through the egress filters
defined for this device, thus providing a form of incoming traffic
shaping. When this column is non-empty, the <emphasis
role="bold">classify</emphasis> option is assumed.</para>
role="bold">classify</emphasis> option is assumed unless the
<emphasis role="bold">connmark</emphasis> option is
specified.</para>
</listitem>
</varlistentry>
</variablelist>

View File

@@ -27,8 +27,11 @@
<para>This file is used to specify the priority of traffic for simple
traffic shaping (TC_ENABLED=Simple in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5)). The
priority band of each packet is determined by the <emphasis
url="shorewall.conf.html">shorewall.conf</ulink>(5)). Beginning with
Shorewall 5.2.7, the file allows ?FORMAT 2 which inserts a SPORT column
immediately to the right of the DPORT column.</para>
<para>The priority band of each packet is determined by the <emphasis
role="bold">last</emphasis> entry that the packet matches. If a packet
doesn't match any entry in this file, then its priority will be determined
by its TOS field. The default mapping is as follows but can be changed by
@@ -87,15 +90,36 @@
</varlistentry>
<varlistentry>
<term>PORT(S) - <replaceable>port</replaceable> [,...]</term>
<term>DPORT - <replaceable>port</replaceable> [,...]</term>
<listitem>
<para>This column was named PORT prior to Shorewall 5.2.7. Both
'port' and 'dport' may be used in the <ulink
url="../configuration_file_basics.htm#Pairs">alternate input
format</ulink>.</para>
<para>Optional. May only be given if the the PROTO is TCP (6), UDP
(17), DCCP (33), SCTP (132) or UDPLITE (136). A list of one or more
port numbers or service names from /etc/services. Port ranges of the
form
<replaceable>lowport</replaceable>:<replaceable>highport</replaceable>
may also be included.</para>
may also be included. In format 1, packets whose source or
destination port matches the specified
<replaceable>port</replaceable>(s) are assigned to the band given in
the BAND column.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>SPORT - <replaceable>port</replaceable> [,...]</term>
<listitem>
<para>Only present in file format 2. Optional. May only be given if
the the PROTO is TCP (6), UDP (17), DCCP (33), SCTP (132) or UDPLITE
(136). A list of one or more port numbers or service names from
/etc/services. Port ranges of the form
<replaceable>lowport</replaceable>:<replaceable>highport</replaceable>
may also be included. </para>
</listitem>
</varlistentry>

View File

@@ -5,5 +5,7 @@
#
# See https://shorewall.org/manpages/shorewall-snat.html for more information
#
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
?FORMAT 2
###################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY

View File

@@ -6,5 +6,6 @@
# See https://shorewall.org/simple_traffic_shaping.htm for additional
# information.
#
?FORMAT 2
###############################################################################
#BAND PROTO PORT ADDRESS INTERFACE HELPER
#BAND PROTO DPORT SPORT ADDRESS INTERFACE HELPER

View File

@@ -2592,7 +2592,7 @@ eth0 External 50mbit:200kb 5.0mbit:100kb:200ms:100m
<programlisting><emphasis role="bold">ethtool -K eth<emphasis>N</emphasis> tso off gso off</emphasis></programlisting>
</section>
<section>
<section id="faq97a">
<title>(FAQ 97a) I enable Shorewall traffic shaping and now my download
rate is way below what I specified</title>

View File

@@ -57,11 +57,8 @@
</programlisting>
<para>Using this feature requires the <firstterm>GeoIP Match</firstterm>
capability in your iptables and kernel. As of this writing, that
capability requires installing <ulink
url="http://xtables-addons.sourceforge.net/">xtables-addons</ulink> 1.33
or later and <ulink
url="http://xtables-addons.sourceforge.net/geoip.php">creating a
capability in your iptables and kernel. That capability requires <ulink
url="https://dev.maxmind.com/geoip/geoip2/geolite2/">creating a
country-code database</ulink>.</para>
<para>The Shorewall compiler uses the geoip country-code database to
@@ -83,11 +80,19 @@
<para>To accomodate both big-endian and little-endian machines as well as
any future ability to install the database at another location, Shorewall
supports a GEOIPDIR option in <ulink
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5) and <ulink
url="manpages/shorewall.conf.html">shorewall6.conf</ulink> (5). The
default value of that option is
url="manpages/shorewall.conf.html">shorewall.conf</ulink>(5) and <ulink
url="manpages/shorewall.conf.html">shorewall6.conf</ulink>(5). The default
value of that option is
<filename>/usr/share/xt_geoip/LE</filename>.</para>
<important>
<para>Recent versions of the country-code database are installed in
<filename>/usr/share/xt_geoip/, regardless of endian convention. This
requires modifying the setting of GEOIPDIR in <ulink
url="manpages/shorewall.conf.html">shorewall.conf</ulink> (5) and <ulink
url="manpages/shorewall.conf.html">shorewall6.conf</ulink>(5).</filename></para>
</important>
<para>The country codes at the time of this writing are shown in the
following two sections.</para>
</section>

View File

@@ -68,9 +68,39 @@
provides access to a container running irssi under screen, allowing
constant access to and monitoring of IRC channels.</para>
<para>The firewall's local ethernet interface (eth2) is connected to a
Netgear GS108E smart switch with two vlans:</para>
<itemizedlist>
<listitem>
<para>VLAN 1 (eth2.1) is connected to a wireless access point
supporting both IPv4 (172.20.1.0/24) and IPv6
(2601:601:a000:16f2::/64).</para>
</listitem>
<listitem>
<para>VLAN 2 (eth2.2) is connected to devices located in my office
supporting both IPv4 (172.20.1.0/24) and IPv6
(2601:601:a000:16f2::/64).</para>
</listitem>
</itemizedlist>
<para>The switch's management interface is accessed via eth2
(192.168.0.0/24).</para>
<note>
<para>The GS108E does not currently support restricting the management
interface to a particular VLAN -- it is accessible from any connected
host whose IP configuration allows unrouted access to the switch's IP
address.</para>
</note>
<para>Here is a diagram of this installation:</para>
<graphic fileref="images/Network2020.png"/>
<para>The boxes in the diagram represent the six shorewall zones (The
firewall and IPSec vpn zone are not shown).</para>
</section>
<section>
@@ -79,39 +109,38 @@
<para>Here are the contents of /etc/shorewall/ and /etc/shorewal6/:</para>
<programlisting>root@gateway:~# ls -l /etc/shorewall
total 120
-rw-r--r-- 1 root root 201 Mar 19 2017 action.Mirrors
-rw-r--r-- 1 root root 109 Oct 20 2017 actions
total 132
-rw-r--r-- 1 root root 1152 May 18 10:51 action.NotSyn
-rw-r--r-- 1 root root 180 Jun 27 09:24 actions
-rw-r--r-- 1 root root 60 May 31 17:55 action.SSHLIMIT
-rw-r--r-- 1 root root 82 Oct 5 2018 arprules
-rw-r--r-- 1 root root 528 Oct 7 2019 blrules
-rw-r--r-- 1 root root 528 May 25 15:39 blrules
-rw-r--r-- 1 root root 1797 Sep 16 2019 capabilities
-rw-r--r-- 1 root root 656 Jun 10 2018 conntrack
-rw-r--r-- 1 root root 722 Jul 2 13:49 conntrack
-rw-r--r-- 1 root root 104 Oct 13 2017 hosts
-rw-r--r-- 1 root root 867 Jun 10 2018 interfaces
-rw-r--r-- 1 root root 1119 Jul 4 14:02 interfaces
-rw-r--r-- 1 root root 107 Jun 29 2017 isusable
-rw-r--r-- 1 root root 240 Oct 13 2017 macro.FTP
-rw-r--r-- 1 root root 705 Oct 22 2019 mangle
-rw-r--r-- 1 root root 1308 Apr 2 2018 mirrors
-rw-r--r-- 1 root root 2889 Apr 23 17:13 params
-rw-r--r-- 1 root root 1096 Oct 14 2019 policy
-rw-r--r-- 1 root root 773 Jul 2 15:04 mangle
-rw-r--r-- 1 root root 3108 Jul 3 15:51 params
-rw-r--r-- 1 root root 1108 Jul 3 16:25 policy
-rw-r--r-- 1 root root 2098 Apr 23 17:19 providers
-rw-r--r-- 1 root root 398 Mar 18 2017 proxyarp
-rw-r--r-- 1 root root 726 Oct 24 2018 routes
-rw-r--r-- 1 root root 729 Mar 1 11:08 rtrules
-rw-r--r-- 1 root root 8593 Feb 25 08:49 rules
-rw-r--r-- 1 root root 5490 Mar 1 18:34 shorewall.conf
-rw-r--r-- 1 root root 1090 Sep 16 2019 snat
-rw-r--r-- 1 root root 8589 Jul 4 09:34 rules
-rw-r--r-- 1 root root 5503 Jun 5 17:29 shorewall.conf
-rw-r--r-- 1 root root 1090 Jul 2 14:32 snat
-rw-r--r-- 1 root root 180 Jan 30 2018 started
-rw-r--r-- 1 root root 539 Feb 6 14:33 stoppedrules
-rw-r--r-- 1 root root 468 Apr 25 14:42 stoppedrules
-rw-r--r-- 1 root root 435 Oct 13 2017 tunnels
-rw-r--r-- 1 root root 941 Oct 15 2017 zones
-rw-r--r-- 1 root root 978 Jul 3 12:28 zones
root@gateway:~# ls -l /etc/shorewall6
total 12
-rw-r--r-- 1 root root 1786 Sep 16 2019 capabilities
lrwxrwxrwx 1 root root 20 Jul 6 2017 mirrors -&gt; ../shorewall/mirrors
lrwxrwxrwx 1 root root 19 Jul 6 2017 params -&gt; ../shorewall/params
-rw-r--r-- 1 root root 5324 Oct 18 2019 shorewall6.conf
root@gateway:~#</programlisting>
-rw-r--r-- 1 root root 5338 Jun 7 16:40 shorewall6.conf
</programlisting>
<para>The various configuration files are described in the sections that
follow. Note that in all cases, these files use the <ulink
@@ -210,8 +239,8 @@ LOGFORMAT="%s %s"
LOGTAGONLY=Yes
LOGLIMIT="s:5/min"
MACLIST_LOG_LEVEL="$LOG_LEVEL"
RELATED_LOG_LEVEL="$LOG_LEVEL:,related"
RPFILTER_LOG_LEVEL="$LOG_LEVEL:,rpfilter"
RELATED_LOG_LEVEL="$LOG_LEVEL:"
RPFILTER_LOG_LEVEL="$LOG_LEVEL:"
SFILTER_LOG_LEVEL="$LOG_LEVEL"
SMURF_LOG_LEVEL="$LOG_LEVEL"
STARTUP_LOG=/var/log/shorewall-init.log
@@ -272,7 +301,7 @@ DETECT_DNAT_IPADDRS=No
DISABLE_IPV6=No
DOCKER=No
DONT_LOAD="nf_nat_sip,nf_conntrack_sip,nf_conntrack_h323,nf_nat_h323"
DYNAMIC_BLACKLIST="ipset-only,disconnect,timeout=7200"
DYNAMIC_BLACKLIST="ipset-only,disconnect,timeout=7200,log,noupdate"
EXPAND_POLICIES=No
EXPORTMODULES=Yes
FASTACCEPT=Yes
@@ -384,7 +413,7 @@ LOGFORMAT="%s %s"
LOGLIMIT="s:5/min"
LOGTAGONLY=Yes
MACLIST_LOG_LEVEL="$LOG_LEVEL"
RELATED_LOG_LEVEL=
RELATED_LOG_LEVEL="$LOG_LEVEL"
RPFILTER_LOG_LEVEL="$LOG_LEVEL"
SFILTER_LOG_LEVEL="$LOG_LEVEL"
SMURF_LOG_LEVEL="$LOG_LEVEL"
@@ -412,7 +441,7 @@ TC=
# D E F A U L T A C T I O N S / M A C R O S
###############################################################################
ACCEPT_DEFAULT="none"
BLACKLIST_DEFAULT="AllowICMPs,Broadcast(DROP),Multicast(DROP),dropNotSyn:$LOG_LEVEL,dropInvalid:$LOG_LEVEL,DropDNSrep:$LOG_LEVEL"
BLACKLIST_DEFAULT="AllowICMPs,Broadcast(DROP),Multicast(DROP),NotSyn(DROP):$LOG_LEVEL,dropInvalid:$LOG_LEVEL,DropDNSrep:$LOG_LEVEL"
DROP_DEFAULT="AllowICMPs,Broadcast(DROP),Multicast(DROP)"
NFQUEUE_DEFAULT="none"
QUEUE_DEFAULT="none"
@@ -440,8 +469,8 @@ COMPLETE=No
DEFER_DNS_RESOLUTION=Yes
DELETE_THEN_ADD=No
DONT_LOAD=
DYNAMIC_BLACKLIST="ipset-only,disconnect,timeout=7200"
EXPAND_POLICIES=Yes
DYNAMIC_BLACKLIST="ipset-only,disconnect,timeout=7200,log,noupdate"
EXPAND_POLICIES=No
EXPORTMODULES=Yes
FASTACCEPT=Yes
FORWARD_CLEAR_MARK=No
@@ -501,7 +530,6 @@ PROVIDER_BITS=2
PROVIDER_OFFSET=8
MASK_BITS=8
ZONE_BITS=0
#LAST LINE -- DO NOT REMOVE
</programlisting>
</section>
</section>
@@ -520,9 +548,7 @@ ZONE_BITS=0
<para>The contents of /etc/shorewall/params is as follows:</para>
<programlisting>INCLUDE mirrors #Sets the MIRRORS variable for the Mirrors action
#
<programlisting>#
# Set compile-time variables depending on the address family
#
if [ $g_family = 4 ]; then
@@ -543,14 +569,17 @@ if [ $g_family = 4 ]; then
FAST_GATEWAY=10.2.10.1 # Default gateway through the IF_FAST interface
FAST_MARK=0x20000 # Multi-ISP mark setting for IF_FAST
IPSECMSS=1460
DBL_SET=SW_DBL4
#
# Interface Options
#
LOC_OPTIONS=dhcp,ignore=1,wait=5,routefilter,routeback,tcpflags=0,nodbl,physical=eth2
LOC_OPTIONS=dhcp,ignore=1,wait=5,routefilter,tcpflags=0,nodbl,physical=eth2.2
WLAN_OPTIONS=dhcp,ignore=1,wait=5,routefilter,tcpflags=0,nodbl,physical=eth2.1
FAST_OPTIONS=optional,dhcp,tcpflags,nosmurfs,sourceroute=0,arp_ignore=1,proxyarp=0,nosmurfs,rpfilter,physical=eth0
PROD_OPTIONS=optional,dhcp,tcpflags,nosmurfs,sourceroute=0,arp_ignore=1,proxyarp=0,nosmurfs,rpfilter,physical=eth1
DMZ_OPTIONS=routeback,proxyarp=1,required,wait=30,nets=70.90.191.120/29,nodbl,physical=br0
IRC_OPTIONS=routeback,proxyarp=1,required,wait=30,nets=172.20.2.0/24,dhcp,nodbl,physical=br1
SWCH_OPTIONS=dhcp,tcpflags=0,nodbl,physical=eth2
else
#
# IPv6 compilation
@@ -560,22 +589,24 @@ else
STATISTICAL=No # Don't use statistical load balancing
LISTS=[2001:470:b:227::42] # IP address of lists.shorewall.net (MX and HTTPS)
MAIL=[2001:470:b:227::45] # IP address of mail.shorewall.net (IMAPS and HTTPS)
SERVER=[2001:470:b:227::43] # IP address of www.shorewall.org (HTTP, FTP and RSYNC)
IRSSI=[2601:601:a000:16f1::]/64 # IP address of asus.shorewall.org (Bit Torrent)
SERVER=[2001:470:b:227::43] # IP address of server.shorewall.net(FTP)
IRSSI=[2601:601:a000:16f1::]/64 # IP address of irssi.shorewall.net
PROXY=Yes # Use TPROXY for local web access
ALL=[::]/0 # Entire address space
LOC_ADDR=[2601:601:a000:16f0::1] # IP address of the local LAN interface
FAST_GATEWAY=2601:601:a000:1600:22e5:2aff:feb7:f2cf
FAST_MARK=0x100 # Multi-ISP mark setting for IF_FAST
IPSECMSS=1440
DBL_SET=SW_DBL6
#
# Interface Options
#
PROD_OPTIONS=forward=1,optional,rpfilter,routeback,physical=sit1
FAST_OPTIONS=forward=1,optional,dhcp,rpfilter,physical=eth0
LOC_OPTIONS=forward=1,nodbl,routeback,physical=eth2
LOC_OPTIONS=forward=1,nodbl,routeback,physical=eth2.2
DMZ_OPTIONS=routeback,forward=1,required,wait=30,nodbl,physical=br0
IRC_OPTIONS=routeback,forward=1,required,wait=30,nodbl,physical=br1
WLAN_OPTIONS=forward=1,nodbl,routeback,physical=eth2.1
fi</programlisting>
</section>
@@ -584,19 +615,23 @@ fi</programlisting>
<para>Here is the /etc/shorewall/zones file:</para>
<programlisting>###############################################################################
#ZONE TYPE OPTIONS IN OUT
<programlisting>#ZONE TYPE OPTIONS IN OUT
# OPTIONS OPTIONS
#
# By using the 'ip' type, both Shorewall and Shorewall6 can share this file
#
fw { TYPE=firewall }
net { TYPE=ip }
loc { TYPE=ip }
dmz { TYPE=ip }
apps { TYPE=ip }
vpn { TYPE=ipsec, OPTIONS=mode=tunnel,proto=esp,mss=$IPSECMSS }
</programlisting>
wlan { TYPE=ip }
?if __IPV4
swch { TYPE=local }
?endif</programlisting>
</section>
<section>
@@ -619,12 +654,18 @@ vpn { TYPE=ipsec, OPTIONS=mode=tunnel,proto=esp,mss=$IPSECMSS }
# For IPv6, it is sit1 (Hurricane Electric 6in4 link)
# DMZ_IF is a bridge to the production containers
# IRC_IF is a bridge to a container that currently runs irssi under screen
# WLAN_IF is a vlan interface that connects to the wireless networks
# SWCH_IF is the vlan trunk interface used for switch management
loc { INTERFACE=LOC_IF, OPTIONS=$LOC_OPTIONS }
wlan { INTERFACE=WLAN_IF, OPTIONS=$WLAN_OPTIONS }
net { INTERFACE=FAST_IF, OPTIONS=$FAST_OPTIONS }
net { INTERFACE=PROD_IF, OPTIONS=$PROD_OPTIONS }
dmz { INTERFACE=DMZ_IF, OPTIONS=$DMZ_OPTIONS }
apps { INTERFACE=IRC_IF, OPTIONS=$IRC_OPTIONS }</programlisting>
apps { INTERFACE=IRC_IF, OPTIONS=$IRC_OPTIONS }
?if __IPV4
swch { INTERFACE=SWCH_IF, OPTIONS=$SWCH_OPTIONS }
?endif</programlisting>
</section>
<section>
@@ -643,7 +684,7 @@ vpn { HOSTS=LOC_IF:$ALL }</programlisting>
<para>The same set of policies apply to both address families:</para>
<programlisting>#SOURCE DEST POLICY LOGLEVEL RATE
<programlisting>SOURCE DEST POLICY LOGLEVEL RATE
$FW { DEST=dmz,net, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
@@ -653,7 +694,7 @@ $FW { DEST=all, POLICY=ACCEPT:Broadcast(ACCEPT),Multicast(ACCEPT), LOG
$FW { DEST=all, POLICY=ACCEPT:AllowICMPs,Broadcast(ACCEPT),Multicast(ACCEPT) LOGLEVEL=$LOG_LEVEL }
?endif
loc,apps { DEST=net, POLICY=ACCEPT }
loc,apps,wlan { DEST=net, POLICY=ACCEPT }
loc,vpn,apps { DEST=loc,vpn,apps POLICY=ACCEPT }
loc { DEST=fw, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
@@ -665,9 +706,8 @@ net { DEST=net, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
net { DEST=fw, POLICY=BLACKLIST:+Broadcast(DROP),Multicast(DROP),DropDNSrep:$LOG_LEVEL, LOGLEVEL=$LOG_LEVEL, RATE=8/sec:30 }
net { DEST=all, POLICY=BLACKLIST:+DropDNSrep:$LOG_LEVEL, LOGLEVEL=$LOG_LEVEL, RATE=8/sec:30 }
dmz { DEST=fw POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
dmz { DEST=dmz POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
dmz { DEST=fw, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
dmz { DEST=dmz, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }
all { DEST=all, POLICY=REJECT, LOGLEVEL=$LOG_LEVEL }</programlisting>
</section>
@@ -786,21 +826,16 @@ Tproxy { NUMBER=3, INTERFACE=lo, OPTIONS=tproxy }</programlisting>
<section>
<title>actions</title>
<para>/etc/shorewall/actions defines one action:</para>
<para>/etc/shorewall/actions defines a single action:</para>
<programlisting>#ACTION COMMENT
Mirrors # Accept traffic from Shorewall Mirrors
</programlisting>
<programlisting>#ACTION OPTIONS COMMENT
SSHLIMIT proto=tcp,\ # Blacklist overzealous SSHers
dport=ssh</programlisting>
<para>/etc/shorewall/action.Mirrors:</para>
<para>/etc/shorewall/action.SSHLIMIT:</para>
<programlisting>#TARGET SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE
# PORT PORT(S) DEST LIMIT
?COMMENT Accept traffic from Mirrors
?FORMAT 2
DEFAULTS -
$1 $MIRRORS
</programlisting>
<programlisting>ACCEPT { RATE=s:3/min:3 }
BLACKLIST:$LOG_LEVEL:net_SSHLIMIT</programlisting>
</section>
<section>
@@ -823,7 +858,9 @@ PARAM - - tcp 21
<para>In addition to invoking the FTP helper on TCP port 21, this file
notracks some IPv4 traffic:</para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT USER SWITCH
<programlisting>?FORMAT 3
######################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT USER SWITCH
CT:helper:ftp:P { PROTO=tcp, DPORT=21 }
CT:helper:ftp:O { PROTO=tcp, DPORT=21 }
@@ -835,10 +872,10 @@ CT:helper:ftp:O { PROTO=tcp, DPORT=21 }
NOTRACK:P { SOURCE=LOC_IF, DEST=172.20.1.255, PROTO=udp }
NOTRACK:P { DEST=255.255.255.255, PROTO=udp }
NOTRACK:O { DEST=255.255.255.255, PROTO=udp }
NOTRACK:O { DEST=172.20.1.255, PROTO=udp }
NOTRACK:O { DEST=70.90.191.127, PROTO=udp }
?endif
</programlisting>
NOTRACK:O { DEST=LOC_IF:172.20.0.255, PROTO=udp }
NOTRACK:O { DEST=LOC_IF:172.20.1.255, PROTO=udp }
NOTRACK:O { DEST=PROD_IF:70.90.191.127, PROTO=udp }
?endif</programlisting>
</section>
<section>
@@ -867,6 +904,7 @@ ACCEPT { SOURCE=loc, DEST=$FW, PROTO=tcp, helper=ftp }
ACCEPT { SOURCE=all, DEST=all, PROTO=icmp }
RST(ACCEPT) { SOURCE=all, DEST=all }
ACCEPT { SOURCE=dmz, DEST=dmz }
ACCEPT { SOURCE=$FW, DEST=$FW }
?SECTION INVALID
@@ -919,22 +957,30 @@ DROP:$LOG_LEVEL { SOURCE=net, DEST=all } ;;+ -p tcp -m tcpmss --mss 1:535
######################################################################################################
# Ping
#
Ping(ACCEPT) { SOURCE=$FW,loc,dmz,vpn,apps, DEST=$FW,loc,dmz,vpn,apps }
Ping(ACCEPT) { SOURCE=all!net, DEST=all }
Ping(ACCEPT) { SOURCE=dmz, DEST=dmz }
Ping(ACCEPT) { SOURCE=all, DEST=net }
?if __IPV4
Ping(ACCEPT) { source=$FW, DEST=swch }
?endif
######################################################################################################
# Logging
#
Syslog(ACCEPT) { SOURCE=dmz, DEST=$FW }
######################################################################################################
# SSH
#
AutoBL(SSH,60,-,-,-,-,$LOG_LEVEL)\
{ SOURCE=net, DEST=all, PROTO=tcp, DPORT=22 }
SSH(ACCEPT) { SOURCE=all, DEST=all }
SSH(DROP) { SOURCE=net, DEST=dmz:$SERVER }
SSHLIMIT { SOURCE=net, DEST=all }
?if __IPV4
SSH(ACCEPT) { SOURCE=all+!swch, DEST=all+ }
SSH(DNAT-) { SOURCE=net, DEST=172.20.2.44, PROTO=tcp, DPORT=ssh, ORIGDEST=70.90.191.123 }
?else
SSH(ACCEPT) { SOURCE=all+, DEST=all+ }
?endif
######################################################################################################
# DNS
#
DNS(ACCEPT) { SOURCE=loc,dmz,vpn,apps, DEST=$FW }
DNS(ACCEPT) { SOURCE=loc,dmz,vpn,apps,wlan, DEST=$FW }
DNS(ACCEPT) { SOURCE=$FW, DEST=net }
?if $TEST
DNS(REDIRECT) loc 53 - 53 - !&amp;LOC_IF
@@ -956,30 +1002,32 @@ SMTP(REJECT) { SOURCE=dmz:$LISTS, DEST=net }
IMAPS(ACCEPT) { SOURCE=all, DEST=dmz:$MAIL }
Submission(ACCEPT) { SOURCE=all, DEST=dmz:$LISTS }
SMTPS(ACCEPT) { SOURCE=all, DEST=dmz:$LISTS }
IMAP(ACCEPT) { SOURCE=loc,vpn, DEST=net }
IMAP(REJECT) { SOURCE=net, DEST=all }
######################################################################################################
# NTP
#
NTP(ACCEPT) { SOURCE=all, DEST=net }
######################################################################################################
# Squid
ACCEPT { SOURCE=loc,vpn, DEST=$FW, PROTO=tcp, DPORT=3128 }
ACCEPT { SOURCE=loc,vpn,wlan, DEST=$FW, PROTO=tcp, DPORT=3128 }
######################################################################################################
# HTTP/HTTPS
#
Web(ACCEPT) { SOURCE=loc,vpn DEST=$FW }
Web(ACCEPT) { SOURCE=loc,vpn,wlan DEST=$FW }
Web(ACCEPT) { SOURCE=$FW, DEST=net, USER=proxy }
Web(DROP) { SOURCE=net, DEST=fw, PROTO=tcp, comment="Do not blacklist web crawlers" }
HTTP(ACCEPT) { SOURCE=net,loc,vpn,$FW DEST=dmz:$SERVER,$LISTS,$MAIL }
HTTPS(ACCEPT) { SOURCE=net,loc,vpn,$FW DEST=dmz:$SERVER,$LISTS,$MAIL }
Web(ACCEPT) { SOURCE=dmz,apps DEST=net,$FW }
HTTP(ACCEPT) { SOURCE=net,loc,vpn,wlan,$FW DEST=dmz:$SERVER,$LISTS,$MAIL }
HTTPS(ACCEPT) { SOURCE=net,loc,vpn,wlan,$FW DEST=dmz:$SERVER,$LISTS,$MAIL }
Web(ACCEPT) { SOURCE=dmz,apps,loc,wlan, DEST=net,$FW }
Web(ACCEPT) { SOURCE=$FW, DEST=net, USER=root }
Web(ACCEPT) { SOURCE=$FW, DEST=net, USER=teastep }
?if __IPV4
Web(ACCEPT) { SOURCE=$FW, DEST=swch, USER=teastep }
?endif
Web(ACCEPT) { SOURCE=$FW, DEST=net, USER=_apt }
######################################################################################################
# FTP
#
FTP(ACCEPT) { SOURCE=loc,vpn,apps DEST=net }
FTP(ACCEPT) { SOURCE=dmz, DEST=net }
FTP(ACCEPT) { SOURCE=$FW, DEST=net, USER=root }
FTP(ACCEPT) { SOURCE=all, DEST=dmz:$SERVER }
@@ -1003,39 +1051,27 @@ Whois(ACCEPT) { SOURCE=all, DEST=net }
######################################################################################################
# SMB
#
SMBBI(ACCEPT) { SOURCE=loc, DEST=$FW }
SMBBI(ACCEPT) { SOURCE=loc,wlan, DEST=$FW }
SMBBI(ACCEPT) { SOURCE=vpn, DEST=$FW }
######################################################################################################
# IRC
#
SetEvent(IRC) { SOURCE=loc,apps, DEST=net, PROTO=tcp, DPORT=6667 }
IfEvent(IRC,ACCEPT,10,1,dst,reset) { SOURCE=net, DEST=loc,apps, PROTO=tcp, DPORT=113 }
SetEvent(IRC) { SOURCE=loc,apps,wlan, DEST=net, PROTO=tcp, DPORT=6667 }
IfEvent(IRC,ACCEPT,10,1,dst,reset) { SOURCE=net, DEST=loc,apps,wlan, PROTO=tcp, DPORT=113 }
######################################################################################################
# AUTH
Auth(REJECT) { SOURCE=net, DEST=all }
######################################################################################################
# Rsync
#
Mirrors(ACCEPT:none) { SOURCE=net, DEST=dmz:$SERVER, PROTO=tcp, DPORT=873 }
######################################################################################################
# IPSEC
#
?if __IPV4
DNAT { SOURCE=loc,net, DEST=apps:172.20.2.44, PROTO=udp, DPORT=500,4500, ORIGDEST=70.90.191.123 }
DNAT { SOURCE=loc,net,wlan, DEST=apps:172.20.2.44, PROTO=udp, DPORT=500,4500, ORIGDEST=70.90.191.123 }
?else
ACCEPT { SOURCE=loc,net, DEST=apps, PROTO=udp, DPORT=500,4500 }
ACCEPT { SOURCE=loc,net, DEST=apps, PROTO=esp }
ACCEPT { SOURCE=loc,net,wlan, DEST=apps, PROTO=udp, DPORT=500,4500 }
ACCEPT { SOURCE=loc,net,wlan, DEST=apps, PROTO=esp }
?endif
ACCEPT { SOURCE=$FW, DEST=net, PROTO=udp, SPORT=4500 }
######################################################################################################
# Bit Torrent
?if __IPV4
DNAT { SOURCE=net, DEST=apps:$IRSSIINT, PROTO=udp,tcp, DPORT=59410, ORIGDEST=$IRSSIEXT }
?else
ACCEPT { SOURCE=net, DEST=apps:$IRSSI, PROTO=udp,tcp, DPORT=59410 }
?endif
REJECT { SOURCE=net, DEST=all, PROTO=udp,tcp, DPORT=51413,59410 }
######################################################################################################
# VNC
ACCEPT { SOURCE=loc, DEST=$FW, PROTO=tcp, DPORT=5900 }
######################################################################################################
@@ -1046,6 +1082,10 @@ FIN(ACCEPT) { SOURCE=all, DEST=all }
# Multicast
?if __IPV4
Multicast(ACCEPT) { SOURCE=all, DEST=$FW }
?endif
######################################################################################################
?if __IPV4
ACCEPT { SOURCE=fw, DEST=all, PROTO=icmp, DPORT=host-unreachable }
?endif</programlisting>
</section>
@@ -1071,11 +1111,15 @@ TCPMSS(pmtu,none) { PROTO=tcp }
?if $PROXY
#
# Use TPROXY for IPv4 web access from the local LAN
# Use TPROXY for web access from the local LAN
#
DIVERT:R { PROTO=tcp, SPORT=80 }
DIVERT:R { PROTO=tcp, DPORT=80 }
TPROXY(3129,$LOC_ADDR) { SOURCE=LOC_IF, PROTO=tcp, DPORT=80 }
TPROXY(3129,$LOC_ADDR) { SOURCE=WLAN_IF, PROTO=tcp, DPORT=80 }
# DIVERT:R { PROTO=tcp, SPORT=443 }
# DIVERT:R { PROTO=tcp, DPORT=443 }
# TPROXY(3129,$LOC_ADDR) { SOURCE=LOC_IF, PROTO=tcp, DPORT=443 }
?endif</programlisting>
</section>
@@ -1084,11 +1128,10 @@ TCPMSS(pmtu,none) { PROTO=tcp }
<para>NAT entries are quite dependent on the address family:</para>
<programlisting>###################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
<programlisting>#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
?if __IPV4
MASQUERADE { SOURCE=172.20.1.0/24,172.20.2.0/23, DEST=FAST_IF }
MASQUERADE { SOURCE=172.20.0.0/22, DEST=FAST_IF }
MASQUERADE { SOURCE=70.90.191.120/29, DEST=FAST_IF }
SNAT(70.90.191.121) { SOURCE=!70.90.191.120/29, DEST=PROD_IF, PROBABILITY=0.50, COMMENT="Masquerade Local Network" }
SNAT(70.90.191.123) { SOURCE=!70.90.191.120/29, DEST=PROD_IF, COMMENT="Masquerade Local Network" }
@@ -1107,7 +1150,7 @@ TCPMSS(pmtu,none) { PROTO=tcp }
<programlisting>#TYPE ZONE GATEWAY GATEWAY_ZONE
ipsecnat {ZONE=net, GATEWAY=$ALL, GATEWAY_ZONE=vpn }
ipsecnat {ZONE=loc, GATEWAY=$ALL, GATEWAY_ZONE=vpn }
</programlisting>
ipsecnat {ZONE=wlan, GATEWAY=$ALL, GATEWAY_ZONE=vpn }</programlisting>
</section>
<section>
@@ -1154,7 +1197,9 @@ fi
<para>/etc/shorewall/stoppedrules allow SSH connections into the
firewall system when Shorewall[6] is in the stopped state.</para>
<programlisting/>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT
ACCEPT - $FW tcp 22
</programlisting>
</section>
</section>
</article>

View File

@@ -663,7 +663,7 @@ ACCEPT net:\
<row>
<entry>mangle</entry>
<entry>action,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers</entry>
<entry>action,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers,probability,dscp,switch</entry>
</row>
<row>
@@ -738,6 +738,14 @@ ACCEPT net:\
<entry>secmark,chain,source,dest,proto,dport,sport,user,mark</entry>
</row>
<row>
<entry>snat</entry>
<entry>action,source,dest,proto,port,sport,ipsec,mark,user,switch,origdest,probability
(Note: 'port' may be specified as 'dport', beginning with
Shorewall 5.2.6).</entry>
</row>
<row>
<entry>tcclasses</entry>

View File

@@ -1 +1 @@
5.2.5.1
5.2.7-RC1

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -1 +1 @@
5.2.5-Beta1
5.2.7-Beta1

View File

@@ -145,7 +145,8 @@ ACCEPT net:+sshok $FW tcp 22</programlisting></para>
<para>Beginning with Shorewall 4.4.14, multiple source or destination
matches may be specified by placing multiple set names in '+[...]' (e.g.,
+[myset,myotherset]). When so enclosed, the set names need not be prefixed
with a plus sign.</para>
with a plus sign. When such a list of sets is specified, matching packets
must match all of the listed sets.</para>
<para>Shorewall can save/restore your ipset contents with certain
restrictions:</para>

View File

@@ -93,6 +93,13 @@
qdisc but seems to provide a benefit when the actual link output
temporarily drops below the limit imposed by tbf or when tbf allows a
burst of traffic to be released.</para>
<caution>
<para>IPSec traffic passes through traffic shaping twice - once en clair
and once encrypted and encapsulated. As a result, throughput may be
significantly less than configured if IPSEC packets form a significant
percentage of the traffic being shaped.</para>
</caution>
</section>
<section>
@@ -187,8 +194,9 @@ eth0 External</programlisting>
<para>Assign traffic entering the firewall on a particular interface
to a specific priority band:</para>
<programlisting>#BAND PROTO PORT(S) ADDRESS INTERFACE HELPER
2 - - - eth1</programlisting>
<programlisting>?FORMAT 2
#BAND PROTO DPORT SPORT ADDRESS INTERFACE HELPER
2 - - - - eth1</programlisting>
<para>In this example, traffic from eth1 will be assigned to priority
band 2.</para>
@@ -203,15 +211,17 @@ eth0 External</programlisting>
<para>Assign traffic from a particular IP address to a specific
priority band:</para>
<programlisting>#BAND PROTO DPORT ADDRESS INTERFACE HELPER
1 - - 192.168.1.44</programlisting>
<programlisting>?FORMAT 2
#BAND PROTO DPORT SPORT ADDRESS INTERFACE HELPER
1 - - - 192.168.1.44</programlisting>
<para>In this example, traffic from 192.168.1.44 will be assigned to
priority band 1.</para>
<note>
<para>When an ADDRESS is specified, the PROTO, DPORT and INTERFACE
columns must be empty.</para>
<para>When an ADDRESS is specified, the PROTO, DPORT, SPORT and
INTERFACE columns must be empty.</para>
</note>
</listitem>
@@ -219,11 +229,19 @@ eth0 External</programlisting>
<para>Assign traffic to/from a particular application to a specific
priority band:</para>
<programlisting>#BAND PROTO DPORT ADDRESS INTERFACE HELPER
<programlisting>#BAND PROTO PORT ADDRESS INTERFACE HELPER
1 udp 1194</programlisting>
<para>In that example, OpenVPN traffic is assigned to priority band
1.</para>
<para>In that example, SSH traffic is assigned to priority band 1. In
file format 2, the above would be as follows:</para>
<programlisting>#BAND PROTO DPORT SPORT ADDRESS INTERFACE HELPER
1 tcp 22
1 tcp - 22</programlisting>
<para>In other words, in file format 1, the compiler generates rules
for traffic from client to server and from server to client. In format
2, separate tcpri rules are required.</para>
</listitem>
<listitem>
@@ -355,5 +373,9 @@ COMMENT And place echo requests in band 1 to avoid false line-down reports
<para>Please note that Shorewall numbers the bands 1-3 whereas PRIO(8)
refers to them as bands 0-2.</para>
</caution>
<para>If you encounter performance problems after enabling simple traffic
shaping, check out <ulink url="FAQ.htm#faq97">FAQ 97</ulink> and <ulink
url="FAQ.htm#faq97a">FAQ97a</ulink></para>
</section>
</article>

View File

@@ -26,6 +26,8 @@
<copyright>
<year>2001-2013</year>
<year>2020</year>
<holder>Thomas M. Eastep</holder>
</copyright>
@@ -214,24 +216,6 @@
article</ulink>.</para>
</section>
<section id="Kernel">
<title>Linux Kernel Configuration</title>
<para>You will need at least kernel 2.4.18 for this to work, please take a
look at the following screenshot for what settings you need to enable. For
builtin support, you need the HTB scheduler, the Ingress scheduler, the
PRIO pseudoscheduler and SFQ queue. The other scheduler or queue
algorithms are not needed.</para>
<para>This screen shot shows how I configured QoS in a 2.6.16
Kernel:</para>
<graphic align="center" fileref="images/traffic_shaping2.6.png"/>
<para>And here's my recommendation for a 2.6.21 kernel:<graphic
align="center" fileref="images/traffic_shaping2.6.21.png"/></para>
</section>
<section id="Shorewall">
<title>Enable TC support in Shorewall</title>
@@ -298,6 +282,15 @@
<para>Assign traffic to HTB and/or HFSC classes based on packet mark
value or based on packet contents.</para>
</listitem>
<listitem>
<para>Throttle incoming traffic</para>
</listitem>
<listitem>
<para>Use an <emphasis>Intermediate functional block </emphasis>(IFB)
to shape incoming traffic<emphasis> </emphasis></para>
</listitem>
</itemizedlist>
<para>Those few features are really all that builtin traffic
@@ -392,6 +385,14 @@
The default burst is 10kb, but on my 50mbit line, I specify 200kb.
(50mbit:200kb).</para>
</note>
<caution>
<para>Incoming IPSec traffic traverses traffic shaping twice -
firs as encrypted and encapsulated ESP packets and then en clair.
As a result, incoming bandwidth can be significantly less than
specified if IPSEC packets form a significant part of inoming
traffic.</para>
</caution>
</listitem>
<listitem>
@@ -482,6 +483,16 @@
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">connmark</emphasis></term>
<listitem>
<para>Added in Shorewall 5.2.7. May be specified on IFB
devices to enable use of firewall marks to select the
appropriate traffic shaping class.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
@@ -496,7 +507,8 @@
column.</para>
<para>IFB devices automatically get the <emphasis
role="bold">classify</emphasis> option.</para>
role="bold">classify</emphasis> option unless the <emphasis
role="bold">connmark</emphasis> option is specified.</para>
</listitem>
</itemizedlist>
@@ -1577,9 +1589,11 @@ ip link set ifb0 up</command></programlisting>
<para>Entries in <filename>/etc/shorewall/mangle</filename> or
<filename>/etc/shorewall/tcrules</filename> have no effect on shaping
traffic through an IFB. To allow classification of such traffic, the
/etc/shorewall/tcfilters file has been added. Entries in that file create
<ulink url="http://b42.cz/notes/u32_classifier/">u32 classification
traffic through an IFB unless the IFB is defined in shorewall-tcclasses(5)
with the <emphasis role="bold">connmark</emphasis> option. To allow
classification of such traffic, the /etc/shorewall/tcfilters file has been
added. Entries in that file create <ulink
url="http://b42.cz/notes/u32_classifier/">u32 classification
rules</ulink>.</para>
<section id="tcfilters">
@@ -1937,6 +1951,93 @@ filter parent 1: protocol ip pref 10 u32 <emphasis role="bold">fh 800:</emphasis
role="bold">&lt;========= PROTO TCP</emphasis>
offset 0f00&gt;&gt;6 at 0 eat </programlisting></para>
</section>
<section>
<title>IFBs and SNAT/MASQUERADE</title>
<para>IFB traffic shaping takes place immediately after the traffic is
received by the incoming interface and before it has been passed to any
Netfilter hook. This has two consequences:</para>
<itemizedlist>
<listitem>
<para>There is no opportunity to mark the packets before they are
processed by the IFBs traffic shaping rules.</para>
</listitem>
<listitem>
<para>The DEST IP address is still the IP address of the external
interface on which the traffic arrived.</para>
</listitem>
</itemizedlist>
<para>As a result, in the tcdevices file description above, a <emphasis
role="bold">connmark</emphasis> option was added to that file in
Shorewall 5.2.7. The <emphasis role="bold">connmark</emphasis> option
allows firewall marks to be used to segregate traffic by DEST IP.</para>
<para>Example (based closely on one supplied by Rodrigo Araujo, who also
wrote much of the code supporting the <emphasis
role="bold">connmark</emphasis> option):</para>
<para><emphasis
role="bold">/etc/shorewall/shorewall.conf:</emphasis></para>
<programlisting>...
TC_ENABLED=Internal
...</programlisting>
<para><emphasis role="bold">/etc/shorewall/interfaces:</emphasis></para>
<programlisting>##############################################################################
?FORMAT 2
###############################################################################
#ZONE INTERFACE OPTIONS
net NET_IF dhcp,tcpflags,nosmurfs,routefilter,logmartians,sourceroute=0,physical=eth0
loc LOC_IF tcpflags,nosmurfs,routefilter,logmartians,physical=eth1</programlisting>
<para><emphasis role="bold">/etc/shorewall/snat:</emphasis></para>
<programlisting>?FORMAT 2
#ACTION SOURCE DEST PROTO PORT IPSEC MARK
USER SWITCH ORIGDEST PROBABILITY
MASQUERADE - NET_IF</programlisting>
<para><emphasis role="bold">/etc/shorewall/tcdevices:</emphasis></para>
<programlisting>#INTERFACE IN_BANDWITH OUT_BANDWIDTH OPTIONS REDIRECT
## net upload
10:NET_IF - 1000mbit htb
## net download
11:ifb0 - 1000mbit htb,connmark NET_IF</programlisting>
<para><emphasis role="bold">/etc/shorewall/tcclasses:</emphasis></para>
<programlisting>#INTERFACE MARK RATE CEIL PRIO OPTIONS
10:5000 111 500kbit full 10 tcp-ack,tos-minimize-delay
11:5000 110 500kbit full 10 tcp-ack,tos-minimize-delay
10:1000 100 full-50500 full 20 default
11:1000 101 full-100500 full 20 default
10:50 10 50mbit 50mbit 101 flow=nfct-src
11:100 11 100mbit 100mbit 101 flow=dst</programlisting>
<para><emphasis role="bold">/etc/shorewall/tcfilters:</emphasis></para>
<programlisting>#CLASS SOURCE DEST PROTO DPORT SPORT TOS LENGTH
## limit LAN upload - works
10:50 10.100.100.0/24
## limit LAN download - DOESN'T WORK BECAUSE OF MASQUERADE ON eth0 !!!! (snat file)
#11:100 - 10.100.100.0/24</programlisting>
<para><emphasis role="bold">/etc/shorewall/mangle:</emphasis></para>
<programlisting>#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH
## this only works with the aforementioned conntrack option
## and LAN users' download traffic will get the 11:100 class (defined in tcclasses) applied
CONNMARK(11):F 10.100.100.0/24 - { TEST=0x0/0xff }</programlisting>
</section>
</section>
<section id="show">