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