Project

General

Profile

Download (23.7 KB) Statistics
| Branch: | Tag: | Revision:
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
if (!is_array($config['nat']['outbound']['rule']))
57
	$config['nat']['outbound']['rule'] = array();
58

    
59
$a_out = &$config['nat']['outbound']['rule'];
60

    
61
if (!isset($config['nat']['outbound']['mode']))
62
	$config['nat']['outbound']['mode'] = "automatic";
63

    
64
$mode = $config['nat']['outbound']['mode'];
65

    
66
if ($_POST['apply']) {
67
	$retval = 0;
68
	$retval |= filter_configure();
69

    
70
	if(stristr($retval, "error") <> true)
71
	        $savemsg = get_std_save_message($retval);
72
	else
73
		$savemsg = $retval;
74

    
75
	if ($retval == 0) {
76
		clear_subsystem_dirty('natconf');
77
		clear_subsystem_dirty('filter');
78
	}
79
}
80

    
81
if (isset($_POST['save']) && $_POST['save'] == "Save") {
82
	/* mutually exclusive settings - if user wants advanced NAT, we don't generate automatic rules */
83
	if ($_POST['mode'] == "advanced" && ($mode == "automatic" || $mode == "hybrid")) {
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
88
		 */
89
		if(empty($FilterIflist))
90
			filter_generate_optcfg_array();
91
		if(empty($GatewaysList))
92
			filter_generate_gateways();
93
		$tonathosts = filter_nat_rules_automatic_tonathosts(true);
94
		$automatic_rules = filter_nat_rules_outbound_automatic("");
95

    
96
		foreach ($tonathosts as $tonathost) {
97
			foreach ($automatic_rules as $natent) {
98
				$natent['source']['network'] = $tonathost['subnet'];
99
				$natent['descr'] .= sprintf(gettext(' - %1$s to %2$s'),
100
					$tonathost['descr'],
101
					convert_real_interface_to_friendly_descr($natent['interface']));
102
				$natent['created'] = make_config_revision_entry(null, gettext("Manual Outbound NAT Switch"));
103

    
104
				/* Try to detect already auto created rules and avoid duplicate them */
105
				$found = false;
106
				foreach ($a_out as $rule) {
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']) {
112
						$found = true;
113
						break;
114
					}
115
				}
116

    
117
				if ($found === false)
118
					$a_out[] = $natent;
119
			}
120
		}
121
		$savemsg = gettext("Default rules for each interface have been created.");
122
		unset($FilterIflist, $GatewaysList);
123
	}
124

    
125
	$config['nat']['outbound']['mode'] = $_POST['mode'];
126

    
127
	if (write_config())
128
		mark_subsystem_dirty('natconf');
129
	header("Location: firewall_nat_out.php");
130
	exit;
131
}
132

    
133
if ($_GET['act'] == "del") {
134
	if ($a_out[$_GET['id']]) {
135
		unset($a_out[$_GET['id']]);
136
		if (write_config())
137
			mark_subsystem_dirty('natconf');
138
		header("Location: firewall_nat_out.php");
139
		exit;
140
	}
141
}
142

    
143
if (isset($_POST['del_x'])) {
144
	/* delete selected rules */
145
	if (is_array($_POST['rule']) && count($_POST['rule'])) {
146
		foreach ($_POST['rule'] as $rulei) {
147
			unset($a_out[$rulei]);
148
		}
149
		if (write_config())
150
			mark_subsystem_dirty('natconf');
151
		header("Location: firewall_nat_out.php");
152
		exit;
153
	}
154

    
155
} else if ($_GET['act'] == "toggle") {
156
	if ($a_out[$_GET['id']]) {
157
		if(isset($a_out[$_GET['id']]['disabled']))
158
			unset($a_out[$_GET['id']]['disabled']);
159
		else
160
			$a_out[$_GET['id']]['disabled'] = true;
161
		if (write_config("Firewall: NAT: Outbound, enable/disable NAT rule"))
162
			mark_subsystem_dirty('natconf');
163
		header("Location: firewall_nat_out.php");
164
		exit;
165
	}
166
} else {
167
	/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
168
	unset($movebtn);
169
	foreach ($_POST as $pn => $pd) {
170
		if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
171
			$movebtn = $matches[1];
172
			break;
173
		}
174
	}
