Revision 1d449e7c
Added by Stephen Beaver almost 10 years ago
usr/local/www/firewall_nat_out.php | ||
---|---|---|
32 | 32 |
POSSIBILITY OF SUCH DAMAGE. |
33 | 33 |
*/ |
34 | 34 |
/* |
35 |
pfSense_MODULE: nat
|
|
35 |
pfSense_MODULE: nat
|
|
36 | 36 |
*/ |
37 | 37 |
|
38 | 38 |
##|+PRIV |
... | ... | |
67 | 67 |
$retval = 0; |
68 | 68 |
$retval |= filter_configure(); |
69 | 69 |
|
70 |
if(stristr($retval, "error") <> true)
|
|
71 |
$savemsg = get_std_save_message($retval);
|
|
70 |
if(stristr($retval, "error") != true)
|
|
71 |
$savemsg = get_std_save_message($retval);
|
|
72 | 72 |
else |
73 | 73 |
$savemsg = $retval; |
74 | 74 |
|
... | ... | |
82 | 82 |
/* mutually exclusive settings - if user wants advanced NAT, we don't generate automatic rules */ |
83 | 83 |
if ($_POST['mode'] == "advanced" && ($mode == "automatic" || $mode == "hybrid")) { |
84 | 84 |
/* |
85 |
* user has enabled advanced outbound NAT and doesn't have rules
|
|
86 |
* lets automatically create entries
|
|
87 |
* for all of the interfaces to make life easier on the pip-o-chap
|
|
85 |
* user has enabled advanced outbound NAT and doesn't have rules
|
|
86 |
* lets automatically create entries
|
|
87 |
* for all of the interfaces to make life easier on the pip-o-chap
|
|
88 | 88 |
*/ |
89 | 89 |
if(empty($FilterIflist)) |
90 | 90 |
filter_generate_optcfg_array(); |
... | ... | |
105 | 105 |
$found = false; |
106 | 106 |
foreach ($a_out as $rule) { |
107 | 107 |
if ($rule['interface'] == $natent['interface'] && |
108 |
$rule['source']['network'] == $natent['source']['network'] &&
|
|
109 |
$rule['dstport'] == $natent['dstport'] &&
|
|
110 |
$rule['target'] == $natent['target'] &&
|
|
111 |
$rule['descr'] == $natent['descr']) {
|
|
108 |
$rule['source']['network'] == $natent['source']['network'] &&
|
|
109 |
$rule['dstport'] == $natent['dstport'] &&
|
|
110 |
$rule['target'] == $natent['target'] &&
|
|
111 |
$rule['descr'] == $natent['descr']) {
|
|
112 | 112 |
$found = true; |
113 | 113 |
break; |
114 | 114 |
} |
... | ... | |
146 | 146 |
foreach ($_POST['rule'] as $rulei) { |
147 | 147 |
unset($a_out[$rulei]); |
148 | 148 |
} |
149 |
|
|
149 | 150 |
if (write_config()) |
150 | 151 |
mark_subsystem_dirty('natconf'); |
152 |
|
|
151 | 153 |
header("Location: firewall_nat_out.php"); |
152 | 154 |
exit; |
153 | 155 |
} |
... | ... | |
158 | 160 |
unset($a_out[$_GET['id']]['disabled']); |
159 | 161 |
else |
160 | 162 |
$a_out[$_GET['id']]['disabled'] = true; |
163 |
|
|
161 | 164 |
if (write_config("Firewall: NAT: Outbound, enable/disable NAT rule")) |
162 | 165 |
mark_subsystem_dirty('natconf'); |
166 |
|
|
163 | 167 |
header("Location: firewall_nat_out.php"); |
164 | 168 |
exit; |
165 | 169 |
} |
... | ... | |
186 | 190 |
for ($i = 0; $i < count($a_out); $i++) { |
187 | 191 |
if ($i == $movebtn) |
188 | 192 |
continue; |
193 |
|
|
189 | 194 |
if (in_array($i, $_POST['rule'])) |
190 | 195 |
$a_out_new[] = $a_out[$i]; |
191 | 196 |
} |
... | ... | |
204 | 209 |
|
205 | 210 |
if (write_config()) |
206 | 211 |
mark_subsystem_dirty('natconf'); |
212 |
|
|
207 | 213 |
header("Location: firewall_nat_out.php"); |
208 | 214 |
exit; |
209 | 215 |
} |
210 | 216 |
} |
211 | 217 |
|
218 |
function rule_popup($src,$srcport,$dst,$dstport){ |
|
219 |
global $config,$g; |
|
220 |
$aliases_array = array(); |
|
221 |
if ($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias'])) { |
|
222 |
$descriptions = array (); |
|
223 |
|
|
224 |
foreach ($config['aliases']['alias'] as $alias_id=>$alias_name){ |
|
225 |
$loading_image="<a><img src=\'/themes/{$g['theme']}/images/misc/loader.gif\' alt=\'loader\' /> " .gettext("loading...")."</a>"; |
|
226 |
|
|
227 |
switch ($alias_name['type']){ |
|
228 |
case "port": |
|
229 |
$width="250"; |
|
230 |
break; |
|
231 |
case "urltable": |
|
232 |
$width="500"; |
|
233 |
break; |
|
234 |
default: |
|
235 |
$width="350"; |
|
236 |
|
|
237 |
break; |
|
238 |
} |
|
239 |
$span_begin = "<span style=\"cursor: help;\" onmouseover=\"var response_html=domTT_activate(this, event, 'id','ttalias_{$alias_id}','content','{$loading_image}', 'trail', true, 'delay', 300, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','type','velcro','width',{$width});alias_popup('{$alias_id}','{$g['theme']}','".gettext('loading...')."');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><u>"; |
|
240 |
$span_end = "</u></span>"; |
|
241 |
|
|
242 |
if ($alias_name['name'] == $src) { |
|
243 |
$descriptions['src'] = $span_begin; |
|
244 |
$descriptions['src_end'] = $span_end; |
|
245 |
} |
|
246 |
|
|
247 |
if ($alias_name['name'] == $srcport) { |
|
248 |
$descriptions['srcport'] = $span_begin; |
|
249 |
$descriptions['srcport_end'] = $span_end; |
|
250 |
} |
|
251 |
|
|
252 |
if ($alias_name['name'] == $dst ) { |
|
253 |
$descriptions['dst'] = $span_begin; |
|
254 |
$descriptions['dst_end'] = $span_end; |
|
255 |
} |
|
256 |
|
|
257 |
if ($alias_name['name'] == $dstport) { |
|
258 |
$descriptions['dstport'] = $span_begin; |
|
259 |
$descriptions['dstport_end'] = $span_end; |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
return $descriptions; |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
212 | 267 |
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Outbound")); |
213 | 268 |
include("head.inc"); |
214 | 269 |
|
215 |
//FIXME This largely matches firewall_rules.php |
|
216 |
|
|
217 |
?> |
|
218 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
|
219 |
<?php include("fbegin.inc"); ?> |
|
220 |
<form action="firewall_nat_out.php" method="post" name="iform"> |
|
221 |
<script type="text/javascript" src="/javascript/row_toggle.js"></script> |
|
222 |
<?php |
|
223 | 270 |
if ($savemsg) |
224 |
print_info_box($savemsg); |
|
271 |
print_info_box($savemsg, 'success'); |
|
272 |
|
|
225 | 273 |
if (is_subsystem_dirty('natconf')) |
226 | 274 |
print_info_box_np(gettext("The NAT configuration has been changed.")."<br />".gettext("You must apply the changes in order for them to take effect.")); |
275 |
|
|
276 |
$tab_array = array(); |
|
277 |
$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php"); |
|
278 |
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php"); |
|
279 |
$tab_array[] = array(gettext("Outbound"), true, "firewall_nat_out.php"); |
|
280 |
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php"); |
|
281 |
display_top_tabs($tab_array); |
|
282 |
|
|
283 |
require('classes/Form.class.php'); |
|
284 |
|
|
285 |
$form = new Form(); |
|
286 |
|
|
287 |
$section = new Form_Section('General Logging Options'); |
|
288 |
|
|
289 |
$group = new Form_Group('Mode'); |
|
290 |
|
|
291 |
$group->add(new Form_Checkbox( |
|
292 |
'mode', |
|
293 |
'Mode', |
|
294 |
null, |
|
295 |
$mode == 'automatic', |
|
296 |
'automatic' |
|
297 |
))->displayAsRadio()->setHelp('Automatic outbound NAT rule generation.' . '<br />' . '(IPsec passthrough included)'); |
|
298 |
|
|
299 |
$group->add(new Form_Checkbox( |
|
300 |
'mode', |
|
301 |
null, |
|
302 |
null, |
|
303 |
$mode == 'hybrid', |
|
304 |
'hybrid' |
|
305 |
))->displayAsRadio()->setHelp('Hybrid Outbound NAT rule generation.' . '<br />' . '(Automatic Outbound NAT + rules below)'); |
|
306 |
|
|
307 |
$group->add(new Form_Checkbox( |
|
308 |
'mode', |
|
309 |
null, |
|
310 |
null, |
|
311 |
$mode == 'advanced', |
|
312 |
'advanced' |
|
313 |
))->displayAsRadio()->setHelp('Manual Outbound NAT rule generation.' . '<br />' . '(AON - Advanced Outbound NAT)'); |
|
314 |
|
|
315 |
$group->add(new Form_Checkbox( |
|
316 |
'mode', |
|
317 |
null, |
|
318 |
null, |
|
319 |
$mode == 'disabled', |
|
320 |
'disabled' |
|
321 |
))->displayAsRadio()->setHelp('Disable Outbound NAT rule generation.' . '<br />' . '(No Outbound NAT rules)'); |
|
322 |
|
|
323 |
$section->add($group); |
|
324 |
|
|
325 |
$form->add($section); |
|
326 |
print($form); |
|
227 | 327 |
?> |
228 |
<br /> |
|
229 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall nat outbound"> |
|
230 |
<tr><td> |
|
231 |
<?php |
|
232 |
$tab_array = array(); |
|
233 |
$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php"); |
|
234 |
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php"); |
|
235 |
$tab_array[] = array(gettext("Outbound"), true, "firewall_nat_out.php"); |
|
236 |
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php"); |
|
237 |
display_top_tabs($tab_array); |
|
238 |
?> |
|
239 |
</td></tr> |
|
240 |
<tr> |
|
241 |
<td> |
|
242 |
<div id="mainarea"> |
|
243 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> |
|
244 |
<tr> |
|
245 |
<td rowspan="3" align="right" valign="middle"><b><?=gettext("Mode:"); ?></b></td> |
|
246 |
<td> |
|
247 |
<input name="mode" type="radio" id="automatic" value="automatic" <?php if ($mode == "automatic") echo "checked=\"checked\"";?> /> |
|
248 |
</td> |
|
249 |
<td> |
|
250 |
<strong> |
|
251 |
<?=gettext("Automatic outbound NAT rule generation"); ?><br /> |
|
252 |
<?=gettext("(IPsec passthrough included)");?> |
|
253 |
</strong> |
|
254 |
</td> |
|
255 |
<td> |
|
256 |
<input name="mode" type="radio" id="hybrid" value="hybrid" <?php if ($mode == "hybrid") echo "checked=\"checked\"";?> /> |
|
257 |
</td> |
|
258 |
<td> |
|
259 |
<strong> |
|
260 |
<?=gettext("Hybrid Outbound NAT rule generation"); ?><br /> |
|
261 |
<?=gettext("(Automatic Outbound NAT + rules below)");?> |
|
262 |
</strong> |
|
263 |
</td> |
|
264 |
<td rowspan="3" valign="middle" align="left"> |
|
265 |
<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> |
|
266 |
</td> |
|
267 |
</tr> |
|
268 |
<tr> |
|
269 |
<td colspan="4"> |
|
270 |
|
|
271 |
</td> |
|
272 |
</tr> |
|
273 |
<tr> |
|
274 |
<td> |
|
275 |
<input name="mode" type="radio" id="advanced" value="advanced" <?php if ($mode == "advanced") echo "checked=\"checked\"";?> /> |
|
276 |
</td> |
|
277 |
<td> |
|
278 |
<strong> |
|
279 |
<?=gettext("Manual Outbound NAT rule generation"); ?><br /> |
|
280 |
<?=gettext("(AON - Advanced Outbound NAT)");?> |
|
281 |
</strong> |
|
282 |
</td> |
|
283 |
<td> |
|
284 |
<input name="mode" type="radio" id="disabled" value="disabled" <?php if ($mode == "disabled") echo "checked=\"checked\"";?> /> |
|
285 |
</td> |
|
286 |
<td> |
|
287 |
<strong> |
|
288 |
<?=gettext("Disable Outbound NAT rule generation"); ?><br /> |
|
289 |
<?=gettext("(No Outbound NAT rules)");?> |
|
290 |
</strong> |
|
291 |
</td> |
|
292 |
</tr> |
|
293 |
<tr> |
|
294 |
<td colspan="6"> |
|
295 |
|
|
296 |
</td> |
|
297 |
</tr> |
|
298 |
</table> |
|
299 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="mappings"> |
|
300 |
<tr><td colspan="5"><b> <?=gettext("Mappings:"); ?></b></td></tr> |
|
301 |
<tr><td> </td></tr> |
|
302 |
<tr id="frheader"> |
|
303 |
<td width="3%" class="list"> </td> |
|
304 |
<td width="3%" class="list"> </td> |
|
305 |
<td width="10%" class="listhdrr"><?=gettext("Interface");?></td> |
|
306 |
<td width="15%" class="listhdrr"><?=gettext("Source");?></td> |
|
307 |
<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td> |
|
308 |
<td width="15%" class="listhdrr"><?=gettext("Destination");?></td> |
|
309 |
<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td> |
|
310 |
<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td> |
|
311 |
<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td> |
|
312 |
<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td> |
|
313 |
<td width="25%" class="listhdr"><?=gettext("Description");?></td> |
|
314 |
<td width="5%" class="list"> |
|
315 |
<table border="0" cellspacing="0" cellpadding="1" summary="add"> |
|
316 |
<tr> |
|
317 |
<td width="17"></td> |
|
318 |
<td> |
|
319 |
<a href="firewall_nat_out_edit.php?after=-1"> |
|
320 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" /> |
|
321 |
</a> |
|
322 |
</td> |
|
323 |
</tr> |
|
324 |
</table> |
|
325 |
</td> |
|
326 |
</tr> |
|
328 |
<script> |
|
329 |
|
|
330 |
// Todo: Move script to external file ? |
|
331 |
// Check the checkbox, and change the background color when clicking on a row |
|
332 |
function fr_toggle(id, prefix) { |
|
333 |
|
|
334 |
if (!prefix) |
|
335 |
prefix = 'fr'; |
|
336 |
|
|
337 |
var checkbox = document.getElementById(prefix + 'c' + id); |
|
338 |
|
|
339 |
checkbox.checked = !checkbox.checked; |
|
340 |
fr_bgcolor(id, prefix); |
|
341 |
} |
|
342 |
|
|
343 |
function fr_bgcolor(id, prefix) { |
|
344 |
if (!prefix) |
|
345 |
prefix = 'fr'; |
|
346 |
|
|
347 |
var row = document.getElementById(prefix + id); |
|
348 |
var checkbox = document.getElementById(prefix + 'c' + id); |
|
349 |
var cells = row.getElementsByTagName('td'); |
|
350 |
var cellcnt = cells.length; |
|
351 |
|
|
352 |
for (i = 0; i < cellcnt; i++) |
|
353 |
cells[i].style.backgroundColor = checkbox.checked ? "#B9DEF0" : "#FFFFFF"; // #B9DEF0 = Bootstrap "info" |
|
354 |
} |
|
355 |
</script> |
|
356 |
|
|
357 |
<form action="firewall_nat_out.php" method="post" name="iform"> |
|
358 |
<div class="panel panel-default"> |
|
359 |
<div class="panel-heading"><?=gettext('Mappings')?></div> |
|
360 |
<div class="panel-body table-responsive"> |
|
361 |
<table class="table table-striped table-hover table-condensed"> |
|
362 |
<thead> |
|
363 |
<tr> |
|
364 |
<th><!-- checkbox --></th> |
|
365 |
<th><!-- status --></th> |
|
366 |
<th><?=gettext("Interface")?></th> |
|
367 |
<th><?=gettext("Source")?></th> |
|
368 |
<th><?=gettext("Source Port")?></th> |
|
369 |
<th><?=gettext("Destination")?></th> |
|
370 |
<th><?=gettext("Destination Port")?></th> |
|
371 |
<th><?=gettext("NAT Address")?></th> |
|
372 |
<th><?=gettext("NAT Port")?></th> |
|
373 |
<th><?=gettext("Static Port")?></th> |
|
374 |
<th><?=gettext("Description")?></th> |
|
375 |
<th><?=gettext("Actions")?></th> |
|
376 |
</tr> |
|
377 |
</thead> |
|
378 |
<tbody> |
|
327 | 379 |
<?php |
328 | 380 |
$i = 0; |
329 | 381 |
foreach ($a_out as $natent): |
330 | 382 |
$iconfn = "pass"; |
331 | 383 |
$textss = $textse = ""; |
332 |
if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) { |
|
333 |
$textss = "<span class=\"gray\">"; |
|
334 |
$textse = "</span>"; |
|
384 |
if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) |
|
335 | 385 |
$iconfn .= "_d"; |
336 |
} |
|
337 | 386 |
|
338 | 387 |
//build Alias popup box |
339 | 388 |
$alias_src_span_begin = ""; |
... | ... | |
353 | 402 |
$alias_dst_span_end = $alias_popup["dst_end"]; |
354 | 403 |
$alias_dst_port_span_end = $alias_popup["dstport_end"]; |
355 | 404 |
?> |
356 |
<tr valign="top" id="fr<?=$i;?>"> |
|
357 |
<td class="listt"> |
|
358 |
<input type="checkbox" id="frc<?=$i;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /> |
|
359 |
</td> |
|
360 |
<td class="listt" align="center"> |
|
405 |
<tr id="fr<?=$i?>"> |
|
406 |
<td> |
|
407 |
<input type="checkbox" id="frc<?=$i?>" name="rule[]" value="<?=$i?>" onclick="fr_bgcolor('<?=$i?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" /> |
|
408 |
</td> |
|
409 |
|
|
410 |
<td> |
|
361 | 411 |
<?php |
362 | 412 |
if ($mode == "disabled" || $mode == "automatic"): |
363 | 413 |
?> |
364 |
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0"
|
|
365 |
title="<?=gettext("This rule is being ignored");?>" alt="icon" />
|
|
414 |
<img src="/bootstrap/glyphicons/glyphicons-halflings.png" class="<?= ($iconfn == "pass") ? "icon-ok":"icon-remove"?>"
|
|
415 |
title="<?=gettext("Click to toggle enabled/disabled status")?>" alt="icon" />
|
|
366 | 416 |
<?php |
367 | 417 |
else: |
368 | 418 |
?> |
369 |
<a href="?act=toggle&id=<?=$i;?>"> |
|
370 |
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" |
|
371 |
title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" /> |
|
372 |
</a> |
|
419 |
<a href="?act=toggle&id=<?=$i?>"> |
|
420 |
<img src="/bootstrap/glyphicons/glyphicons-halflings.png" class="<?= ($iconfn == "pass") ? "icon-ok":"icon-remove"?>" |
|
421 |
title="<?=gettext("Click to toggle enabled/disabled status")?>" alt="icon" /> |
|
422 |
</a> |
|
423 |
|
|
373 | 424 |
<?php |
374 | 425 |
endif; |
375 | 426 |
?> |
376 |
</td> |
|
377 |
<td class="listlr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
378 |
<?php echo $textss . htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . $textse; ?> |
|
379 |
|
|
380 |
</td> |
|
381 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
382 |
<?PHP $natent['source']['network'] = ($natent['source']['network'] == "(self)") ? "This Firewall" : $natent['source']['network']; ?> |
|
383 |
<?php echo $textss . $alias_src_span_begin . $natent['source']['network'] . $alias_src_span_end . $textse;?> |
|
384 |
</td> |
|
385 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
427 |
</td> |
|
428 |
|
|
429 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
430 |
<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']))?> |
|
431 |
</td> |
|
432 |
|
|
433 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
434 |
<?php |
|
435 |
$natent['source']['network'] = ($natent['source']['network'] == "(self)") ? "This Firewall" : $natent['source']['network']; |
|
436 |
?> |
|
437 |
<?=$alias_src_span_begin . $natent['source']['network'] . $alias_src_span_end?> |
|
438 |
</td> |
|
439 |
|
|
440 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
386 | 441 |
<?php |
387 |
echo $textss; |
|
388 | 442 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; |
389 | 443 |
if (!$natent['sourceport']) |
390 | 444 |
echo "*"; |
391 | 445 |
else |
392 | 446 |
echo $alias_src_port_span_begin . $natent['sourceport'] . $alias_src_port_span_end; |
393 |
echo $textse; |
|
394 | 447 |
?> |
395 |
</td> |
|
396 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
448 |
</td> |
|
449 |
|
|
450 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
397 | 451 |
<?php |
398 |
echo $textss; |
|
399 | 452 |
if (isset($natent['destination']['any'])) |
400 | 453 |
echo "*"; |
401 | 454 |
else { |
... | ... | |
403 | 456 |
echo "! "; |
404 | 457 |
echo $alias_dst_span_begin . $natent['destination']['address'] . $alias_dst_span_end; |
405 | 458 |
} |
406 |
echo $textse; |
|
407 | 459 |
?> |
408 |
</td> |
|
409 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
460 |
</td> |
|
461 |
|
|
462 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
410 | 463 |
<?php |
411 |
echo $textss; |
|
412 | 464 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; |
465 |
|
|
413 | 466 |
if (!$natent['dstport']) |
414 | 467 |
echo "*"; |
415 | 468 |
else |
416 | 469 |
echo $alias_dst_port_span_begin . $natent['dstport'] . $alias_dst_port_span_end; |
417 |
echo $textse; |
|
418 | 470 |
?> |
419 |
</td> |
|
420 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
471 |
</td> |
|
472 |
|
|
473 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
421 | 474 |
<?php |
422 |
echo $textss; |
|
423 | 475 |
if (isset($natent['nonat'])) |
424 | 476 |
echo '<I>NO NAT</I>'; |
425 | 477 |
elseif (!$natent['target']) |
... | ... | |
428 | 480 |
echo $natent['targetip'] . '/' . $natent['targetip_subnet']; |
429 | 481 |
else |
430 | 482 |
echo $natent['target']; |
431 |
echo $textse; |
|
432 | 483 |
?> |
433 |
</td> |
|
434 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
484 |
</td> |
|
485 |
|
|
486 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
435 | 487 |
<?php |
436 |
echo $textss; |
|
437 | 488 |
if (!$natent['natport']) |
438 | 489 |
echo "*"; |
439 | 490 |
else |
440 | 491 |
echo $natent['natport']; |
441 |
echo $textse; |
|
442 | 492 |
?> |
443 |
</td> |
|
444 |
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';" align="center"> |
|
493 |
</td> |
|
494 |
|
|
495 |
<td onclick="fr_toggle(<?=$i?>)" id="frd<?=$i?>"> |
|
445 | 496 |
<?php |
446 |
echo $textss; |
|
447 | 497 |
if(isset($natent['staticnatport'])) |
448 | 498 |
echo gettext("YES"); |
449 | 499 |
else |
450 | 500 |
echo gettext("NO"); |
451 |
echo $textse; |
|
452 | 501 |
?> |
453 |
</td> |
|
454 |
<td class="listbg" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';"> |
|
455 |
<?=htmlspecialchars($natent['descr']);?> |
|
456 |
</td> |
|
457 |
<td class="list nowrap" valign="middle"> |
|
458 |
<table border="0" cellspacing="0" cellpadding="1" summary="move"> |
|
459 |
<tr> |
|
460 |
<td><input onmouseover="fr_insline(<?=$i;?>, true)" onmouseout="fr_insline(<?=$i;?>, false)" name="move_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" title="<?=gettext("move selected rules before this rule");?>" type="image" style="height:17;width:17;border:0" /></td> |
|
461 |
<td> |
|
462 |
<a href="firewall_nat_out_edit.php?id=<?=$i;?>"> |
|
463 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit mapping");?>" alt="edit" /> |
|
464 |
</a> |
|
465 |
</td> |
|
466 |
</tr> |
|
467 |
<tr> |
|
468 |
<td align="center" valign="middle"> |
|
469 |
<a href="firewall_nat_out.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this rule?");?>')"> |
|
470 |
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule");?>" alt="delete" /> |
|
471 |
</a> |
|
472 |
</td> |
|
473 |
<td> |
|
474 |
<a href="firewall_nat_out_edit.php?dup=<?=$i;?>"> |
|
475 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add a new NAT based on this one");?>" width="17" height="17" border="0" alt="duplicate" /> |
|
476 |
</a> |
|
477 |
</td> |
|
478 |
</tr> |
|
479 |
</table> |
|
480 |
</td> |
|
481 |
</tr> |
|
502 |
</td> |
|
503 |
|
|
504 |
<td onclick="fr_toggle(<?=$i?>)"> |
|
505 |
<?=htmlspecialchars($natent['descr'])?> |
|
506 |
</td> |
|
507 |
|
|
508 |
<!-- Action icons --> |
|
509 |
<td onclick="fr_toggle(<?=$nnats?>)" id="frd<?=$nnats?>"> |
|
510 |
<input name="move_<?=$i;?>" title="<?=gettext("Move selected mapping(s) before this rule");?>" src="/bootstrap/glyphicons/glyphicons-halflings.png" class="icon-eject" type="image" /> |
|
511 |
<a class="icon icon-pencil" title="<?=gettext("Edit mapping"); ?>" href="firewall_nat_out.php?id=<?=$i?>"></a> |
|
512 |
<a class="icon icon-remove-sign" title="<?=gettext("Delete mapping")?>" href="firewall_nat_out.php?act=del&id=<?=$i?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?")?>')"></a> |
|
513 |
<a class="icon icon-share-alt" title="<?=gettext("Add a new mapping based on this one")?>" href="firewall_nat_out_edit.php?dup=<?=$i?>"></a> |
|
514 |
</td> |
|
482 | 515 |
<?php |
483 | 516 |
$i++; |
484 | 517 |
endforeach; |
485 | 518 |
?> |
486 |
<tr valign="top" id="fr<?=$i;?>"> |
|
487 |
<td class="list" colspan="11"></td> |
|
488 |
<td class="list nowrap" valign="middle"> |
|
489 |
<table border="0" cellspacing="0" cellpadding="1" summary="edit"> |
|
490 |
<tr> |
|
491 |
<td> |
|
492 |
<?php |
|
493 |
if ($i == 0): |
|
494 |
?> |
|
495 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_left_d.gif" width="17" height="17" title="<?=gettext("move selected mappings to end");?>" border="0" alt="move" /> |
|
496 |
<?php |
|
497 |
else: |
|
498 |
?> |
|
499 |
<input onmouseover="fr_insline(<?=$i;?>, true)" onmouseout="fr_insline(<?=$i;?>, false)" name="move_<?=$i;?>" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_left.gif" style="width:17;height:17;border:0" title="<?=gettext("move selected mappings to end");?>" /> |
|
500 |
<?php |
|
501 |
endif; |
|
502 |
?> |
|
503 |
</td> |
|
504 |
<td> |
|
505 |
<a href="firewall_nat_out_edit.php"> |
|
506 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" /> |
|
507 |
</a> |
|
508 |
</td> |
|
509 |
</tr> |
|
510 |
<tr> |
|
511 |
<td> |
|
512 |
<?php |
|
513 |
if ($i == 0): |
|
514 |
?> |
|
515 |
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected rules");?>" border="0" alt="delete" /> |
|
519 |
</tr> |
|
520 |
</tbody> |
|
521 |
</table> |
|
522 |
</div> |
|
523 |
</div> |
|
524 |
|
|
525 |
<nav class="action-buttons"> |
|
526 |
<a href="firewall_nat_out_edit.php?after=-1" class="icon icon-plus-sign" title="<?=gettext('Add new mapping')?>"></a> |
|
516 | 527 |
<?php |
517 |
else:
|
|
528 |
if ($i > 0) {
|
|
518 | 529 |
?> |
519 |
<input name="del" type="image" src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" style="width:17;height:17" title="<?=gettext("delete selected mappings");?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected mappings?");?>')" /> |
|
530 |
<input name="move_<?=$i?>" type="image" src="/bootstrap/glyphicons/glyphicons-halflings.png" class="icon-fast-forward" title="<?=gettext("Move selected mappings to end")?>" /> |
|
531 |
<input name="del" type="image" src="/bootstrap/glyphicons/glyphicons-halflings.png" class="icon-remove-sign" title="<?=gettext("Delete selected mappings")?>" onclick="return confirm('<?=gettext("Do you really want to delete the selected mappings?")?>')" /> |
|
520 | 532 |
<?php |
521 |
endif;
|
|
533 |
}
|
|
522 | 534 |
?> |
523 |
</td> |
|
524 |
</tr> |
|
525 |
</table> |
|
526 |
</td> |
|
527 |
</tr> |
|
535 |
</nav> |
|
536 |
|
|
528 | 537 |
<?php |
529 |
if ($mode == "automatic" || $mode == "hybrid"): |
|
530 |
if(empty($FilterIflist)) |
|
531 |
filter_generate_optcfg_array(); |
|
532 |
if(empty($GatewaysList)) |
|
533 |
filter_generate_gateways(); |
|
534 |
$automatic_rules = filter_nat_rules_outbound_automatic(implode(" ", filter_nat_rules_automatic_tonathosts())); |
|
535 |
unset($FilterIflist, $GatewaysList); |
|
538 |
if ($mode == "automatic" || $mode == "hybrid"): |
|
539 |
if(empty($FilterIflist)) |
|
540 |
filter_generate_optcfg_array(); |
|
541 |
if(empty($GatewaysList)) |
|
542 |
filter_generate_gateways(); |
|
543 |
|
|
544 |
$automatic_rules = filter_nat_rules_outbound_automatic(implode(" ", filter_nat_rules_automatic_tonathosts())); |
|
545 |
unset($FilterIflist, $GatewaysList); |
|
536 | 546 |
?> |
537 |
<tr><td colspan="5"><b> <?=gettext("Automatic rules:"); ?></b></td></tr> |
|
538 |
<tr><td> </td></tr> |
|
539 |
<tr id="frheader"> |
|
540 |
<td width="3%" class="list"> </td> |
|
541 |
<td width="3%" class="list"> </td> |
|
542 |
<td width="10%" class="listhdrr"><?=gettext("Interface");?></td> |
|
543 |
<td width="15%" class="listhdrr"><?=gettext("Source");?></td> |
|
544 |
<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td> |
|
545 |
<td width="15%" class="listhdrr"><?=gettext("Destination");?></td> |
|
546 |
<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td> |
|
547 |
<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td> |
|
548 |
<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td> |
|
549 |
<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td> |
|
550 |
<td width="25%" class="listhdr"><?=gettext("Description");?></td> |
|
551 |
<td width="5%" class="list"> </td> |
|
552 |
</tr> |
|
547 |
<div class="panel panel-default"> |
|
548 |
<div class="panel-heading"><?=gettext("Automatic rules:")?></div> |
|
549 |
<div class="panel-body table-responsive"> |
|
550 |
<table class="table table-striped table-hover table-condensed"> |
|
551 |
<thead> |
|
552 |
<tr> |
|
553 |
<th><!-- status --></th> |
|
554 |
<th><?=gettext("Interface")?></th> |
|
555 |
<th><?=gettext("Source")?></th> |
|
556 |
<th><?=gettext("Source Port")?></th> |
|
557 |
<th><?=gettext("Destination")?></th> |
|
558 |
<th><?=gettext("Destination Port")?></th> |
|
559 |
<th><?=gettext("NAT Address")?></th> |
|
560 |
<th><?=gettext("NAT Port")?></th> |
|
561 |
<th><?=gettext("Static Port")?></th> |
|
562 |
<th><?=gettext("Description")?></th> |
|
563 |
|
|
564 |
</tr> |
|
553 | 565 |
<?php |
554 |
foreach ($automatic_rules as $natent):
|
|
566 |
foreach ($automatic_rules as $natent): |
|
555 | 567 |
?> |
556 |
<tr valign="top"> |
|
557 |
<td class="list"> </td> |
|
558 |
<td class="listt" align="center"> |
|
559 |
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0" title="<?=gettext("automatic outbound nat");?>" alt="icon" /> |
|
568 |
<tr> |
|
569 |
<td> |
|
570 |
<img src="/bootstrap/glyphicons/glyphicons-halflings.png" class="icon-ok" title="<?=gettext("automatic outbound nat")?>" alt="icon" /> |
|
560 | 571 |
</td> |
561 |
<td class="listlr" style="background-color: #E0E0E0"> |
|
562 |
<?php echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); ?> |
|
563 |
|
|
572 |
<td> |
|
573 |
<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); ?> |
|
564 | 574 |
</td> |
565 |
<td class="listr" style="background-color: #E0E0E0">
|
|
566 |
<?=$natent['source']['network'];?>
|
|
575 |
<td> |
|
576 |
<?=$natent['source']['network']?> |
|
567 | 577 |
</td> |
568 |
<td class="listr" style="background-color: #E0E0E0">
|
|
578 |
<td> |
|
569 | 579 |
<?php |
570 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; |
|
571 |
if (!$natent['sourceport']) |
|
572 |
echo "*"; |
|
573 |
else |
|
574 |
echo $natent['sourceport']; |
|
580 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; |
|
581 |
|
|
582 |
if (!$natent['sourceport']) |
|
583 |
echo "*"; |
|
584 |
else |
|
585 |
echo $natent['sourceport']; |
|
575 | 586 |
?> |
576 | 587 |
</td> |
577 |
<td class="listr" style="background-color: #E0E0E0">
|
|
588 |
<td> |
|
578 | 589 |
<?php |
579 |
if (isset($natent['destination']['any'])) |
|
580 |
echo "*"; |
|
581 |
else { |
|
582 |
if (isset($natent['destination']['not'])) |
|
583 |
echo "! "; |
|
584 |
echo $natent['destination']['address']; |
|
590 |
if (isset($natent['destination']['any'])) |
|
591 |
echo "*"; |
|
592 |
else { |
|
593 |
if (isset($natent['destination']['not'])) |
|
594 |
echo "! "; |
|
595 |
|
|
596 |
echo $natent['destination']['address']; |
|
585 | 597 |
} |
586 | 598 |
?> |
587 | 599 |
</td> |
588 |
<td class="listr" style="background-color: #E0E0E0">
|
|
600 |
<td> |
|
589 | 601 |
<?php |
590 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
|
|
591 |
if (!$natent['dstport'])
|
|
592 |
echo "*";
|
|
593 |
else
|
|
594 |
echo $natent['dstport'];
|
|
602 |
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ; |
|
603 |
if (!$natent['dstport']) |
|
604 |
echo "*"; |
|
605 |
else |
|
606 |
echo $natent['dstport']; |
|
595 | 607 |
?> |
596 | 608 |
</td> |
597 |
<td class="listr" style="background-color: #E0E0E0">
|
|
609 |
<td> |
|
598 | 610 |
<?php |
599 |
if (isset($natent['nonat']))
|
|
600 |
echo '<I>NO NAT</I>';
|
|
601 |
elseif (!$natent['target'])
|
|
602 |
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
|
|
603 |
elseif ($natent['target'] == "other-subnet")
|
|
604 |
echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
|
|
605 |
else
|
|
606 |
echo $natent['target'];
|
|
611 |
if (isset($natent['nonat'])) |
|
612 |
echo 'NO NAT';
|
|
613 |
elseif (!$natent['target']) |
|
614 |
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address"; |
|
615 |
elseif ($natent['target'] == "other-subnet") |
|
616 |
echo $natent['targetip'] . '/' . $natent['targetip_subnet']; |
|
617 |
else |
|
618 |
echo $natent['target']; |
|
607 | 619 |
?> |
608 | 620 |
</td> |
609 |
<td class="listr" style="background-color: #E0E0E0">
|
|
621 |
<td> |
|
610 | 622 |
<?php |
611 |
if (!$natent['natport'])
|
|
612 |
echo "*";
|
|
613 |
else
|
|
614 |
echo $natent['natport'];
|
|
623 |
if (!$natent['natport']) |
|
624 |
echo "*"; |
|
625 |
else |
|
626 |
echo $natent['natport']; |
|
615 | 627 |
?> |
616 | 628 |
</td> |
617 |
<td class="listr" style="background-color: #E0E0E0">
|
|
629 |
<td> |
|
618 | 630 |
<?php |
619 |
if(isset($natent['staticnatport']))
|
|
620 |
echo gettext("YES");
|
|
621 |
else
|
|
622 |
echo gettext("NO");
|
|
631 |
if(isset($natent['staticnatport'])) |
|
632 |
echo gettext("YES"); |
|
633 |
else |
|
634 |
echo gettext("NO"); |
|
623 | 635 |
?> |
624 | 636 |
</td> |
625 |
<td class="listbg">
|
|
626 |
<?=htmlspecialchars($natent['descr']);?>
|
|
637 |
<td> |
|
638 |
<?=htmlspecialchars($natent['descr'])?>
|
|
627 | 639 |
</td> |
628 |
<td class="list"> </td> |
|
629 | 640 |
</tr> |
630 | 641 |
<?php |
631 |
endforeach;
|
|
632 |
endif;
|
|
642 |
endforeach; |
|
643 |
endif; |
|
633 | 644 |
?> |
634 |
<tr> |
|
635 |
<td colspan="12"> |
|
636 |
<p><span class="vexpl"> |
|
637 |
<span class="red"><strong><?=gettext("Note:"); ?><br /></strong></span> |
|
638 |
<?=gettext("If automatic outbound NAT selected, a mapping is automatically created " . |
|
639 |
"for each interface's subnet (except WAN-type connections) and the rules " . |
|
640 |
"on \"Mappings\" section of this page are ignored.<br /><br /> " . |
|
641 |
"If manual outbound NAT is selected, outbound NAT rules will not be " . |
|
642 |
"automatically generated and only the mappings you specify on this page " . |
|
643 |
"will be used. <br /><br /> " . |
|
644 |
"If hybrid outbound NAT is selected, mappings you specify on this page will " . |
|
645 |
"be used, followed by the automatically generated ones. <br /><br />" . |
|
646 |
"If disable outbound NAT is selected, no rules will be used. <br /><br />" . |
|
647 |
"If a target address other than an interface's IP address is used, " . |
|
648 |
"then depending on the way the WAN connection is setup, a "); ?> |
|
649 |
<a href="firewall_virtual_ip.php"><?=gettext("Virtual IP"); ?></a> |
|
650 |
<?= gettext(" may also be required.") ?> |
|
651 |
</span></p> |
|
652 |
</td> |
|
653 |
</tr> |
|
645 |
</tbody> |
|
654 | 646 |
</table> |
655 |
</div> |
|
656 |
</td> |
|
657 |
</tr> |
|
658 |
</table> |
|
647 |
</div> |
|
648 |
</div> |
|
659 | 649 |
</form> |
660 |
<?php include("fend.inc"); ?> |
|
661 |
</body> |
|
662 |
</html> |
|
650 |
|
|
651 |
<div> |
|
652 |
<?php |
|
653 |
print_info_box(gettext('If automatic outbound NAT selected, a mapping is automatically generated for each interface\'s subnet (except WAN-type connections) and the rules ' . |
|
654 |
'on "Mappings" section of this page are ignored.' . '<br />' . |
|
655 |
'If manual outbound NAT is selected, outbound NAT rules will not be automatically generated and only the mappings you specify on this page ' . |
|
656 |
'will be used.' . '<br />' . |
|
657 |
'If hybrid outbound NAT is selected, mappings you specify on this page will be used, followed by the automatically generated ones.' . '<br />' . |
|
658 |
'If disable outbound NAT is selected, no rules will be used.' . '<br />' . |
|
659 |
'If a target address other than an interface\'s IP address is used, then depending on the way the WAN connection is setup, a ') . |
|
660 |
'<a href="firewall_virtual_ip.php">' . gettext("Virtual IP") . '</a>' . gettext(" may also be required.") |
|
661 |
); |
|
662 |
?> |
|
663 |
</div> |
|
664 |
|
|
665 |
<?php include("foot.inc"); |
Also available in: Unified diff
firewall_nat_out Conversion complete
Ready for review