From a539f08be256d662fb0b7661eca43d03ca24e97a Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Sun, 20 Feb 2005 20:18:05 +0000 Subject: advanced nat can now do source port mapping (useful for IPSec traversal) --- usr/local/www/firewall_nat_out_edit.php | 55 ++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'usr/local/www/firewall_nat_out_edit.php') diff --git a/usr/local/www/firewall_nat_out_edit.php b/usr/local/www/firewall_nat_out_edit.php index bdf0242..2fca182 100755 --- a/usr/local/www/firewall_nat_out_edit.php +++ b/usr/local/www/firewall_nat_out_edit.php @@ -61,8 +61,10 @@ function network_to_pconfig($adr, &$padr, &$pmask, &$pnot) { if (isset($id) && $a_out[$id]) { list($pconfig['source'],$pconfig['source_subnet']) = explode('/', $a_out[$id]['source']['network']); + $pconfig['sourceport'] = $a_out[$id]['sourceport']; network_to_pconfig($a_out[$id]['destination'], $pconfig['destination'], $pconfig['destination_subnet'], $pconfig['destination_not']); + $pconfig['natport'] = $a_out[$id]['natport']; $pconfig['target'] = $a_out[$id]['target']; $pconfig['interface'] = $a_out[$id]['interface']; if (!$pconfig['interface']) @@ -97,6 +99,9 @@ if ($_POST) { if ($_POST['source_subnet'] && !is_numericint($_POST['source_subnet'])) { $input_errors[] = "A valid source bit count must be specified."; } + if ($_POST['sourceport'] && !is_numericint($_POST['sourceport'])) { + $input_errors[] = "A valid source port must be specified."; + } if ($_POST['destination_type'] != "any") { if ($_POST['destination'] && !is_ipaddr($_POST['destination'])) { $input_errors[] = "A valid destination must be specified."; @@ -107,7 +112,10 @@ if ($_POST) { } if ($_POST['destination_type'] != "any") { if ($_POST['destination_not']) - $input_errors[] = "Negating destination address of \"any\" is invalid."; + $input_errors[] = "Negating destination address of \"any\" is invalid."; + } + if ($_POST['natport'] && !is_numericint($_POST['natport'])) { + $input_errors[] = "A valid NAT port must be specified."; } if ($_POST['target'] && !is_ipaddr($_POST['target'])) { @@ -155,6 +163,7 @@ if ($_POST) { if (!$input_errors) { $natent = array(); $natent['source']['network'] = $osn; + $natent['sourceport'] = $_POST['sourceport']; $natent['descr'] = $_POST['descr']; $natent['target'] = $_POST['target']; $natent['interface'] = $_POST['interface']; @@ -164,6 +173,8 @@ if ($_POST) { else $natent['destination']['network'] = $ext; + $natent['natport'] = $_POST['natport']; + if (isset($_POST['destination_not']) && $ext != "any") $natent['destination']['not'] = true; @@ -234,18 +245,30 @@ function typesel_change() { Source - - - / - -
- Enter the source network for the outbound NAT mapping. + + + / + + + + + + + + + + + + + +
Address:  
 Enter the source network for the outbound NAT mapping.
Port:  
 Enter the source port for the outbound NAT mapping.
Destination @@ -281,7 +304,11 @@ function typesel_change() { Enter the destination network for the outbound NAT mapping. - + + NAT port:   + (leave blank for any) + + Target -- cgit v1.1