forked from extern/shorewall_code
Compare commits
30 Commits
5.0.14-Bet
...
5.0.14-bas
Author | SHA1 | Date | |
---|---|---|---|
|
8441ac5c5f | ||
|
01a6881f4f | ||
|
f917670fbd | ||
|
c376740329 | ||
|
4169520d63 | ||
|
53d97bbcc8 | ||
|
9ae36e1989 | ||
|
60619fb3cb | ||
|
41ecee356b | ||
|
e188bde6c4 | ||
|
6e08717089 | ||
|
d37967f32f | ||
|
10c1ad245a | ||
|
032a16eb43 | ||
|
a89d8b3af4 | ||
|
3f68814a38 | ||
|
3a70185284 | ||
|
95a1e65016 | ||
|
282253022e | ||
|
174f46f3e6 | ||
|
4d77d673e8 | ||
|
e4e424bbdc | ||
|
71fb1a8cbd | ||
|
46c8147521 | ||
|
de3b05ea41 | ||
|
ae9b57d854 | ||
|
1a06765d14 | ||
|
579910fdb8 | ||
|
21877d5fcb | ||
|
0b9387f09c |
@@ -266,10 +266,12 @@ our %EXPORT_TAGS = (
|
||||
set_chain_variables
|
||||
mark_firewall_not_started
|
||||
mark_firewall6_not_started
|
||||
interface_address
|
||||
get_interface_address
|
||||
get_interface_addresses
|
||||
get_interface_bcasts
|
||||
get_interface_acasts
|
||||
interface_gateway
|
||||
get_interface_gateway
|
||||
get_interface_mac
|
||||
have_global_variables
|
||||
@@ -5775,12 +5777,12 @@ sub have_ipset_rules() {
|
||||
$ipset_rules;
|
||||
}
|
||||
|
||||
sub get_interface_address( $ );
|
||||
sub get_interface_address( $;$ );
|
||||
|
||||
sub get_interface_gateway ( $;$ );
|
||||
sub get_interface_gateway ( $;$$ );
|
||||
|
||||
sub record_runtime_address( $$;$ ) {
|
||||
my ( $addrtype, $interface, $protect ) = @_;
|
||||
sub record_runtime_address( $$;$$ ) {
|
||||
my ( $addrtype, $interface, $protect, $provider ) = @_;
|
||||
|
||||
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
|
||||
fatal_error "Mixed required/optional usage of address variable $1" if ( $address_variables{$1} || $addrtype ) ne $addrtype;
|
||||
@@ -5794,9 +5796,9 @@ sub record_runtime_address( $$;$ ) {
|
||||
my $addr;
|
||||
|
||||
if ( $addrtype eq '&' ) {
|
||||
$addr = get_interface_address( $interface );
|
||||
$addr = get_interface_address( $interface, $provider );
|
||||
} else {
|
||||
$addr = get_interface_gateway( $interface, $protect );
|
||||
$addr = get_interface_gateway( $interface, $protect, $provider );
|
||||
}
|
||||
|
||||
$addr . ' ';
|
||||
@@ -5821,12 +5823,18 @@ sub conditional_rule( $$ ) {
|
||||
if ( $type eq '&' ) {
|
||||
$variable = get_interface_address( $interface );
|
||||
add_commands( $chainref , "if [ $variable != " . NILIP . ' ]; then' );
|
||||
incr_cmd_level $chainref;
|
||||
} else {
|
||||
$variable = get_interface_gateway( $interface );
|
||||
add_commands( $chainref , qq(if [ -n "$variable" ]; then) );
|
||||
|
||||
if ( $variable =~ /^\$/ ) {
|
||||
add_commands( $chainref , qq(if [ -n "$variable" ]; then) );
|
||||
incr_cmd_level $chainref;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
incr_cmd_level $chainref;
|
||||
return 1;
|
||||
}
|
||||
} elsif ( $type eq '%' && $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
|
||||
@@ -6787,8 +6795,8 @@ sub interface_address( $ ) {
|
||||
#
|
||||
# Record that the ruleset requires the first IP address on the passed interface
|
||||
#
|
||||
sub get_interface_address ( $ ) {
|
||||
my ( $logical ) = $_[0];
|
||||
sub get_interface_address ( $;$ ) {
|
||||
my ( $logical, $provider ) = @_;
|
||||
|
||||
my $interface = get_physical( $logical );
|
||||
my $variable = interface_address( $interface );
|
||||
@@ -6798,6 +6806,8 @@ sub get_interface_address ( $ ) {
|
||||
|
||||
$interfaceaddr{$interface} = "$variable=\$($function $interface)\n";
|
||||
|
||||
set_interface_option( $logical, 'used_address_variable', 1 ) unless $provider;
|
||||
|
||||
"\$$variable";
|
||||
}
|
||||
|
||||
@@ -6858,14 +6868,21 @@ sub interface_gateway( $ ) {
|
||||
#
|
||||
# Record that the ruleset requires the gateway address on the passed interface
|
||||
#
|
||||
sub get_interface_gateway ( $;$ ) {
|
||||
my ( $logical, $protect ) = @_;
|
||||
sub get_interface_gateway ( $;$$ ) {
|
||||
my ( $logical, $protect, $provider ) = @_;
|
||||
|
||||
my $interface = get_physical $logical;
|
||||
my $variable = interface_gateway( $interface );
|
||||
my $gateway = get_interface_option( $interface, 'gateway' );
|
||||
|
||||
$global_variables |= ALL_COMMANDS;
|
||||
|
||||
if ( $gateway ) {
|
||||
fatal_error q(A gateway variable cannot be used for a provider interface with GATEWAY set to 'none' in the providers file) if $gateway eq 'none';
|
||||
fatal_error q(A gateway variable cannot be used for a provider interface with an empty GATEWAY column in the providers file) if $gateway eq 'omitted';
|
||||
return $gateway if $gateway ne 'detect';
|
||||
}
|
||||
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface));
|
||||
} else {
|
||||
@@ -6873,6 +6890,8 @@ sub get_interface_gateway ( $;$ ) {
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
|
||||
}
|
||||
|
||||
set_interface_option($interface, 'used_gateway_variable', 1) unless $provider;
|
||||
|
||||
$protect ? "\${$variable:-" . NILIP . '}' : "\$$variable";
|
||||
}
|
||||
|
||||
|
@@ -804,33 +804,8 @@ sub compiler {
|
||||
# Validate the TC files so that the providers will know what interfaces have TC
|
||||
#
|
||||
my $tcinterfaces = process_tc;
|
||||
#
|
||||
# Generate a function to bring up each provider
|
||||
#
|
||||
|
||||
process_providers( $tcinterfaces );
|
||||
#
|
||||
# [Re-]establish Routing
|
||||
#
|
||||
if ( $scriptfilename || $debug ) {
|
||||
emit( "\n#",
|
||||
'# Setup routing and traffic shaping',
|
||||
'#',
|
||||
'setup_routing_and_traffic_shaping() {'
|
||||
);
|
||||
|
||||
push_indent;
|
||||
}
|
||||
|
||||
setup_providers;
|
||||
#
|
||||
# TCRules and Traffic Shaping
|
||||
#
|
||||
setup_tc( $update );
|
||||
|
||||
if ( $scriptfilename || $debug ) {
|
||||
pop_indent;
|
||||
emit "}\n"; # End of setup_routing_and_traffic_shaping()
|
||||
}
|
||||
|
||||
$have_arptables = process_arprules if $family == F_IPV4;
|
||||
|
||||
@@ -841,11 +816,7 @@ sub compiler {
|
||||
#
|
||||
process_tos;
|
||||
#
|
||||
# ECN
|
||||
#
|
||||
setup_ecn if $family == F_IPV4 && have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
|
||||
#
|
||||
# Setup Masquerading/SNAT
|
||||
# Setup Masquerade/SNAT
|
||||
#
|
||||
setup_snat( $update );
|
||||
#
|
||||
@@ -889,6 +860,37 @@ sub compiler {
|
||||
#
|
||||
setup_accounting if $config{ACCOUNTING};
|
||||
|
||||
enable_script;
|
||||
#
|
||||
# Generate a function to bring up each provider
|
||||
#
|
||||
if ( $scriptfilename || $debug ) {
|
||||
emit( "\n#",
|
||||
'# Setup routing and traffic shaping',
|
||||
'#',
|
||||
'setup_routing_and_traffic_shaping() {'
|
||||
);
|
||||
|
||||
push_indent;
|
||||
}
|
||||
|
||||
setup_providers;
|
||||
#
|
||||
# TCRules and Traffic Shaping
|
||||
#
|
||||
setup_tc( $update );
|
||||
|
||||
if ( $scriptfilename || $debug ) {
|
||||
pop_indent;
|
||||
emit "}\n"; # End of setup_routing_and_traffic_shaping()
|
||||
}
|
||||
#
|
||||
# ECN
|
||||
#
|
||||
setup_ecn if $family == F_IPV4 && have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
|
||||
|
||||
disable_script;
|
||||
|
||||
if ( $scriptfilename ) {
|
||||
#
|
||||
# Compiling a script - generate the zone by zone matrix
|
||||
|
@@ -472,7 +472,7 @@ sub validate_portpair1( $$ ) {
|
||||
|
||||
fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/-/-/ > 1;
|
||||
|
||||
$portpair = "0$portpair" if substr( $portpair, 0, 1 ) eq ':';
|
||||
$portpair = "1$portpair" if substr( $portpair, 0, 1 ) eq ':';
|
||||
$portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':';
|
||||
|
||||
my @ports = split /-/, $portpair, 2;
|
||||
@@ -483,9 +483,10 @@ sub validate_portpair1( $$ ) {
|
||||
|
||||
if ( @ports == 2 ) {
|
||||
$what = 'port range';
|
||||
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1];
|
||||
fatal_error "Invalid port range ($portpair)" unless $ports[0] && $ports[0] < $ports[1];
|
||||
} else {
|
||||
$what = 'port';
|
||||
fatal_error 'Invalid port number (0)' unless $portpair;
|
||||
}
|
||||
|
||||
fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, SCTP or DCCP" unless
|
||||
|
@@ -2740,6 +2740,9 @@ EOF
|
||||
pop_indent;
|
||||
|
||||
emit '
|
||||
rm -f ${VARDIR}/*.address
|
||||
rm -f ${VARDIR}/*.gateway
|
||||
|
||||
run_stopped_exit';
|
||||
|
||||
my @ipsets = all_ipsets;
|
||||
|
@@ -76,7 +76,6 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
||||
#
|
||||
$pre_nat = 1 if $interfacelist =~ s/^\+//;
|
||||
|
||||
$savelist = $interfacelist;
|
||||
#
|
||||
# Check for INLINE
|
||||
#
|
||||
@@ -86,6 +85,8 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
||||
} else {
|
||||
$inlinematches = get_inline_matches(0);
|
||||
}
|
||||
|
||||
$savelist = $interfacelist;
|
||||
#
|
||||
# Handle early matches
|
||||
#
|
||||
@@ -225,13 +226,13 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
||||
} elsif ( $addresses eq 'NONAT' ) {
|
||||
fatal_error "'persistent' may not be specified with 'NONAT'" if $persistent;
|
||||
fatal_error "'random' may not be specified with 'NONAT'" if $randomize;
|
||||
$target = 'RETURN';
|
||||
$target = $snat ? 'CONTINUE' : 'RETURN';
|
||||
$add_snat_aliases = 0;
|
||||
} elsif ( $addresses ) {
|
||||
my $addrlist = '';
|
||||
my @addrs = split_list $addresses, 'address';
|
||||
|
||||
fatal_error "Only one IPv6 ADDRESS may be specified" if $family == F_IPV6 && @addrs > 1;
|
||||
fatal_error "Only one ADDRESS may be specified" if @addrs > 1;
|
||||
|
||||
for my $addr ( @addrs ) {
|
||||
if ( $addr =~ /^([&%])(.+)$/ ) {
|
||||
@@ -279,14 +280,20 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
||||
} elsif ( $family == F_IPV4 ) {
|
||||
if ( $addr =~ /^.*\..*\..*\./ ) {
|
||||
$target = 'SNAT ';
|
||||
my ($ipaddr, $rest) = split ':', $addr;
|
||||
my ($ipaddr, $rest) = split ':', $addr, 2;
|
||||
if ( $ipaddr =~ /^(.+)-(.+)$/ ) {
|
||||
validate_range( $1, $2 );
|
||||
} else {
|
||||
validate_address $ipaddr, 0;
|
||||
}
|
||||
validate_portpair1( $proto, $rest ) if supplied $rest;
|
||||
$addrlist .= "--to-source $addr ";
|
||||
|
||||
if ( supplied $rest ) {
|
||||
validate_portpair1( $proto, $rest );
|
||||
$addrlist .= "--to-source $addr ";
|
||||
} else {
|
||||
$addrlist .= "--to-source $ipaddr";
|
||||
}
|
||||
|
||||
$exceptionrule = do_proto( $proto, '', '' ) if $addr =~ /:/;
|
||||
} else {
|
||||
my $ports = $addr;
|
||||
@@ -397,9 +404,12 @@ sub process_one_masq1( $$$$$$$$$$$$ )
|
||||
|
||||
if ( $snat ) {
|
||||
$target =~ s/ .*//;
|
||||
$target = 'CONTINUE' if $target eq 'RETURN';
|
||||
$target .= '+' if $pre_nat;
|
||||
$target .= '(' . $addresses . ')' if $addresses ne '-';
|
||||
|
||||
if ( $addresses ne '-' && $addresses ne 'NONAT' ) {
|
||||
$addresses =~ s/^://;
|
||||
$target .= '(' . $addresses . ')';
|
||||
}
|
||||
|
||||
my $line = "$target\t$networks\t$savelist\t$proto\t$ports\t$ipsec\t$mark\t$user\t$condition\t$origdest\t$probability";
|
||||
#
|
||||
|
@@ -472,12 +472,14 @@ sub process_a_provider( $ ) {
|
||||
|
||||
if ( ( $gw = lc $gateway ) eq 'detect' ) {
|
||||
fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared;
|
||||
$gateway = get_interface_gateway $interface;
|
||||
$gateway = get_interface_gateway( $interface, undef, 1 );
|
||||
$gatewaycase = 'detect';
|
||||
set_interface_option( $interface, 'gateway', 'detect' );
|
||||
} elsif ( $gw eq 'none' ) {
|
||||
fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared;
|
||||
$gatewaycase = 'none';
|
||||
$gateway = '';
|
||||
set_interface_option( $interface, 'gateway', 'none' );
|
||||
} elsif ( $gateway && $gateway ne '-' ) {
|
||||
( $gateway, $mac ) = split_host_list( $gateway, 0 );
|
||||
validate_address $gateway, 0;
|
||||
@@ -491,12 +493,15 @@ sub process_a_provider( $ ) {
|
||||
}
|
||||
|
||||
$gatewaycase = 'specified';
|
||||
set_interface_option( $interface, 'gateway', $gateway );
|
||||
} else {
|
||||
$gatewaycase = 'omitted';
|
||||
fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared;
|
||||
$gateway = '';
|
||||
set_interface_option( $interface, 'gateway', $pseudo ? 'detect' : 'omitted' );
|
||||
}
|
||||
|
||||
|
||||
my ( $loose, $track, $balance, $default, $default_balance, $optional, $mtu, $tproxy, $local, $load, $what, $hostroute, $persistent );
|
||||
|
||||
if ( $pseudo ) {
|
||||
@@ -725,9 +730,9 @@ sub emit_started_message( $$$$$ ) {
|
||||
my ( $spaces, $level, $pseudo, $name, $number ) = @_;
|
||||
|
||||
if ( $pseudo ) {
|
||||
emit qq(${spaces}progress_message${level} " Optional interface $name Started");
|
||||
emit qq(${spaces}progress_message${level} "Optional interface $name Started");
|
||||
} else {
|
||||
emit qq(${spaces}progress_message${level} " Provider $name ($number) Started");
|
||||
emit qq(${spaces}progress_message${level} "Provider $name ($number) Started");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,7 +799,7 @@ sub add_a_provider( $$ ) {
|
||||
}
|
||||
|
||||
if ( $gateway ) {
|
||||
$address = get_interface_address $interface unless $address;
|
||||
$address = get_interface_address( $interface, 1 ) unless $address;
|
||||
|
||||
emit( qq([ -z "$address" ] && return\n) );
|
||||
|
||||
@@ -920,7 +925,7 @@ CEOF
|
||||
}
|
||||
|
||||
if ( $gateway ) {
|
||||
$address = get_interface_address $interface unless $address;
|
||||
$address = get_interface_address( $interface, 1 ) unless $address;
|
||||
|
||||
if ( $hostroute ) {
|
||||
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
|
||||
@@ -1033,6 +1038,16 @@ CEOF
|
||||
emit( qq(rm -f \${VARDIR}/${physical}_disabled) );
|
||||
emit_started_message( '', 2, $pseudo, $table, $number );
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) || get_interface_option( $interface, 'used_gateway_variable' ) ) {
|
||||
emit( '',
|
||||
'if [ -n "$g_forcereload" ]; then',
|
||||
" progress_message2 \"The IP address or gateway of $physical has changed -- forcing reload of the ruleset\"",
|
||||
' COMMAND=reload',
|
||||
' detect_configuration',
|
||||
' define_firewall',
|
||||
'fi' );
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
|
||||
unless ( $pseudo ) {
|
||||
@@ -1043,6 +1058,17 @@ CEOF
|
||||
}
|
||||
|
||||
emit "fi\n";
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
|
||||
my $variable = interface_address( $interface );
|
||||
|
||||
emit( "echo \$$variable > \${VARDIR}/${physical}.address" );
|
||||
}
|
||||
|
||||
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
|
||||
my $variable = interface_gateway( $interface );
|
||||
emit( qq(echo "\$$variable" > \${VARDIR}/${physical}.gateway\n) );
|
||||
}
|
||||
} else {
|
||||
emit( qq(progress_message "Provider $table ($number) Started") );
|
||||
}
|
||||
@@ -1067,6 +1093,17 @@ CEOF
|
||||
} else {
|
||||
emit ( "error_message \"WARNING: Interface $physical is not usable -- Provider $table ($number) not Started\"" );
|
||||
}
|
||||
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
|
||||
my $variable = interface_address( $interface );
|
||||
emit( "\necho \$$variable > \${VARDIR}/${physical}.address" );
|
||||
}
|
||||
|
||||
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
|
||||
my $variable = interface_gateway( $interface );
|
||||
emit( qq(\necho "\$$variable" > \${VARDIR}/${physical}.gateway) );
|
||||
}
|
||||
} else {
|
||||
if ( $shared ) {
|
||||
emit( "fatal_error \"Gateway $gateway is not reachable -- Provider $table ($number) Cannot be Started\"" );
|
||||
@@ -1205,7 +1242,7 @@ sub add_an_rtrule1( $$$$$ ) {
|
||||
if ( $source eq '-' ) {
|
||||
$source = 'from ' . ALLIP;
|
||||
} elsif ( $source =~ s/^&// ) {
|
||||
$source = 'from ' . record_runtime_address '&', $source;
|
||||
$source = 'from ' . record_runtime_address( '&', $source, undef, 1 );
|
||||
} elsif ( $family == F_IPV4 ) {
|
||||
if ( $source =~ /:/ ) {
|
||||
( my $interface, $source , my $remainder ) = split( /:/, $source, 3 );
|
||||
@@ -2139,6 +2176,7 @@ sub handle_optional_interfaces( $ ) {
|
||||
}
|
||||
|
||||
push_indent;
|
||||
|
||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||
} else {
|
||||
@@ -2151,6 +2189,28 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit( " SW_${wildbase}_IS_USABLE=Yes" ) if $interfaceref->{wildcard};
|
||||
emit( 'fi' );
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
|
||||
my $variable = interface_address( $interface );
|
||||
|
||||
emit( '',
|
||||
"if [ -f \${VARDIR}/${physical}.address ]; then",
|
||||
" if [ \$(cat \${VARDIR}/${physical}.address) != \$$variable ]; then",
|
||||
' g_forcereload=Yes',
|
||||
' fi',
|
||||
'fi' );
|
||||
}
|
||||
|
||||
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
|
||||
my $variable = interface_gateway( $interface );
|
||||
|
||||
emit( '',
|
||||
"if [ -f \${VARDIR}/${physical}.gateway ]; then",
|
||||
" if [ \$(cat \${VARDIR}/${physical}.gateway) != \"\$$variable\" ]; then",
|
||||
' g_forcereload=Yes',
|
||||
' fi',
|
||||
'fi' );
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit( "fi\n" );
|
||||
@@ -2161,6 +2221,7 @@ sub handle_optional_interfaces( $ ) {
|
||||
my $base = uc var_base( $physical );
|
||||
my $case = $physical;
|
||||
my $wild = $case =~ s/\+$/*/;
|
||||
my $variable = interface_address( $interface );
|
||||
|
||||
if ( $wildcards ) {
|
||||
emit( "$case)" );
|
||||
@@ -2181,6 +2242,15 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit ( " SW_${base}_IS_USABLE=Yes" ,
|
||||
'fi' );
|
||||
|
||||
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
|
||||
emit( '',
|
||||
"if [ -f \${VARDIR}/${physical}.address ]; then",
|
||||
" if [ \$(cat \${VARDIR}/${physical}.address) != \$$variable ]; then",
|
||||
' g_forcereload=Yes',
|
||||
' fi',
|
||||
'fi' );
|
||||
}
|
||||
|
||||
if ( $wildcards ) {
|
||||
pop_indent, emit( 'fi' ) if $wild;
|
||||
emit( ';;' );
|
||||
|
@@ -5357,12 +5357,13 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
my $interfaces;
|
||||
my $normalized_action;
|
||||
|
||||
if ( $action =~ /^MASQUERADE(\+)?\((.+)\)$/ ) {
|
||||
if ( $action =~ /^MASQUERADE(\+)?(?:\((.+)\))?$/ ) {
|
||||
$target = 'MASQUERADE';
|
||||
$actiontype = $builtin_target{$action = $target};
|
||||
$pre_nat = $1;
|
||||
$addresses = $2;
|
||||
$addresses = ( $2 || '' );
|
||||
$options = 'random' if $addresses =~ s/:?random$//;
|
||||
$add_snat_aliases = '';
|
||||
} elsif ( $action =~ /^SNAT(\+)?\((.+)\)$/ ) {
|
||||
$pre_nat = $1;
|
||||
$addresses = $2;
|
||||
@@ -5377,24 +5378,25 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
$pre_nat = $1;
|
||||
} elsif ( $action eq 'MASQUERADE' ) {
|
||||
$actiontype = $builtin_target{$target = 'MASQUERADE'};
|
||||
$add_snat_aliases = '';
|
||||
} else {
|
||||
( $target , $params ) = get_target_param1( $action );
|
||||
|
||||
$pre_nat = ( $target =~ s/\+$// );
|
||||
|
||||
$actiontype = $targets{$target};
|
||||
$actiontype = ( $targets{$target} || 0 );
|
||||
|
||||
fatal_error "Invalid ACTION ($action)" unless $actiontype & ( ACTION | INLINE );
|
||||
}
|
||||
|
||||
if ( $inchain = defined $chainref ) {
|
||||
( $inaction, undef, $interfaces, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 5 if $chainref->{action};
|
||||
fatal_error q('+' is not allowed within an action body) if $pre_nat;
|
||||
}
|
||||
#
|
||||
# Next, parse the DEST column
|
||||
#
|
||||
if ( $inaction ) {
|
||||
fatal_error q('*' is not allowed within an action body) if $pre_nat;
|
||||
$destnets = $dest;
|
||||
} elsif ( $family == F_IPV4 ) {
|
||||
if ( $dest =~ /^([^:]+)::([^:]*)$/ ) {
|
||||
@@ -5455,6 +5457,8 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
|
||||
my $rule = '';
|
||||
my $saveaddresses = $addresses;
|
||||
my $savetarget = $target;
|
||||
my $savebaserule = $baserule;
|
||||
my $interface = $fullinterface;
|
||||
|
||||
$interface =~ s/:.*//; #interface name may include 'alias'
|
||||
@@ -5505,10 +5509,12 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
$detectaddress = 1;
|
||||
}
|
||||
} else {
|
||||
fatal_error "SNAT rules must spacify a new source address and/or new source ports" unless supplied $addresses;
|
||||
|
||||
my $addrlist = '';
|
||||
my @addrs = split_list $addresses, 'address';
|
||||
|
||||
fatal_error "Only one IPv6 ADDRESS may be specified" if $family == F_IPV6 && @addrs > 1;
|
||||
fatal_error "Only one SNAT address may be specified" if @addrs > 1;
|
||||
|
||||
for my $addr ( @addrs ) {
|
||||
if ( $addr =~ /^([&%])(.+)$/ ) {
|
||||
@@ -5551,20 +5557,27 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
}
|
||||
} elsif ( $family == F_IPV4 ) {
|
||||
if ( $addr =~ /^.*\..*\..*\./ ) {
|
||||
my ($ipaddr, $rest) = split ':', $addr;
|
||||
my ($ipaddr, $rest) = split ':', $addr, 2;
|
||||
if ( $ipaddr =~ /^(.+)-(.+)$/ ) {
|
||||
validate_range( $1, $2 );
|
||||
} else {
|
||||
validate_address $ipaddr, 0;
|
||||
}
|
||||
validate_portpair1( $proto, $rest ) if supplied $rest;
|
||||
$addrlist .= " --to-source $addr";
|
||||
|
||||
if ( supplied $rest ) {
|
||||
validate_portpair1( $proto, $rest );
|
||||
$addrlist .= " --to-source $addr";
|
||||
} else {
|
||||
$addrlist .= " --to-source $ipaddr";
|
||||
}
|
||||
|
||||
$exceptionrule = do_proto( $proto, '', '' ) if $addr =~ /:/;
|
||||
} else {
|
||||
my $ports = $addr;
|
||||
$ports =~ s/^://;
|
||||
fatal_error "Missing Address or Port[-range] ($addr)" unless supplied $ports && $ports ne '-';
|
||||
validate_portpair1( $proto, $ports );
|
||||
$addrlist .= " --to-ports $ports";
|
||||
$addrlist .= " --to-source :$ports";
|
||||
$exceptionrule = do_proto( $proto, '', '' );
|
||||
}
|
||||
} else {
|
||||
@@ -5614,6 +5627,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
if ( supplied $addresses ) {
|
||||
validate_portpair1($proto, $addresses );
|
||||
$target .= " --to-ports $addresses";
|
||||
$exceptionrule = do_proto( $proto, '', '' );
|
||||
}
|
||||
}
|
||||
#
|
||||
@@ -5699,7 +5713,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
|
||||
conditional_rule_end( $chainref ) if $detectaddress || $conditional;
|
||||
|
||||
if ( $add_snat_aliases ) {
|
||||
if ( $add_snat_aliases && $addresses ) {
|
||||
my ( $interface, $alias , $remainder ) = split( /:/, $fullinterface, 3 );
|
||||
fatal_error "Invalid alias ($alias:$remainder)" if defined $remainder;
|
||||
for my $address ( split_list $addresses, 'address' ) {
|
||||
@@ -5722,6 +5736,8 @@ sub process_snat1( $$$$$$$$$$$$ ) {
|
||||
}
|
||||
|
||||
$addresses = $saveaddresses;
|
||||
$target = $savetarget;
|
||||
$baserule = $savebaserule;
|
||||
}
|
||||
|
||||
progress_message " Snat record \"$currentline\" $done"
|
||||
@@ -5755,11 +5771,10 @@ sub setup_snat( $ ) # Convert masq->snat if true
|
||||
convert_masq() if $_[0];
|
||||
|
||||
if ( $fn = open_file( 'masq', 1, 1 ) ) {
|
||||
|
||||
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty masq file" , 's'; } );
|
||||
|
||||
process_one_masq(0) while read_a_line( NORMAL_READ );
|
||||
} elsif ( $fn = open_file( 'snat', 1, 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 );
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,6 @@ our @EXPORT = ( qw( NOTHING
|
||||
get_interface_origin
|
||||
interface_has_option
|
||||
set_interface_option
|
||||
set_interface_provider
|
||||
interface_zone
|
||||
interface_zones
|
||||
verify_required_interfaces
|
||||
@@ -195,7 +194,6 @@ our %reservedName = ( all => 1,
|
||||
# number => <ordinal position in the interfaces file>
|
||||
# physical => <physical interface name>
|
||||
# base => <shell variable base representing this interface>
|
||||
# provider => <Provider Name, if interface is associated with a provider>
|
||||
# wildcard => undef|1 # Wildcard Name
|
||||
# zones => { zone1 => 1, ... }
|
||||
# origin => <where defined>
|
||||
|
@@ -128,6 +128,7 @@ g_compiled=
|
||||
g_file=
|
||||
g_docker=
|
||||
g_dockernetwork=
|
||||
g_forcereload=
|
||||
|
||||
initialize
|
||||
|
||||
|
@@ -10,12 +10,14 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-snat"
|
||||
###################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
#
|
||||
# See http://shorewall.net/manpages/shorewall-snat.html for more information
|
||||
###########################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT 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
|
||||
#
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
192.168.0.0/16 eth0
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
192.168.0.0/16 eth0
|
||||
|
@@ -10,12 +10,14 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-snat"
|
||||
###################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
#
|
||||
# See http://shorewall.net/manpages/shorewall-snat.html for more information
|
||||
###########################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT 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
|
||||
#
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
192.168.0.0/16 eth0
|
||||
MASQUERADE 10.0.0.0/8,\
|
||||
169.254.0.0/16,\
|
||||
172.16.0.0/12,\
|
||||
1 92.168.0.0/16 eth0
|
||||
|
@@ -1,8 +1,9 @@
|
||||
#
|
||||
# Shorewall SNAT/Masquerade File
|
||||
# Shorewall -- /etc/shorewall/snat
|
||||
#
|
||||
# For information about entries in this file, type "man shorewall-snat"
|
||||
#
|
||||
# See http://shorewall.net/manpages/shorewall-snat.html for additional information
|
||||
###################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
# See http://shorewall.net/manpages/shorewall-snat.html for more information
|
||||
#
|
||||
###########################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
|
@@ -703,7 +703,7 @@ run_install $OWNERSHIP -m 0644 snat ${DESTDIR}${SHAREDIR}/$PRODUCT/con
|
||||
run_install $OWNERSHIP -m 0644 snat.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles
|
||||
|
||||
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/snat ]; then
|
||||
run_install $OWNERSHIP -m 0600 masq${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/masq
|
||||
run_install $OWNERSHIP -m 0600 snat${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/snat
|
||||
echo "SNAT file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/snat"
|
||||
fi
|
||||
|
||||
|
@@ -164,7 +164,7 @@
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ADDRESS</emphasis> (Optional) - [<emphasis
|
||||
role="bold">-</emphasis>|<emphasis
|
||||
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>[,<emphasis>address-or-address-range</emphasis>]...][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
||||
role="bold">:random</emphasis>][:persistent]|<emphasis
|
||||
role="bold">detect</emphasis>|<emphasis
|
||||
|
@@ -75,7 +75,7 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">SNAT[+]</emphasis>([<emphasis>address-or-address-range</emphasis>[,<emphasis>address-or-address-range</emphasis>]...][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">SNAT[+]</emphasis>([<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
||||
role="bold">:random</emphasis>][:<option>persistent</option>]|<emphasis
|
||||
role="bold">detect</emphasis>|</term>
|
||||
|
@@ -1087,10 +1087,12 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
|
||||
<para>Beginning with Shorewall 5.0.0, it is no longer necessary to
|
||||
set INLINE_MATCHES=Yes in order to be able to specify your own
|
||||
iptables text in a rule. You may simply preface that text with a
|
||||
pair of semicolons (";;"). If alternate input is also specified in
|
||||
the rule, it should appear before the semicolons and may be
|
||||
separated from normal column input by a single semicolon.</para>
|
||||
iptables text in a rule and INLINE_MATCHES=Yes is deprecated.
|
||||
Beginning with 5.0.0, you may simply preface your text with a pair
|
||||
of semicolons (";;"). If alternate input is also specified in the
|
||||
rule, it should appear before the semicolons and may be separated
|
||||
from normal column input by a single semicolon or enclosed in curly
|
||||
braces ("{....}").</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
#
|
||||
# Shorewall6 SNAT/Masquerade File
|
||||
# Shorewall6 -- /etc/shorewall6/snat
|
||||
#
|
||||
# For information about entries in this file, type "man shorewall6-snat"
|
||||
#
|
||||
# See http://shorewall.net/manpages6/shorewall6-snat.html for additional information
|
||||
###################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
# See http://shorewall.net/manpages6/shorewall6-snat.html for more information
|
||||
#
|
||||
###########################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
|
||||
|
@@ -125,7 +125,7 @@
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ADDRESS</emphasis> (Optional) - [<emphasis
|
||||
role="bold">-</emphasis>|<emphasis
|
||||
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>[,<emphasis>address-or-address-range</emphasis>]...][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
||||
role="bold">:random</emphasis>][:persistent]|<emphasis
|
||||
role="bold">detect</emphasis>|<emphasis
|
||||
|
@@ -75,7 +75,7 @@
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis
|
||||
role="bold">SNAT</emphasis>[+]([<emphasis>address-or-address-range</emphasis>[,<emphasis>address-or-address-range</emphasis>]...][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">SNAT</emphasis>[+]([<emphasis>address-or-address-range</emphasis>][:<emphasis>lowport</emphasis><emphasis
|
||||
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
||||
role="bold">:random</emphasis>][:<option>persistent</option>]|<emphasis
|
||||
role="bold">detect</emphasis>|</term>
|
||||
|
@@ -920,13 +920,13 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.0. Traditionally in <ulink
|
||||
url="/manpages6/shorewall6-rules.html">shorewall6-rules(5)</ulink>,
|
||||
url="/manpages6/shorewall6-rules.html">shorewall6-rules</ulink>(5),
|
||||
a semicolon separates column-oriented specifications on the left
|
||||
from <ulink url="/configuration_file_basics.htm#Pairs">alternative
|
||||
specificaitons</ulink> on the right.. When INLINE_MATCHES=Yes is
|
||||
specified, the specifications on the right are interpreted as if
|
||||
INLINE had been specified in the ACTION column. This also applies to
|
||||
<ulink url="shorewall6-masq.html">shorewall6-masq(5)</ulink> and
|
||||
<ulink url="shorewall-masq.html">shorewall6-masq(5)</ulink> and
|
||||
<ulink url="shorewall6-mangle.html">shorewall6-mangle(5</ulink>)
|
||||
which also support INLINE. If not specified or if specified as the
|
||||
empty value, the value 'No' is assumed for backward
|
||||
@@ -934,10 +934,12 @@ net all DROP info</programlisting>then the chain name is 'net-all'
|
||||
|
||||
<para>Beginning with Shorewall 5.0.0, it is no longer necessary to
|
||||
set INLINE_MATCHES=Yes in order to be able to specify your own
|
||||
iptables text in a rule. You may simply preface that text with a
|
||||
pair of semicolons (";;"). If alternate input is also specified in
|
||||
the rule, it should appear before the semicolons and may be
|
||||
separated from normal column input by a single semicolon.</para>
|
||||
iptables text in a rule and INLINE_MATCHES=Yes is deprecated.
|
||||
Beginning with 5.0.0, you may simply preface your text with a pair
|
||||
of semicolons (";;"). If alternate input is also specified in the
|
||||
rule, it should appear before the semicolons and may be separated
|
||||
from normal column input by a single semicolon or enclosed in curly
|
||||
braces ("{....}").</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -106,8 +106,17 @@
|
||||
url="Install.htm#idp8774904608">configure scripts included with Shorewall
|
||||
Core</ulink>.</para>
|
||||
|
||||
<important>
|
||||
<para>Since Shorewall 4.5.2, each of these directories is now
|
||||
relocatable using the <ulink url="Install.htm#idp8774904608">configure
|
||||
scripts included with Shorewall Core</ulink>. These scripts set shell
|
||||
variables in the shorewallrc file which is normally installed in
|
||||
/usr/share/shorewall/. The name of the variable is included in
|
||||
parentheses in the section headings below.</para>
|
||||
</important>
|
||||
|
||||
<section id="sbin">
|
||||
<title>/sbin</title>
|
||||
<title>/sbin ($SBINDIR)</title>
|
||||
|
||||
<para>The <filename>/sbin/shorewall</filename> shell program is used to
|
||||
interact with Shorewall. See <ulink
|
||||
@@ -115,7 +124,7 @@
|
||||
</section>
|
||||
|
||||
<section id="share-shorewall">
|
||||
<title>/usr/share/shorewall</title>
|
||||
<title>/usr/share/shorewall (${SHAREDIR}/shorewall)</title>
|
||||
|
||||
<para>The bulk of Shorewall is installed here.</para>
|
||||
|
||||
@@ -220,22 +229,28 @@
|
||||
</section>
|
||||
|
||||
<section id="shorewall">
|
||||
<title>/etc/shorewall</title>
|
||||
<title>/etc/shorewall (${CONFDIR}/shorewall)</title>
|
||||
|
||||
<para>This is where the modifiable IPv4 configuration files are
|
||||
installed.</para>
|
||||
</section>
|
||||
|
||||
<section id="init">
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)</title>
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)
|
||||
($INITDIR)</title>
|
||||
|
||||
<para>An init script is installed here. Depending on the distribution,
|
||||
it is named <filename>shorewall</filename> or
|
||||
<filename>rc.firewall</filename>.</para>
|
||||
<filename>rc.firewall</filename>. Only installed on systems where
|
||||
systemd is not installed.</para>
|
||||
|
||||
<para>When systemd is installed, the Shorewall .service files are
|
||||
installed in the directory specified by the SERVICEDIR variable in
|
||||
<filename>/usr/share/shorewall/shorewallrc</filename>.</para>
|
||||
</section>
|
||||
|
||||
<section id="var">
|
||||
<title>/var/lib/shorewall</title>
|
||||
<title>/var/lib/shorewall (${VARLIB}/shorewall)</title>
|
||||
|
||||
<para>Shorewall doesn't install any files in this directory but rather
|
||||
uses the directory for storing state information. This directory may be
|
||||
@@ -332,7 +347,7 @@
|
||||
<para>Shorewall6 installs its files in a number of directories:</para>
|
||||
|
||||
<section id="sbin6">
|
||||
<title>/sbin</title>
|
||||
<title>/sbin ($SBINDIR)</title>
|
||||
|
||||
<para>The <filename>/sbin/shorewall6</filename> shell program is used to
|
||||
interact with Shorewall6. See <ulink
|
||||
@@ -340,7 +355,7 @@
|
||||
</section>
|
||||
|
||||
<section id="share-shorewall6">
|
||||
<title>/usr/share/shorewall6</title>
|
||||
<title>/usr/share/shorewall6 (${SHAREDIR}/shorewall6)</title>
|
||||
|
||||
<para>The bulk of Shorewall6 is installed here.</para>
|
||||
|
||||
@@ -417,14 +432,28 @@
|
||||
</section>
|
||||
|
||||
<section id="etc-shorewall6">
|
||||
<title>/etc/shorewall6</title>
|
||||
<title>/etc/shorewall6 (${CONFDIR}/</title>
|
||||
|
||||
<para>This is where the modifiable IPv6 configuration files are
|
||||
installed.</para>
|
||||
</section>
|
||||
|
||||
<section id="init">
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)
|
||||
($INITDIR)</title>
|
||||
|
||||
<para>An init script is installed here. Depending on the distribution,
|
||||
it is named <filename>shorewall6</filename> or
|
||||
<filename>rc.firewall</filename>. Only installed on systems where
|
||||
systemd is not installed.</para>
|
||||
|
||||
<para>When systemd is installed, the Shorewall .service files are
|
||||
installed in the directory specified by the SERVICEDIR variable in
|
||||
<filename>/usr/share/shorewall/shorewallrc</filename>.</para>
|
||||
</section>
|
||||
|
||||
<section id="var-shorewall6">
|
||||
<title>/var/lib/shorewall6</title>
|
||||
<title>/var/lib/shorewall6 (${VARLIB}/shorewall6)</title>
|
||||
|
||||
<para>Shorewall6 doesn't install any files in this directory but rather
|
||||
uses the directory for storing state information. This directory may be
|
||||
@@ -514,7 +543,7 @@
|
||||
in the sub-sections that follow.</para>
|
||||
|
||||
<section id="sbin-lite">
|
||||
<title>/sbin</title>
|
||||
<title>/sbin ($SBINDIR_</title>
|
||||
|
||||
<para>The <filename>/sbin/shorewall-lite</filename> shell program is
|
||||
used to interact with Shorewall lite. See <ulink
|
||||
@@ -522,22 +551,28 @@
|
||||
</section>
|
||||
|
||||
<section id="init-lite">
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)</title>
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)
|
||||
($INITDIR)</title>
|
||||
|
||||
<para>An init script is installed here. Depending on the distribution,
|
||||
it is named <filename>shorewall-lite</filename> or
|
||||
<filename>rc.firewall</filename>.</para>
|
||||
<filename>rc.firewall</filename>. Only installed on systems where
|
||||
systemd is not installed.</para>
|
||||
|
||||
<para>When systemd is installed, the Shorewall .service files are
|
||||
installed in the directory specified by the SERVICEDIR variable in
|
||||
<filename>/usr/share/shorewall/shorewallrc</filename>.</para>
|
||||
</section>
|
||||
|
||||
<section id="shorewall-lite">
|
||||
<title>/etc/shorewall-lite</title>
|
||||
<title>/etc/shorewall-lite (${CONFDIR}/shorewall-lite)</title>
|
||||
|
||||
<para>This is where the modifiable configuration files are
|
||||
installed.</para>
|
||||
</section>
|
||||
|
||||
<section id="share-lite">
|
||||
<title>/usr/share/shorewall-lite</title>
|
||||
<title>/usr/share/shorewall-lite (${SHAREDIR}/shorewall-lite)</title>
|
||||
|
||||
<para>The bulk of Shorewall-lite is installed here.</para>
|
||||
|
||||
@@ -586,7 +621,7 @@
|
||||
</section>
|
||||
|
||||
<section id="var-lite">
|
||||
<title>/var/lib/shorewall-lite</title>
|
||||
<title>/var/lib/shorewall-lite (${VARLIB}/shorewall-lite)</title>
|
||||
|
||||
<para>Shorewall-lite doesn't install any files in this directory but
|
||||
rather uses the directory for storing state information. This directory
|
||||
@@ -719,15 +754,29 @@
|
||||
<filename>rc.firewall</filename>.</para>
|
||||
</section>
|
||||
|
||||
<section id="init">
|
||||
<title>/etc/init.d or /etc/rc.d (depends on distribution)
|
||||
($INITDIR)</title>
|
||||
|
||||
<para>An init script is installed here. Depending on the distribution,
|
||||
it is named <filename>shorewall</filename>6-lite or
|
||||
<filename>rc.firewall</filename>. Only installed on systems where
|
||||
systemd is not installed.</para>
|
||||
|
||||
<para>When systemd is installed, the Shorewall .service files are
|
||||
installed in the directory specified by the SERVICEDIR variable in
|
||||
<filename>/usr/share/shorewall/shorewallrc</filename>.</para>
|
||||
</section>
|
||||
|
||||
<section id="etc-shorewall6-lite">
|
||||
<title>/etc/shorewall6-lite</title>
|
||||
<title>/etc/shorewall6-lite (${CONFDIR}/shorewall6-lite)</title>
|
||||
|
||||
<para>This is where the modifiable configuration files are
|
||||
installed.</para>
|
||||
</section>
|
||||
|
||||
<section id="share-lite6">
|
||||
<title>/usr/share/shorewall6-lite</title>
|
||||
<title>/usr/share/shorewall6-lite (${SHAREDIR}/shorewall6-lite)</title>
|
||||
|
||||
<para>The bulk of Shorewall-lite is installed here.</para>
|
||||
|
||||
@@ -776,7 +825,7 @@
|
||||
</section>
|
||||
|
||||
<section id="var-lite6">
|
||||
<title>/var/lib/shorewall6-lite</title>
|
||||
<title>/var/lib/shorewall6-lite (${VARLIB}/shorewall6-lite)</title>
|
||||
|
||||
<para>Shorewall6-lite doesn't install any files in this directory but
|
||||
rather uses the directory for storing state information. This directory
|
||||
|
@@ -102,12 +102,9 @@
|
||||
<listitem>
|
||||
<para>Your kernel must contain Netfilter physdev match support
|
||||
(CONFIG_IP_NF_MATCH_PHYSDEV=m or CONFIG_IP_NF_MATCH_PHYSDEV=y).
|
||||
Physdev match is standard in the 2.6 kernel series but must be patched
|
||||
into the 2.4 kernels (see <ulink
|
||||
url="http://bridge.sf.net">http://bridge.sf.net</ulink>). Bering and
|
||||
Bering uCLibc users must find and install ipt_physdev.o for their
|
||||
distribution and add <quote>ipt_physdev</quote> to
|
||||
/etc/modules.</para>
|
||||
Physdev match is standard in the 2.6 and later kernel series but must
|
||||
be patched into the 2.4 kernels (see <ulink
|
||||
url="http://bridge.sf.net">http://bridge.sf.net</ulink>).</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
|
@@ -1655,11 +1655,17 @@ SSH(ACCEPT) net:$MYIP $FW
|
||||
<title>Address Variables</title>
|
||||
|
||||
<caution>
|
||||
<para>If you use address variables that refer to an optional interface,
|
||||
the <command>enable</command> command will not change/insert the rules
|
||||
that use the variable. Therefore, to be completely safe, if you use such
|
||||
address variables then you must follow an <command>enable</command>
|
||||
command with a <command>reload</command> command.</para>
|
||||
<para>Prior to Shorewall 5.0.14, if you use address variables that refer
|
||||
to an optional interface, the <command>enable</command> command will not
|
||||
change/insert the rules that use the variable. Therefore, to be
|
||||
completely safe, if you use such address variables then you must follow
|
||||
a successful <command>enable</command> command with a
|
||||
<command>reload</command> command.</para>
|
||||
|
||||
<para>Beginning with Shorewall 5.0.14, if a Shorewall-defined address
|
||||
variable's value has changed since the Netfilter ruleset was
|
||||
instantiated, then a successful <command>enable</command> command will
|
||||
automatically reload the ruleset.</para>
|
||||
</caution>
|
||||
|
||||
<para>Given that shell variables are expanded at compile time, there is no
|
||||
@@ -1891,9 +1897,8 @@ SSH(ACCEPT) net:$MYIP $FW
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>If there is no gateway out of the named interface, the nil IP
|
||||
address is used (0.0.0.0 in IPv4 and :: in IPv6). That way, the generated
|
||||
rule will match no packets (or all packets if used with exclusion).</para>
|
||||
<para>If there is no gateway out of the named interface, rules containing
|
||||
the intefaces's run-time gateway variable are omitted.</para>
|
||||
</section>
|
||||
|
||||
<section id="ActionVariables">
|
||||
|
@@ -13,14 +13,20 @@
|
||||
|
||||
<surname>Eastep</surname>
|
||||
</author>
|
||||
|
||||
<author>
|
||||
<surname>Bill Shirley</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
|
||||
<pubdate><?dbtimestamp format="Y/m/d"?></pubdate>
|
||||
|
||||
<copyright>
|
||||
<year>2001 - 2015</year>
|
||||
<year>2001 - 2016</year>
|
||||
|
||||
<holder>Thomas M. Eastep</holder>
|
||||
|
||||
<holder>Bill Shirley</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
@@ -463,9 +469,32 @@ sync=1</programlisting>
|
||||
<para>By setting the LOGTAGONLY option to Yes in <ulink
|
||||
url="manpages/shorewall.conf.html">shorewall.conf(5)</ulink> or <ulink
|
||||
url="manpages6/shorewall6.conf.html">shorewall6.conf(5)</ulink>, the
|
||||
disposition ('DROP' in the above example) will be omitted. See the
|
||||
shorewall[6].conf man page for further information about how
|
||||
LOGTAGONLY=Yes can be used.</para>
|
||||
disposition ('DROP' in the above example) will be omitted. Consider the
|
||||
following rule:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO
|
||||
REJECT(icmp-proto-unreachable):notice:IPv6 loc net 41 # who's using IPv6 tunneling</programlisting>
|
||||
|
||||
<para>This rule generates the following warning at compile time:</para>
|
||||
|
||||
<simplelist>
|
||||
<member>WARNING: Log Prefix shortened to "Shorewall:IPv6:REJECT(icmp-p
|
||||
" /etc/shorewall/rules (line 212)</member>
|
||||
</simplelist>
|
||||
|
||||
<para>and produces the rather ugly prefix "Shorewall:IPv6:REJECT(icmp-p
|
||||
".</para>
|
||||
|
||||
<para>Now consider this similar rule:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO
|
||||
REJECT(icmp-proto-unreachable):notice:IPv6,tunneling loc net 41 # who's using IPv6 tunneling</programlisting>
|
||||
|
||||
<para>With LOGTAGONLY=Yes, no warning is generated and the prefix
|
||||
becomes "Shorewall:IPv6:tunneling:"</para>
|
||||
|
||||
<para>See the shorewall[6].conf man page for further information about
|
||||
how LOGTAGONLY=Yes can be used.</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -479,4 +508,72 @@ sync=1</programlisting>
|
||||
linkend="LogTags">above</link>.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Some Additional Thoughts on Logging (by Bill Shirley)</title>
|
||||
|
||||
<para>As a side note to the LOGTAGONLY example above, i recommend blocking
|
||||
all tunneling because it bypasses the firewall rules:</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO DPORT
|
||||
?COMMENT tunneling
|
||||
REJECT(icmp-proto-unreachable):notice:IPv6,tunneling loc net 41 # who's using IPv6 tunneling
|
||||
REJECT(icmp-port-unreachable) loc net tcp,udp teredo
|
||||
REJECT(icmp-port-unreachable) loc net tcp,udp isakmp,ipsec-nat-t</programlisting>
|
||||
|
||||
<para>Here is an example of logging traffic only once:</para>
|
||||
|
||||
<para><filename>/etc/shorewall/init:</filename></para>
|
||||
|
||||
<programlisting>ipset -exist create IPv4 hash:ip timeout 86400
|
||||
ipset -exist create IPv4-port hash:ip,port timeout 14400</programlisting>
|
||||
|
||||
<para><filename>/etc/shorewall/rules</filename> (at the top):</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO
|
||||
?SECTION NEW
|
||||
# ------------------
|
||||
?COMMENT drop previously flagged
|
||||
DROP net:+IPv4[src] fw
|
||||
DROP net:+IPv4-port[src,dst] fw</programlisting>
|
||||
|
||||
<para>After all the rules have been checked, at the bottom of
|
||||
<filename>/etc/shorewall/rules</filename>:</para>
|
||||
|
||||
<programlisting># =============================================================================
|
||||
# =============================== H@ck0rz =====================================
|
||||
# =============================================================================
|
||||
?COMMENT dont whack myself
|
||||
REJECT:notice inet:$ME_NET fw
|
||||
|
||||
?COMMENT not public
|
||||
ADD(+IPv4-port:src,dst) net fw tcp,udp domain
|
||||
ADD(+IPv4-port:src,dst) net fw tcp ldap,ldaps
|
||||
ADD(+IPv4-port:src,dst) net fw tcp,udp ipp
|
||||
|
||||
?COMMENT H@ck0rz
|
||||
ADD(+IPv4:src) net fw tcp ssh
|
||||
ADD(+IPv4:src) net fw tcp ftp,ftps,sftp,telnet,telnets,exec,login,shell,sunrpc
|
||||
ADD(+IPv4:src) net fw tcp,udp ms-sql-s,ms-sql-m
|
||||
|
||||
?COMMENT drop if added
|
||||
DROP:info:BAN,IPv4 net:+IPv4[src] fw
|
||||
DROP:info:BAN,IPv4-port net:+IPv4-port[src,dst] fw</programlisting>
|
||||
|
||||
<para>One final note: I wanted less firewall messages in /var/log/messages
|
||||
so I added to rsyslog.conf:</para>
|
||||
|
||||
<programlisting>#### RULES #### <-- find this
|
||||
if $msg contains 'Shorewall' then {
|
||||
action(type="omfile" file="/var/log/shorewall.log")
|
||||
# if ($syslogfacility == 0 and $syslogseverity >= 4) then stop # warning
|
||||
# if ($syslogfacility == 0 and $syslogseverity >= 5) then stop # notice
|
||||
if ($syslogfacility == 0 and $syslogseverity >= 6) then stop # info
|
||||
}</programlisting>
|
||||
|
||||
<para> I log at 'notice' log level if I want the message in
|
||||
<filename>/var/log/messages</filename> and everything goes to
|
||||
<filename>/var/log/shorewall.log</filename>. Don't forget to add
|
||||
/var/log/shorewall.log to logrotate. </para>
|
||||
</section>
|
||||
</article>
|
||||
|
@@ -1373,8 +1373,9 @@ Destination Gateway Genmask Flags MSS Window irtt Iface
|
||||
|
||||
<member>SNAT is configured in Shorewall using the <filename><ulink
|
||||
url="manpages/shorewall-masq.html">/etc/shorewall/masq</ulink></filename>
|
||||
file (/etc/shorewall/snat when running Shorewall 5.0.14 or
|
||||
later):</member>
|
||||
file (<ulink
|
||||
url="manpages/shorewall-snat.html">/etc/shorewall/snat</ulink> when
|
||||
running Shorewall 5.0.14 or later):</member>
|
||||
</simplelist>
|
||||
|
||||
<programlisting>#INTERFACE SOURCE ADDRESS
|
||||
|
@@ -194,6 +194,17 @@
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/policy
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/rules
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/zones
|
||||
~#</programlisting>
|
||||
|
||||
<para>When running Shorewall 5.0.14 or later:</para>
|
||||
|
||||
<programlisting>~# rpm -ql shorewall | fgrep three-interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/policy
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/rules
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/snat
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/zones
|
||||
~#</programlisting>
|
||||
</listitem>
|
||||
|
||||
@@ -667,14 +678,18 @@ root@lists:~# </programlisting>
|
||||
|
||||
<para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para>
|
||||
|
||||
<para>If your external IP is static, you can enter it in the third column
|
||||
in the <filename
|
||||
<para>If your external <acronym>IP</acronym> is static then, if you are
|
||||
running Shorewall 5.0.13 or earlier, you can enter our static IP in the
|
||||
third column in the <filename
|
||||
class="directory">/etc/shorewall/</filename><filename>masq</filename>
|
||||
entry if you like although your firewall will work fine if you leave that
|
||||
column empty. Entering your static IP in column 3 makes processing
|
||||
outgoing packets a little more efficient. When running Shorewall 5.0.14 or
|
||||
later, the rule in /etc/shorewall/snat must be change from a MASQUERADE
|
||||
rule to an SNAT rule.</para>
|
||||
column empty (Masquerade). Entering your static <acronym>IP</acronym> in
|
||||
column 3 (SNAT) makes the processing of outgoing packets a little more
|
||||
efficient.</para>
|
||||
|
||||
<para>When running Shorewall 5.0.14 or later, the rule in
|
||||
/etc/shorewall/snat must be change from a MASQUERADE rule to an SNAT
|
||||
rule.</para>
|
||||
|
||||
<programlisting>#ACTION SOURCE DEST PROTO PORT
|
||||
<emphasis role="bold">SNAT(<replaceable>static-ip</replaceable>)</emphasis> ...</programlisting>
|
||||
|
@@ -172,6 +172,17 @@
|
||||
/usr/share/doc/packages/shorewall/Samples/two-interfaces/policy
|
||||
/usr/share/doc/packages/shorewall/Samples/two-interfaces/rules
|
||||
/usr/share/doc/packages/shorewall/Samples/two-interfaces/zones
|
||||
~#</programlisting>
|
||||
|
||||
<para>When running Shorewall 5.0.14 or later:</para>
|
||||
|
||||
<programlisting>~# rpm -ql shorewall | fgrep three-interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/interfaces
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/policy
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/rules
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/snat
|
||||
/usr/share/doc/packages/shorewall/Samples/three-interfaces/zones
|
||||
~#</programlisting>
|
||||
</listitem>
|
||||
|
||||
@@ -618,13 +629,16 @@ root@lists:~# </programlisting>
|
||||
|
||||
<para><inlinegraphic fileref="images/BD21298_.gif" format="GIF"/></para>
|
||||
|
||||
<para>If your external <acronym>IP</acronym> is static, you can enter it
|
||||
in the third column in the <filename
|
||||
<para>If your external <acronym>IP</acronym> is static then, if you are
|
||||
running Shorewall 5.0.13 or earlier, you can enter our static IP in the
|
||||
third column in the <filename
|
||||
class="directory">/etc/shorewall/</filename><filename>masq</filename>
|
||||
entry if you like although your firewall will work fine if you leave that
|
||||
column empty (Masquerade). Entering your static <acronym>IP</acronym> in
|
||||
column 3 (SNAT) makes the processing of outgoing packets a little more
|
||||
efficient. When running Shorewall 5.0.14 or later, the rule in
|
||||
efficient.</para>
|
||||
|
||||
<para>When running Shorewall 5.0.14 or later, the rule in
|
||||
/etc/shorewall/snat must be change from a MASQUERADE rule to an SNAT
|
||||
rule.</para>
|
||||
|
||||
|
Reference in New Issue
Block a user