diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 668ed15f7..8fb71b1df 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -1529,7 +1529,7 @@ function filter_nat_rules_generate(&$FilterIflist) $tmp = explode('/', $srcaddr); $srcip = $tmp[0]; - if (!empty($tmp[1]) && is_numeric($tmp[1])) { + if (!empty($tmp[1]) && is_numeric($tmp[1]) && strpos($target, '/') === false) { $sn = $tmp[1]; $sn1 = "/{$sn}"; } @@ -1546,8 +1546,8 @@ function filter_nat_rules_generate(&$FilterIflist) } else { $nat_if_list = array(); } - - $natrules .= "binat on {$natif} from {$srcaddr} to {$dstaddr} -> {$target}{$sn1}\n"; + $nattype = empty($rule['type']) ? "binat" : $rule['type']; + $natrules .= "{$nattype} on {$natif} from {$srcaddr} to {$dstaddr} -> {$target}{$sn1}\n"; if (!empty($nat_if_list)) { $binat_if_list = implode(" ", $nat_if_list); $binat_if_list = "{ {$binat_if_list} }"; diff --git a/src/www/firewall_nat_1to1.php b/src/www/firewall_nat_1to1.php index 15866b74a..493db60e9 100644 --- a/src/www/firewall_nat_1to1.php +++ b/src/www/firewall_nat_1to1.php @@ -226,7 +226,7 @@ $main_buttons = array( - +   diff --git a/src/www/firewall_nat_1to1_edit.php b/src/www/firewall_nat_1to1_edit.php index 523f1805f..3989ee79b 100644 --- a/src/www/firewall_nat_1to1_edit.php +++ b/src/www/firewall_nat_1to1_edit.php @@ -47,9 +47,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['interface'] = "wan"; $pconfig['src'] = 'lan'; $pconfig['dst'] = 'any'; + $pconfig['type'] = 'binat'; if (isset($configId)) { // copy settings from config - foreach (array('disabled','interface','external','descr','natreflection') as $fieldname) { + foreach (array('disabled','interface','external','descr','natreflection', 'type') as $fieldname) { if (isset($a_1to1[$configId][$fieldname])) { $pconfig[$fieldname] = $a_1to1[$configId][$fieldname]; } else { @@ -100,8 +101,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { /* For external, user can enter only ip's */ - if (!empty($pconfig['external']) && !is_ipaddr($_POST['external'])) { - $input_errors[] = gettext("A valid external subnet must be specified."); + $tmpext = explode('/', $pconfig['external']); + //print_r($tmpext);echo $pconfig['srcmask'] ;die; + if (!empty($pconfig['external'])) { + if ($pconfig['type'] == 'binat' && (!is_ipaddr($tmpext[0]) || (count($tmpext) != 1 && $pconfig['srcmask'] != $tmpext[1]))) { + $input_errors[] = gettext("A valid external subnet must be specified."); + } elseif ($pconfig['type'] == 'nat' && !is_subnet($pconfig['external'])) { + $input_errors[] = gettext("A valid external subnet must be specified."); + } } /* For src, user can enter only ip's or networks */ if (!is_specialnet($pconfig['src']) && !is_ipaddroralias($pconfig['src'])) { @@ -124,6 +131,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $natent['external'] = $pconfig['external']; $natent['descr'] = $pconfig['descr']; $natent['interface'] = $pconfig['interface']; + $natent['type'] = $pconfig['type']; // copy form data with some kind of logic in it $natent['disabled'] = isset($_POST['disabled']) ? true:false; @@ -255,19 +263,36 @@ include("head.inc"); - + - -
-