175
	/* move selected rules before this rule */
176
	if (isset($movebtn) && is_array($_POST['rule']) && count($_POST['rule'])) {
177
		$a_out_new = array();
178

    
179
		/* copy all rules < $movebtn and not selected */
180
		for ($i = 0; $i < $movebtn; $i++) {
181
			if (!in_array($i, $_POST['rule']))
182
				$a_out_new[] = $a_out[$i];
183
		}
184

    
185
		/* copy all selected rules */
186
		for ($i = 0; $i < count($a_out); $i++) {
187
			if ($i == $movebtn)
188
				continue;
189
			if (in_array($i, $_POST['rule']))
190
				$a_out_new[] = $a_out[$i];
191
		}
192

    
193
		/* copy $movebtn rule */
194
		if ($movebtn < count($a_out))
195
			$a_out_new[] = $a_out[$movebtn];
196

    
197
		/* copy all rules > $movebtn and not selected */
198
		for ($i = $movebtn+1; $i < count($a_out); $i++) {
199
			if (!in_array($i, $_POST['rule']))
200
				$a_out_new[] = $a_out[$i];
201
		}
202
		if (count($a_out_new) > 0)
203
			$a_out = $a_out_new;
204

    
205
		if (write_config())
206
			mark_subsystem_dirty('natconf');
207
		header("Location: firewall_nat_out.php");
208
		exit;
209
	}
210
}
211

    
212
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Outbound"));
213
include("head.inc");
214

    
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
if ($savemsg)
224
	print_info_box($savemsg);
225
if (is_subsystem_dirty('natconf'))
226
	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."));
227
?>
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
						&nbsp;
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
						&nbsp;
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>&nbsp;<?=gettext("Mappings:"); ?></b></td></tr>
301
				<tr><td>&nbsp;</td></tr>
302
				<tr id="frheader">
303
					<td width="3%" class="list">&nbsp;</td>
304
					<td width="3%" class="list">&nbsp;</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>
327
<?php
328
			$i = 0;
329
			foreach ($a_out as $natent):
330
				$iconfn = "pass";
331
				$textss = $textse = "";
332
				if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) {
333
					$textss = "<span class=\"gray\">";
334
					$textse = "</span>";
335
					$iconfn .= "_d";
336
				}
337

    
338
				//build Alias popup box
339
				$alias_src_span_begin = "";
340
				$alias_src_port_span_begin = "";
341
				$alias_dst_span_begin = "";
342
				$alias_dst_port_span_begin = "";
343

    
344
				$alias_popup = rule_popup($natent['source']['network'],pprint_port($natent['sourceport']),$natent['destination']['address'],pprint_port($natent['dstport']));
345

    
346
				$alias_src_span_begin = $alias_popup["src"];
347
				$alias_src_port_span_begin = $alias_popup["srcport"];
348
				$alias_dst_span_begin = $alias_popup["dst"];
349
				$alias_dst_port_span_begin = $alias_popup["dstport"];
350

    
351
				$alias_src_span_end = $alias_popup["src_end"];
352
				$alias_src_port_span_end = $alias_popup["srcport_end"];
353
				$alias_dst_span_end = $alias_popup["dst_end"];
354
				$alias_dst_port_span_end = $alias_popup["dstport_end"];
355
?>
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">
361
<?php
362
					if ($mode == "disabled" || $mode == "automatic"):
363
?>
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" />
366
<?php
367
					else:
368
?>
369
						<a href="?act=toggle&amp;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>
373
<?php
374
						endif;
375
?>
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
						&nbsp;
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;?>';">
386
<?php
387
						echo $textss;
388
						echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
389
						if (!$natent['sourceport'])
390
							echo "*";
391
						else
392
							echo $alias_src_port_span_begin . $natent['sourceport'] . $alias_src_port_span_end;
393
						echo $textse;
394
?>
395
					</td>
396
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
397
<?php
398
						echo $textss;
399
						if (isset($natent['destination']['any']))
400
							echo "*";
401
						else {
402
							if (isset($natent['destination']['not']))
403
								echo "!&nbsp;";
404
							echo $alias_dst_span_begin . $natent['destination']['address'] . $alias_dst_span_end;
405
						}
406
						echo $textse;
