forked from extern/shorewall_code
Compare commits
23 Commits
5.2.5.2
...
5.2.6-base
Author | SHA1 | Date | |
---|---|---|---|
|
418f96082e | ||
|
b761a6eaa0 | ||
|
d643f57bc1 | ||
|
d1c7b3d9da | ||
|
d399fd0815 | ||
|
3dc14e3575 | ||
|
7ba6ac71e3 | ||
|
10aef23ab1 | ||
|
e3f139bbdb | ||
|
e4f24f41fd | ||
|
d0e4c53bd0 | ||
|
43ac903085 | ||
|
28b92dae32 | ||
|
bac493c2c5 | ||
|
3ed1cdec94 | ||
|
3f5bdfd705 | ||
|
c9512dfaf8 | ||
|
af2b7e6fc1 | ||
|
01bfdabd5a | ||
|
c234a1a0ec | ||
|
7ca18c410b | ||
|
e2aeed898d | ||
|
2eb1c88555 |
@@ -1 +1 @@
|
||||
5.2.5-Beta2
|
||||
5.2.6-base
|
||||
|
@@ -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)
|
||||
@@ -4012,7 +4025,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 +4359,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 +4401,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 +4417,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> ]"
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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])";
|
||||
}
|
||||
|
||||
#
|
||||
|
@@ -858,13 +858,14 @@ 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;
|
||||
optimize_policy_chains;
|
||||
}
|
||||
|
||||
enable_script;
|
||||
@@ -928,16 +929,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;
|
||||
|
@@ -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
|
||||
) , ] ,
|
||||
@@ -555,7 +554,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.
|
||||
|
@@ -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 '-' ) {
|
||||
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto );
|
||||
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,23 +1994,49 @@ sub process_action(\$\$$) {
|
||||
set_inline_matches( $matches );
|
||||
}
|
||||
} else {
|
||||
my ( $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,
|
||||
ipsec => 5,
|
||||
mark => 6,
|
||||
user => 7,
|
||||
switch => 8,
|
||||
origdest => 9,
|
||||
probability => 10,
|
||||
},
|
||||
{},
|
||||
11,
|
||||
1 );
|
||||
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,
|
||||
switch => 8,
|
||||
origdest => 9,
|
||||
probability => 10,
|
||||
},
|
||||
{},
|
||||
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
|
||||
#
|
||||
@@ -4822,9 +4880,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 +5428,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,28 +5448,54 @@ 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) =
|
||||
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,
|
||||
},
|
||||
{},
|
||||
11,
|
||||
1 );
|
||||
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,
|
||||
switch => 8,
|
||||
origdest => 9,
|
||||
probability => 10,
|
||||
},
|
||||
{},
|
||||
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 +5523,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 +5550,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 +5571,6 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
my ( $action, $loglevel ) = split_action( $origaction );
|
||||
my $logaction;
|
||||
my $param;
|
||||
|
||||
#
|
||||
# Handle early matches
|
||||
#
|
||||
@@ -5584,7 +5670,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
#
|
||||
# Handle Protocol, Ports and Condition
|
||||
#
|
||||
$baserule .= do_proto( $proto, $ports, '' );
|
||||
$baserule .= do_proto( $proto, $ports, $sports );
|
||||
#
|
||||
# Handle Mark
|
||||
#
|
||||
@@ -5831,6 +5917,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
supplied( $destnets ) && $destnets ne '-' ? $inaction || $interface ? join( ':', $interface, $destnets ) : $destnets : $inaction ? '-' : $interface,
|
||||
$proto,
|
||||
$ports,
|
||||
$sports,
|
||||
$ipsec,
|
||||
$mark,
|
||||
$user,
|
||||
@@ -5841,9 +5928,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 +6030,30 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
|
||||
sub process_snat( )
|
||||
{
|
||||
my ($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 },
|
||||
{}, #Nopad
|
||||
undef, #Columns
|
||||
1 ); #Allow inline matches
|
||||
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, dport => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
|
||||
{}, #Nopad
|
||||
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 +6068,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 );
|
||||
}
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -1 +1 @@
|
||||
5.2.5.1
|
||||
5.2.6-RC1
|
||||
|
@@ -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
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
5.2.5.1
|
||||
5.2.6-RC1
|
||||
|
Reference in New Issue
Block a user