Add static-port option for outbound NAT

This commit is contained in:
Scott Ullrich 2006-01-03 04:38:46 +00:00
parent d1d6fdf30b
commit f6ded420af
2 changed files with 18 additions and 1 deletions

View File

@ -388,8 +388,14 @@ function filter_nat_rules_generate_if($if, $src = "any", $srcport = "", $dst = "
$target = "-> {$tgt}";
}
/* outgoing static-port option, hamachi, Grandstream, VOIP, etc */
if($staticnatport)
$staticnatport_txt = " static-port";
else
$staticnatport_txt = "";
/* Put all the pieces together */
$natrule = "{$nat} on {$if} from {$src} to {$dst} {$target}\n";
$natrule = "{$nat} on {$if} from {$src} to {$dst} {$target}{$staticnatport_txt}\n";
return $natrule;
}

View File

@ -63,6 +63,7 @@ if (isset($id) && $a_out[$id]) {
$pconfig['descr'] = $a_out[$id]['descr'];
$pconfig['nonat'] = $a_out[$id]['nonat'];
$pconfig['nosync'] = isset($a_out[$id]['nosync']);
$pconfig['staticnatport'] = isset($a_out[$id]['staticnatport']);
} else {
$pconfig['source_subnet'] = 24;
$pconfig['destination'] = "any";
@ -179,6 +180,12 @@ if ($_POST) {
$natent['target'] = $_POST['target'];
$natent['interface'] = $_POST['interface'];
/* static-port */
if(isset($_POST['staticnatport']))
$natent['staticnatport'] = true;
else
unset($natent['staticnatport']);
/* if user has selected not nat, set it here */
if(isset($_POST['nonat']))
$natent['nonat'] = true;
@ -387,6 +394,10 @@ function sourcesel_change() {
<td>Port:&nbsp;&nbsp;</td>
<td><input name="natport" type="text" class="formfld" id="natport" size="5" value="<?=htmlspecialchars($pconfig['natport']);?>"></td>
</tr>
<tr>
<td>Static-port:&nbsp;&nbsp;</td>
<td><input name="staticnatport" type="text" class="formfld" id="staticnatport" size="5" value="<?=htmlspecialchars($pconfig['staticnatport']);?>"></td>
</tr>
<tr><td>&nbsp;</td><td>
<span class="vexpl">Enter the source port for the outbound NAT mapping.</span>
</td></tr>