1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
firewall_nat_out.php
|
5
|
Copyright (C) 2004 Scott Ullrich
|
6
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7
|
All rights reserved.
|
8
|
|
9
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
10
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
All rights reserved.
|
12
|
|
13
|
Redistribution and use in source and binary forms, with or without
|
14
|
modification, are permitted provided that the following conditions are met:
|
15
|
|
16
|
1. Redistributions of source code must retain the above copyright notice,
|
17
|
this list of conditions and the following disclaimer.
|
18
|
|
19
|
2. Redistributions in binary form must reproduce the above copyright
|
20
|
notice, this list of conditions and the following disclaimer in the
|
21
|
documentation and/or other materials provided with the distribution.
|
22
|
|
23
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
24
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
25
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
26
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
27
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
POSSIBILITY OF SUCH DAMAGE.
|
33
|
*/
|
34
|
/*
|
35
|
pfSense_MODULE: nat
|
36
|
*/
|
37
|
|
38
|
##|+PRIV
|
39
|
##|*IDENT=page-firewall-nat-outbound
|
40
|
##|*NAME=Firewall: NAT: Outbound page
|
41
|
##|*DESCR=Allow access to the 'Firewall: NAT: Outbound' page.
|
42
|
##|*MATCH=firewall_nat_out.php*
|
43
|
##|-PRIV
|
44
|
|
45
|
require("guiconfig.inc");
|
46
|
require_once("functions.inc");
|
47
|
require_once("filter.inc");
|
48
|
require_once("shaper.inc");
|
49
|
|
50
|
global $FilterIflist;
|
51
|
global $GatewaysList;
|
52
|
|
53
|
if (!is_array($config['nat']['outbound'])) {
|
54
|
$config['nat']['outbound'] = array();
|
55
|
}
|
56
|
|
57
|
if (!is_array($config['nat']['outbound']['rule'])) {
|
58
|
$config['nat']['outbound']['rule'] = array();
|
59
|
}
|
60
|
|
61
|
$a_out = &$config['nat']['outbound']['rule'];
|
62
|
|
63
|
if (!isset($config['nat']['outbound']['mode'])) {
|
64
|
$config['nat']['outbound']['mode'] = "automatic";
|
65
|
}
|
66
|
|
67
|
$mode = $config['nat']['outbound']['mode'];
|
68
|
|
69
|
if ($_POST['apply']) {
|
70
|
$retval = 0;
|
71
|
$retval |= filter_configure();
|
72
|
|
73
|
if (stristr($retval, "error") <> true) {
|
74
|
$savemsg = get_std_save_message($retval);
|
75
|
} else {
|
76
|
$savemsg = $retval;
|
77
|
}
|
78
|
|
79
|
if ($retval == 0) {
|
80
|
clear_subsystem_dirty('natconf');
|
81
|
clear_subsystem_dirty('filter');
|
82
|
}
|
83
|
}
|
84
|
|
85
|
if (isset($_POST['save']) && $_POST['save'] == "Save") {
|
86
|
/* mutually exclusive settings - if user wants advanced NAT, we don't generate automatic rules */
|
87
|
if ($_POST['mode'] == "advanced" && ($mode == "automatic" || $mode == "hybrid")) {
|
88
|
/*
|
89
|
* user has enabled advanced outbound NAT and doesn't have rules
|
90
|
* lets automatically create entries
|
91
|
* for all of the interfaces to make life easier on the pip-o-chap
|
92
|
*/
|
93
|
if (empty($FilterIflist)) {
|
94
|
filter_generate_optcfg_array();
|
95
|
}
|
96
|
if (empty($GatewaysList)) {
|
97
|
filter_generate_gateways();
|
98
|
}
|
99
|
$tonathosts = filter_nat_rules_automatic_tonathosts(true);
|
100
|
$automatic_rules = filter_nat_rules_outbound_automatic("");
|
101
|
|
102
|
foreach ($tonathosts as $tonathost) {
|
103
|
foreach ($automatic_rules as $natent) {
|
104
|
$natent['source']['network'] = $tonathost['subnet'];
|
105
|
$natent['descr'] .= sprintf(gettext(' - %1$s to %2$s'),
|
106
|
$tonathost['descr'],
|
107
|
convert_real_interface_to_friendly_descr($natent['interface']));
|
108
|
$natent['created'] = make_config_revision_entry(null, gettext("Manual Outbound NAT Switch"));
|
109
|
|
110
|
/* Try to detect already auto created rules and avoid duplicating them */
|
111
|
$found = false;
|
112
|
foreach ($a_out as $rule) {
|
113
|
if ($rule['interface'] == $natent['interface'] &&
|
114
|
$rule['source']['network'] == $natent['source']['network'] &&
|
115
|
$rule['dstport'] == $natent['dstport'] &&
|
116
|
$rule['target'] == $natent['target'] &&
|
117
|
$rule['descr'] == $natent['descr']) {
|
118
|
$found = true;
|
119
|
break;
|
120
|
}
|
121
|
}
|
122
|
|
123
|
if ($found === false) {
|
124
|
$a_out[] = $natent;
|
125
|
}
|
126
|
}
|
127
|
}
|
128
|
$savemsg = gettext("Default rules for each interface have been created.");
|
129
|
unset($FilterIflist, $GatewaysList);
|
130
|
}
|
131
|
|
132
|
$config['nat']['outbound']['mode'] = $_POST['mode'];
|
133
|
|
134
|
if (write_config()) {
|
135
|
mark_subsystem_dirty('natconf');
|
136
|
}
|
137
|
header("Location: firewall_nat_out.php");
|
138
|
exit;
|
139
|
}
|
140
|
|
141
|
if ($_GET['act'] == "del") {
|
142
|
if ($a_out[$_GET['id']]) {
|
143
|
unset($a_out[$_GET['id']]);
|
144
|
if (write_config()) {
|
145
|
mark_subsystem_dirty('natconf');
|
146
|
}
|
147
|
header("Location: firewall_nat_out.php");
|
148
|
exit;
|
149
|
}
|
150
|
}
|
151
|
|
152
|
if (isset($_POST['del_x'])) {
|
153
|
/* delete selected rules */
|
154
|
if (is_array($_POST['rule']) && count($_POST['rule'])) {
|
155
|
foreach ($_POST['rule'] as $rulei) {
|
156
|
unset($a_out[$rulei]);
|
157
|
}
|
158
|
if (write_config()) {
|
159
|
mark_subsystem_dirty('natconf');
|
160
|
}
|
161
|
header("Location: firewall_nat_out.php");
|
162
|
exit;
|
163
|
}
|
164
|
|
165
|
} else if ($_GET['act'] == "toggle") {
|
166
|
if ($a_out[$_GET['id']]) {
|
167
|
if (isset($a_out[$_GET['id']]['disabled'])) {
|
168
|
unset($a_out[$_GET['id']]['disabled']);
|
169
|
} else {
|
170
|
$a_out[$_GET['id']]['disabled'] = true;
|
171
|
}
|
172
|
if (write_config("Firewall: NAT: Outbound, enable/disable NAT rule")) {
|
173
|
mark_subsystem_dirty('natconf');
|
174
|
}
|
175
|
header("Location: firewall_nat_out.php");
|
176
|
exit;
|
177
|
}
|
178
|
} else {
|
179
|
/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
|
180
|
unset($movebtn);
|
181
|
foreach ($_POST as $pn => $pd) {
|
182
|
if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
|
183
|
$movebtn = $matches[1];
|
184
|
break;
|
185
|
}
|
186
|
}
|
187
|
/* move selected rules before this rule */
|
188
|
if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
|
189
|
$a_out_new = array();
|
190
|
|
191
|
/* copy all rules < $movebtn and not selected */
|
192
|
for ($i = 0; $i < $movebtn; $i++) {
|
193
|
if (!in_array($i, $_POST['rule'])) {
|
194
|
$a_out_new[] = $a_out[$i];
|
195
|
}
|
196
|
}
|
197
|
|
198
|
/* copy all selected rules */
|
199
|
for ($i = 0; $i < count($a_out); $i++) {
|
200
|
if ($i == $movebtn) {
|
201
|
continue;
|
202
|
}
|
203
|
if (in_array($i, $_POST['rule'])) {
|
204
|
$a_out_new[] = $a_out[$i];
|
205
|
}
|
206
|
}
|
207
|
|
208
|
/* copy $movebtn rule */
|
209
|
if ($movebtn < count($a_out)) {
|
210
|
$a_out_new[] = $a_out[$movebtn];
|
211
|
}
|
212
|
|
213
|
/* copy all rules > $movebtn and not selected */
|
214
|
for ($i = $movebtn+1; $i < count($a_out); $i++) {
|
215
|
if (!in_array($i, $_POST['rule'])) {
|
216
|
$a_out_new[] = $a_out[$i];
|
217
|
}
|
218
|
}
|
219
|
if (count($a_out_new) > 0) {
|
220
|
$a_out = $a_out_new;
|
221
|
}
|
222
|
|
223
|
if (write_config()) {
|
224
|
mark_subsystem_dirty('natconf');
|
225
|
}
|
226
|
header("Location: firewall_nat_out.php");
|
227
|
exit;
|
228
|
}
|
229
|
}
|
230
|
|
231
|
$pgtitle = array(gettext("Firewall"), gettext("NAT"), gettext("Outbound"));
|
232
|
include("head.inc");
|
233
|
|
234
|
?>
|
235
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
236
|
<?php include("fbegin.inc"); ?>
|
237
|
<form action="firewall_nat_out.php" method="post" name="iform">
|
238
|
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
|
239
|
<?php
|
240
|
if ($savemsg) {
|
241
|
print_info_box($savemsg);
|
242
|
}
|
243
|
if (is_subsystem_dirty('natconf')) {
|
244
|
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."));
|
245
|
}
|
246
|
?>
|
247
|
<br />
|
248
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall nat outbound">
|
249
|
<tr><td>
|
250
|
<?php
|
251
|
$tab_array = array();
|
252
|
$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php");
|
253
|
$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
|
254
|
$tab_array[] = array(gettext("Outbound"), true, "firewall_nat_out.php");
|
255
|
$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
|
256
|
display_top_tabs($tab_array);
|
257
|
?>
|
258
|
</td></tr>
|
259
|
<tr>
|
260
|
<td>
|
261
|
<div id="mainarea">
|
262
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
263
|
<tr>
|
264
|
<td rowspan="3" align="right" valign="middle"><b><?=gettext("Mode:"); ?></b></td>
|
265
|
<td>
|
266
|
<input name="mode" type="radio" id="automatic" value="automatic" <?php if ($mode == "automatic") echo "checked=\"checked\"";?> />
|
267
|
</td>
|
268
|
<td>
|
269
|
<strong>
|
270
|
<?=gettext("Automatic outbound NAT rule generation"); ?><br />
|
271
|
<?=gettext("(IPsec passthrough included)");?>
|
272
|
</strong>
|
273
|
</td>
|
274
|
<td>
|
275
|
<input name="mode" type="radio" id="hybrid" value="hybrid" <?php if ($mode == "hybrid") echo "checked=\"checked\"";?> />
|
276
|
</td>
|
277
|
<td>
|
278
|
<strong>
|
279
|
<?=gettext("Hybrid Outbound NAT rule generation"); ?><br />
|
280
|
<?=gettext("(Automatic Outbound NAT + rules below)");?>
|
281
|
</strong>
|
282
|
</td>
|
283
|
<td rowspan="3" valign="middle" align="left">
|
284
|
<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
|
285
|
</td>
|
286
|
</tr>
|
287
|
<tr>
|
288
|
<td colspan="4">
|
289
|
|
290
|
</td>
|
291
|
</tr>
|
292
|
<tr>
|
293
|
<td>
|
294
|
<input name="mode" type="radio" id="advanced" value="advanced" <?php if ($mode == "advanced") echo "checked=\"checked\"";?> />
|
295
|
</td>
|
296
|
<td>
|
297
|
<strong>
|
298
|
<?=gettext("Manual Outbound NAT rule generation"); ?><br />
|
299
|
<?=gettext("(AON - Advanced Outbound NAT)");?>
|
300
|
</strong>
|
301
|
</td>
|
302
|
<td>
|
303
|
<input name="mode" type="radio" id="disabled" value="disabled" <?php if ($mode == "disabled") echo "checked=\"checked\"";?> />
|
304
|
</td>
|
305
|
<td>
|
306
|
<strong>
|
307
|
<?=gettext("Disable Outbound NAT rule generation"); ?><br />
|
308
|
<?=gettext("(No Outbound NAT rules)");?>
|
309
|
</strong>
|
310
|
</td>
|
311
|
</tr>
|
312
|
<tr>
|
313
|
<td colspan="6">
|
314
|
|
315
|
</td>
|
316
|
</tr>
|
317
|
</table>
|
318
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="mappings">
|
319
|
<tr><td colspan="5"><b> <?=gettext("Mappings:"); ?></b></td></tr>
|
320
|
<tr><td> </td></tr>
|
321
|
<tr id="frheader">
|
322
|
<td width="3%" class="list"> </td>
|
323
|
<td width="3%" class="list"> </td>
|
324
|
<td width="10%" class="listhdrr"><?=gettext("Interface");?></td>
|
325
|
<td width="15%" class="listhdrr"><?=gettext("Source");?></td>
|
326
|
<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td>
|
327
|
<td width="15%" class="listhdrr"><?=gettext("Destination");?></td>
|
328
|
<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td>
|
329
|
<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td>
|
330
|
<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td>
|
331
|
<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td>
|
332
|
<td width="25%" class="listhdr"><?=gettext("Description");?></td>
|
333
|
<td width="5%" class="list">
|
334
|
<table border="0" cellspacing="0" cellpadding="1" summary="add">
|
335
|
<tr>
|
336
|
<td width="17"></td>
|
337
|
<td>
|
338
|
<a href="firewall_nat_out_edit.php?after=-1">
|
339
|
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" />
|
340
|
</a>
|
341
|
</td>
|
342
|
</tr>
|
343
|
</table>
|
344
|
</td>
|
345
|
</tr>
|
346
|
<?php
|
347
|
$i = 0;
|
348
|
foreach ($a_out as $natent):
|
349
|
$iconfn = "pass";
|
350
|
$textss = $textse = "";
|
351
|
if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) {
|
352
|
$textss = "<span class=\"gray\">";
|
353
|
$textse = "</span>";
|
354
|
$iconfn .= "_d";
|
355
|
}
|
356
|
|
357
|
//build Alias popup box
|
358
|
$alias_src_span_begin = "";
|
359
|
$alias_src_port_span_begin = "";
|
360
|
$alias_dst_span_begin = "";
|
361
|
$alias_dst_port_span_begin = "";
|
362
|
|
363
|
$alias_popup = rule_popup($natent['source']['network'], pprint_port($natent['sourceport']), $natent['destination']['address'], pprint_port($natent['dstport']));
|
364
|
|
365
|
$alias_src_span_begin = $alias_popup["src"];
|
366
|
$alias_src_port_span_begin = $alias_popup["srcport"];
|
367
|
$alias_dst_span_begin = $alias_popup["dst"];
|
368
|
$alias_dst_port_span_begin = $alias_popup["dstport"];
|
369
|
|
370
|
$alias_src_span_end = $alias_popup["src_end"];
|
371
|
$alias_src_port_span_end = $alias_popup["srcport_end"];
|
372
|
$alias_dst_span_end = $alias_popup["dst_end"];
|
373
|
$alias_dst_port_span_end = $alias_popup["dstport_end"];
|
374
|
?>
|
375
|
<tr valign="top" id="fr<?=$i;?>">
|
376
|
<td class="listt">
|
377
|
<input type="checkbox" id="frc<?=$i;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
|
378
|
</td>
|
379
|
<td class="listt" align="center">
|
380
|
<?php
|
381
|
if ($mode == "disabled" || $mode == "automatic"):
|
382
|
?>
|
383
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0"
|
384
|
title="<?=gettext("This rule is being ignored");?>" alt="icon" />
|
385
|
<?php
|
386
|
else:
|
387
|
?>
|
388
|
<a href="?act=toggle&id=<?=$i;?>">
|
389
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0"
|
390
|
title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" />
|
391
|
</a>
|
392
|
<?php
|
393
|
endif;
|
394
|
?>
|
395
|
</td>
|
396
|
<td class="listlr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
397
|
<?php echo $textss . htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . $textse; ?>
|
398
|
|
399
|
</td>
|
400
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
401
|
<?php $natent['source']['network'] = ($natent['source']['network'] == "(self)") ? "This Firewall" : $natent['source']['network']; ?>
|
402
|
<?php echo $textss . $alias_src_span_begin . $natent['source']['network'] . $alias_src_span_end . $textse;?>
|
403
|
</td>
|
404
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
405
|
<?php
|
406
|
echo $textss;
|
407
|
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
|
408
|
if (!$natent['sourceport']) {
|
409
|
echo "*";
|
410
|
} else {
|
411
|
echo $alias_src_port_span_begin . $natent['sourceport'] . $alias_src_port_span_end;
|
412
|
}
|
413
|
echo $textse;
|
414
|
?>
|
415
|
</td>
|
416
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
417
|
<?php
|
418
|
echo $textss;
|
419
|
if (isset($natent['destination']['any'])) {
|
420
|
echo "*";
|
421
|
} else {
|
422
|
if (isset($natent['destination']['not'])) {
|
423
|
echo "! ";
|
424
|
}
|
425
|
echo $alias_dst_span_begin . $natent['destination']['address'] . $alias_dst_span_end;
|
426
|
}
|
427
|
echo $textse;
|
428
|
?>
|
429
|
</td>
|
430
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
431
|
<?php
|
432
|
echo $textss;
|
433
|
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
|
434
|
if (!$natent['dstport']) {
|
435
|
echo "*";
|
436
|
} else {
|
437
|
echo $alias_dst_port_span_begin . $natent['dstport'] . $alias_dst_port_span_end;
|
438
|
}
|
439
|
echo $textse;
|
440
|
?>
|
441
|
</td>
|
442
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
443
|
<?php
|
444
|
echo $textss;
|
445
|
if (isset($natent['nonat'])) {
|
446
|
echo '<I>NO NAT</I>';
|
447
|
} elseif (!$natent['target']) {
|
448
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
|
449
|
} elseif ($natent['target'] == "other-subnet") {
|
450
|
echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
|
451
|
} else {
|
452
|
echo $natent['target'];
|
453
|
}
|
454
|
echo $textse;
|
455
|
?>
|
456
|
</td>
|
457
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
458
|
<?php
|
459
|
echo $textss;
|
460
|
if (!$natent['natport']) {
|
461
|
echo "*";
|
462
|
} else {
|
463
|
echo $natent['natport'];
|
464
|
}
|
465
|
echo $textse;
|
466
|
?>
|
467
|
</td>
|
468
|
<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';" align="center">
|
469
|
<?php
|
470
|
echo $textss;
|
471
|
if (isset($natent['staticnatport'])) {
|
472
|
echo gettext("YES");
|
473
|
} else {
|
474
|
echo gettext("NO");
|
475
|
}
|
476
|
echo $textse;
|
477
|
?>
|
478
|
</td>
|
479
|
<td class="listbg" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
|
480
|
<?=htmlspecialchars($natent['descr']);?>
|
481
|
</td>
|
482
|
<td class="list nowrap" valign="middle">
|
483
|
<table border="0" cellspacing="0" cellpadding="1" summary="move">
|
484
|
<tr>
|
485
|
<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>
|
486
|
<td>
|
487
|
<a href="firewall_nat_out_edit.php?id=<?=$i;?>">
|
488
|
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit mapping");?>" alt="edit" />
|
489
|
</a>
|
490
|
</td>
|
491
|
</tr>
|
492
|
<tr>
|
493
|
<td align="center" valign="middle">
|
494
|
<a href="firewall_nat_out.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this rule?");?>')">
|
495
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule");?>" alt="delete" />
|
496
|
</a>
|
497
|
</td>
|
498
|
<td>
|
499
|
<a href="firewall_nat_out_edit.php?dup=<?=$i;?>">
|
500
|
<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" />
|
501
|
</a>
|
502
|
</td>
|
503
|
</tr>
|
504
|
</table>
|
505
|
</td>
|
506
|
</tr>
|
507
|
<?php
|
508
|
$i++;
|
509
|
endforeach;
|
510
|
?>
|
511
|
<tr valign="top" id="fr<?=$i;?>">
|
512
|
<td class="list" colspan="11"></td>
|
513
|
<td class="list nowrap" valign="middle">
|
514
|
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
|
515
|
<tr>
|
516
|
<td>
|
517
|
<?php
|
518
|
if ($i == 0):
|
519
|
?>
|
520
|
<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" />
|
521
|
<?php
|
522
|
else:
|
523
|
?>
|
524
|
<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");?>" />
|
525
|
<?php
|
526
|
endif;
|
527
|
?>
|
528
|
</td>
|
529
|
<td>
|
530
|
<a href="firewall_nat_out_edit.php">
|
531
|
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" />
|
532
|
</a>
|
533
|
</td>
|
534
|
</tr>
|
535
|
<tr>
|
536
|
<td>
|
537
|
<?php
|
538
|
if ($i == 0):
|
539
|
?>
|
540
|
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected rules");?>" border="0" alt="delete" />
|
541
|
<?php
|
542
|
else:
|
543
|
?>
|
544
|
<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?");?>')" />
|
545
|
<?php
|
546
|
endif;
|
547
|
?>
|
548
|
</td>
|
549
|
</tr>
|
550
|
</table>
|
551
|
</td>
|
552
|
</tr>
|
553
|
<?php
|
554
|
if ($mode == "automatic" || $mode == "hybrid"):
|
555
|
if (empty($FilterIflist)) {
|
556
|
filter_generate_optcfg_array();
|
557
|
}
|
558
|
if (empty($GatewaysList)) {
|
559
|
filter_generate_gateways();
|
560
|
}
|
561
|
$automatic_rules = filter_nat_rules_outbound_automatic(implode(" ", filter_nat_rules_automatic_tonathosts()));
|
562
|
unset($FilterIflist, $GatewaysList);
|
563
|
?>
|
564
|
<tr><td colspan="5"><b> <?=gettext("Automatic rules:"); ?></b></td></tr>
|
565
|
<tr><td> </td></tr>
|
566
|
<tr id="frheader">
|
567
|
<td width="3%" class="list"> </td>
|
568
|
<td width="3%" class="list"> </td>
|
569
|
<td width="10%" class="listhdrr"><?=gettext("Interface");?></td>
|
570
|
<td width="15%" class="listhdrr"><?=gettext("Source");?></td>
|
571
|
<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td>
|
572
|
<td width="15%" class="listhdrr"><?=gettext("Destination");?></td>
|
573
|
<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td>
|
574
|
<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td>
|
575
|
<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td>
|
576
|
<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td>
|
577
|
<td width="25%" class="listhdr"><?=gettext("Description");?></td>
|
578
|
<td width="5%" class="list"> </td>
|
579
|
</tr>
|
580
|
<?php
|
581
|
foreach ($automatic_rules as $natent):
|
582
|
?>
|
583
|
<tr valign="top">
|
584
|
<td class="list"> </td>
|
585
|
<td class="listt" align="center">
|
586
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0" title="<?=gettext("automatic outbound nat");?>" alt="icon" />
|
587
|
</td>
|
588
|
<td class="listlr" style="background-color: #E0E0E0">
|
589
|
<?php echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); ?>
|
590
|
|
591
|
</td>
|
592
|
<td class="listr" style="background-color: #E0E0E0">
|
593
|
<?=$natent['source']['network'];?>
|
594
|
</td>
|
595
|
<td class="listr" style="background-color: #E0E0E0">
|
596
|
<?php
|
597
|
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
|
598
|
if (!$natent['sourceport']) {
|
599
|
echo "*";
|
600
|
} else {
|
601
|
echo $natent['sourceport'];
|
602
|
}
|
603
|
?>
|
604
|
</td>
|
605
|
<td class="listr" style="background-color: #E0E0E0">
|
606
|
<?php
|
607
|
if (isset($natent['destination']['any'])) {
|
608
|
echo "*";
|
609
|
} else {
|
610
|
if (isset($natent['destination']['not'])) {
|
611
|
echo "! ";
|
612
|
}
|
613
|
echo $natent['destination']['address'];
|
614
|
}
|
615
|
?>
|
616
|
</td>
|
617
|
<td class="listr" style="background-color: #E0E0E0">
|
618
|
<?php
|
619
|
echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
|
620
|
if (!$natent['dstport']) {
|
621
|
echo "*";
|
622
|
} else {
|
623
|
echo $natent['dstport'];
|
624
|
}
|
625
|
?>
|
626
|
</td>
|
627
|
<td class="listr" style="background-color: #E0E0E0">
|
628
|
<?php
|
629
|
if (isset($natent['nonat'])) {
|
630
|
echo '<I>NO NAT</I>';
|
631
|
} elseif (!$natent['target']) {
|
632
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
|
633
|
} elseif ($natent['target'] == "other-subnet") {
|
634
|
echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
|
635
|
} else {
|
636
|
echo $natent['target'];
|
637
|
}
|
638
|
?>
|
639
|
</td>
|
640
|
<td class="listr" style="background-color: #E0E0E0">
|
641
|
<?php
|
642
|
if (!$natent['natport']) {
|
643
|
echo "*";
|
644
|
} else {
|
645
|
echo $natent['natport'];
|
646
|
}
|
647
|
?>
|
648
|
</td>
|
649
|
<td class="listr" style="background-color: #E0E0E0">
|
650
|
<?php
|
651
|
if (isset($natent['staticnatport'])) {
|
652
|
echo gettext("YES");
|
653
|
} else {
|
654
|
echo gettext("NO");
|
655
|
}
|
656
|
?>
|
657
|
</td>
|
658
|
<td class="listbg">
|
659
|
<?=htmlspecialchars($natent['descr']);?>
|
660
|
</td>
|
661
|
<td class="list"> </td>
|
662
|
</tr>
|
663
|
<?php
|
664
|
endforeach;
|
665
|
endif;
|
666
|
?>
|
667
|
<tr>
|
668
|
<td colspan="12">
|
669
|
<p><span class="vexpl">
|
670
|
<span class="red"><strong><?=gettext("Note:"); ?><br /></strong></span>
|
671
|
<?=gettext("If automatic outbound NAT selected, a mapping is automatically created " .
|
672
|
"for each interface's subnet (except WAN-type connections) and the rules " .
|
673
|
"on \"Mappings\" section of this page are ignored.<br /><br /> " .
|
674
|
"If manual outbound NAT is selected, outbound NAT rules will not be " .
|
675
|
"automatically generated and only the mappings you specify on this page " .
|
676
|
"will be used. <br /><br /> " .
|
677
|
"If hybrid outbound NAT is selected, mappings you specify on this page will " .
|
678
|
"be used, followed by the automatically generated ones. <br /><br />" .
|
679
|
"If disable outbound NAT is selected, no rules will be used. <br /><br />" .
|
680
|
"If a target address other than an interface's IP address is used, " .
|
681
|
"then depending on the way the WAN connection is setup, a "); ?>
|
682
|
<a href="firewall_virtual_ip.php"><?=gettext("Virtual IP"); ?></a>
|
683
|
<?= gettext(" may also be required.") ?>
|
684
|
</span></p>
|
685
|
</td>
|
686
|
</tr>
|
687
|
</table>
|
688
|
</div>
|
689
|
</td>
|
690
|
</tr>
|
691
|
</table>
|
692
|
</form>
|
693
|
<?php include("fend.inc"); ?>
|
694
|
</body>
|
695
|
</html>
|