407
?>
408
					</td>
409
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
410
<?php
411
						echo $textss;
412
						echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
413
						if (!$natent['dstport'])
414
							echo "*";
415
						else
416
							echo $alias_dst_port_span_begin . $natent['dstport'] . $alias_dst_port_span_end;
417
						echo $textse;
418
?>
419
					</td>
420
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
421
<?php
422
						echo $textss;
423
						if (isset($natent['nonat']))
424
							echo '<I>NO NAT</I>';
425
						elseif (!$natent['target'])
426
							echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
427
						elseif ($natent['target'] == "other-subnet")
428
							echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
429
						else
430
							echo $natent['target'];
431
						echo $textse;
432
?>
433
					</td>
434
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
435
<?php
436
						echo $textss;
437
						if (!$natent['natport'])
438
							echo "*";
439
						else
440
							echo $natent['natport'];
441
						echo $textse;
442
?>
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">
445
<?php
446
						echo $textss;
447
						if(isset($natent['staticnatport']))
448
							echo gettext("YES");
449
						else
450
							echo gettext("NO");
451
						echo $textse;
452
?>
453
					</td>
454
					<td class="listbg" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
455
						<?=htmlspecialchars($natent['descr']);?>&nbsp;
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&amp;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>
482
<?php
483
				$i++;
484
			endforeach;
485
?>
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" />
516
<?php
517
								else:
518
?>
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?");?>')" />
520
<?php
521
								endif;
522
?>
523
								</td>
524
							</tr>
525
						</table>
526
					</td>
527
				</tr>
528
<?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);
536
?>
537
				<tr><td colspan="5"><b>&nbsp;<?=gettext("Automatic rules:"); ?></b></td></tr>
538
				<tr><td>&nbsp;</td></tr>
539
				<tr id="frheader">
540
					<td width="3%" class="list">&nbsp;</td>
541
					<td width="3%" class="list">&nbsp;</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">&nbsp;</td>
552
				</tr>
553
<?php
554
				foreach ($automatic_rules as $natent):
555
?>
556
					<tr valign="top">
557
						<td class="list">&nbsp;</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" />
560
						</td>
561
						<td class="listlr" style="background-color: #E0E0E0">
562
							<?php echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); ?>
563
							&nbsp;
564
						</td>
565
						<td class="listr" style="background-color: #E0E0E0">
566
							<?=$natent['source']['network'];?>
567
						</td>
568
						<td class="listr" style="background-color: #E0E0E0">
569
<?php
570
							echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
571
							if (!$natent['sourceport'])
572
								echo "*";
573
							else
574
								echo $natent['sourceport'];
575
?>
576
						</td>
577
						<td class="listr" style="background-color: #E0E0E0">
578
<?php
579
							if (isset($natent['destination']['any']))
580
								echo "*";
581
							else {
582
								if (isset($natent['destination']['not']))
583
									echo "!&nbsp;";
584
								echo $natent['destination']['address'];
585
							}
586
?>
587
						</td>
588
						<td class="listr" style="background-color: #E0E0E0">
589
<?php
590
							echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
591
							if (!$natent['dstport'])
592
								echo "*";
593
							else
594
								echo $natent['dstport'];
595
?>
596
						</td>
597
						<td class="listr" style="background-color: #E0E0E0">
598
<?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'];
607
?>
608
						</td>
609
						<td class="listr" style="background-color: #E0E0E0">
610
<?php
611
							if (!$natent['natport'])
612
								echo "*";
613
							else
614
								echo $natent['natport'];
615
?>
616
						</td>
617
						<td class="listr" style="background-color: #E0E0E0">
618
<?php
619
							if(isset($natent['staticnatport']))
620
								echo gettext("YES");
621
							else
622
								echo gettext("NO");
623
?>
624
						</td>
625
						<td class="listbg">
626
							<?=htmlspecialchars($natent['descr']);?>&nbsp;
627
						</td>
628
						<td class="list">&nbsp;</td>
629
					</tr>
630
<?php
631
				endforeach;
632
			endif;
633
?>
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>
654
			</table>
655
			</div>
656
		</td>
657
	</tr>
658
</table>
659
</form>
660
<?php include("fend.inc"); ?>
661
</body>
662
</html>
(69-69/252)