diff --git a/Shorewall/Perl/Shorewall/Nat.pm b/Shorewall/Perl/Shorewall/Nat.pm index bec89ed9a..bd62a0ab5 100644 --- a/Shorewall/Perl/Shorewall/Nat.pm +++ b/Shorewall/Perl/Shorewall/Nat.pm @@ -377,7 +377,7 @@ sub setup_nat() { while ( read_a_line ) { - my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 'nat file', { external => 1, interface => 1, internal => 2, allints => 3, localnat => 4 }; + my ( $external, $interfacelist, $internal, $allints, $localnat ) = split_line1 'nat file', { external => 0, interface => 1, internal => 2, allints => 3, localnat => 4 }; if ( $external eq 'COMMENT' ) { process_comment; diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index 17c0b851a..e0c1d061f 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -1777,7 +1777,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { if ( $actiontype & (NATRULE | NONAT | NATONLY ) ) { $targets{$inaction} |= NATRULE if $inaction; - fatal_error "NAT rules are not allowed in the BLACKLIST section" if $blacklist; + fatal_error "NAT rules are only allowed in the NEW section" unless $section eq 'NEW'; } # # Take care of irregular syntax and targets @@ -2172,11 +2172,11 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { my $chn; if ( $inaction ) { - $nonat_chain = ensure_chain 'nat', $chain; + $nonat_chain = ensure_chain( 'nat', $chain ); } elsif ( $sourceref->{type} == FIREWALL ) { $nonat_chain = $nat_table->{OUTPUT}; } else { - $nonat_chain = ensure_chain 'nat', dnat_chain $sourcezone; + $nonat_chain = ensure_chain( 'nat', dnat_chain( $sourcezone ) ); my @interfaces = keys %{zone_interfaces $sourcezone}; @@ -2217,6 +2217,8 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { } } + dont_move( dont_optimize( $nonat_chain ) ) if $tgt eq 'RETURN'; + expand_rule( $nonat_chain , PREROUTE_RESTRICT , $rule , @@ -2228,19 +2230,6 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { $log_action , '', ); - # - # Possible optimization if the rule just generated was a simple jump to the nonat chain - # - if ( $chn && ${$nonat_chain->{rules}}[-1] eq "-A -j $tgt" ) { - # - # It was -- delete that rule - # - pop @{$nonat_chain->{rules}}; - # - # And move the rules from the nonat chain to the zone dnat chain - # - move_rules ( $chn, $nonat_chain ); - } } # @@ -2251,6 +2240,8 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { if ( $actiontype & ACTION ) { $action = $usedactions{$normalized_target}{name}; $loglevel = ''; + } else { + dont_move( dont_optimize ( $chainref ) ) if $action eq 'RETURN'; } if ( $origdest ) { @@ -2265,7 +2256,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$ $) { verify_audit( $action ) if $actiontype & AUDIT; - expand_rule( ensure_chain( 'filter', $chain ) , + expand_rule( $chainref , $restriction , $rule , $source ,