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
	write_config();
68

    
69
	$retval = 0;
70
	$retval |= filter_configure();
71

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

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

    
83
if (isset($_POST['save']) && $_POST['save'] == "Save") {
84
	/* mutually exclusive settings - if user wants advanced NAT, we don't generate automatic rules */
85
	if ($_POST['mode'] == "advanced" && ($mode == "automatic" || $mode == "hybrid")) {
86
		/*
87
		 *    user has enabled advanced outbound NAT and doesn't have rules
88
		 *    lets automatically create entries
89
		 *    for all of the interfaces to make life easier on the pip-o-chap
90
		 */
91
		if(empty($FilterIflist))
92
			filter_generate_optcfg_array();
93
		if(empty($GatewaysList))
94
			filter_generate_gateways();
95
		$tonathosts = filter_nat_rules_automatic_tonathosts(true);
96
		$automatic_rules = filter_nat_rules_outbound_automatic("");
97

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

    
106
				/* Try to detect already auto created rules and avoid duplicate them */
107
				$found = false;
108
				foreach ($a_out as $rule) {
109
					if ($rule['interface'] == $natent['interface'] &&
110
					    $rule['source']['network'] == $natent['source']['network'] &&
111
					    $rule['dstport'] == $natent['dstport'] &&
112
					    $rule['target'] == $natent['target'] &&
113
					    $rule['descr'] == $natent['descr']) {
114
						$found = true;
115
						break;
116
					}
117
				}
118

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

    
127
	$config['nat']['outbound']['mode'] = $_POST['mode'];
128

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

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

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

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

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

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

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

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

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

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

    
217
//FIXME This largely matches firewall_rules.php
218

    
219
?>
220
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
221
<?php include("fbegin.inc"); ?>
222
<form action="firewall_nat_out.php" method="post" name="iform">
223
<script type="text/javascript" src="/javascript/row_toggle.js"></script>
224
<?php
225
if ($savemsg)
226
	print_info_box($savemsg);
227
if (is_subsystem_dirty('natconf'))
228
	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."));
229
?>
230
<br />
231
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firewall nat outbound">
232
	<tr><td>
233
<?php
234
		$tab_array = array();
235
		$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php");
236
		$tab_array[] = array(gettext("1:1"), false, "firewall_nat_1to1.php");
237
		$tab_array[] = array(gettext("Outbound"), true, "firewall_nat_out.php");
238
		$tab_array[] = array(gettext("NPt"), false, "firewall_nat_npt.php");
239
		display_top_tabs($tab_array);
240
?>
241
	</td></tr>
242
	<tr>
243
		<td>
244
			<div id="mainarea">
245
			<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
246
				<tr>
247
					<td rowspan="3" align="right" valign="middle"><b><?=gettext("Mode:"); ?></b></td>
248
					<td>
249
						<input name="mode" type="radio" id="automatic" value="automatic" <?php if ($mode == "automatic") echo "checked=\"checked\"";?> />
250
					</td>
251
					<td>
252
						<strong>
253
							<?=gettext("Automatic outbound NAT rule generation"); ?><br />
254
							<?=gettext("(IPsec passthrough included)");?>
255
						</strong>
256
					</td>
257
					<td>
258
						<input name="mode" type="radio" id="hybrid" value="hybrid" <?php if ($mode == "hybrid") echo "checked=\"checked\"";?> />
259
					</td>
260
					<td>
261
						<strong>
262
							<?=gettext("Hybrid Outbound NAT rule generation"); ?><br />
263
							<?=gettext("(Automatic Outbound NAT + rules below)");?>
264
						</strong>
265
					</td>
266
					<td rowspan="3" valign="middle" align="left">
267
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
268
					</td>
269
				</tr>
270
				<tr>
271
					<td colspan="4">
272
						&nbsp;
273
					</td>
274
				</tr>
275
				<tr>
276
					<td>
277
						<input name="mode" type="radio" id="advanced" value="advanced" <?php if ($mode == "advanced") echo "checked=\"checked\"";?> />
278
					</td>
279
					<td>
280
						<strong>
281
							<?=gettext("Manual Outbound NAT rule generation"); ?><br />
282
							<?=gettext("(AON - Advanced Outbound NAT)");?>
283
						</strong>
284
					</td>
285
					<td>
286
						<input name="mode" type="radio" id="disabled" value="disabled" <?php if ($mode == "disabled") echo "checked=\"checked\"";?> />
287
					</td>
288
					<td>
289
						<strong>
290
							<?=gettext("Disable Outbound NAT rule generation"); ?><br />
291
							<?=gettext("(No Outbound NAT rules)");?>
292
						</strong>
293
					</td>
294
				</tr>
295
				<tr>
296
					<td colspan="6">
297
						&nbsp;
298
					</td>
299
				</tr>
300
			</table>
301
			<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="mappings">
302
				<tr><td colspan="5"><b>&nbsp;<?=gettext("Mappings:"); ?></b></td></tr>
303
				<tr><td>&nbsp;</td></tr>
304
				<tr id="frheader">
305
					<td width="3%" class="list">&nbsp;</td>
306
					<td width="3%" class="list">&nbsp;</td>
307
					<td width="10%" class="listhdrr"><?=gettext("Interface");?></td>
308
					<td width="15%" class="listhdrr"><?=gettext("Source");?></td>
309
					<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td>
310
					<td width="15%" class="listhdrr"><?=gettext("Destination");?></td>
311
					<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td>
312
					<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td>
313
					<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td>
314
					<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td>
315
					<td width="25%" class="listhdr"><?=gettext("Description");?></td>
316
					<td width="5%" class="list">
317
						<table border="0" cellspacing="0" cellpadding="1" summary="add">
318
							<tr>
319
								<td width="17"></td>
320
								<td>
321
									<a href="firewall_nat_out_edit.php?after=-1">
322
										<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" />
323
									</a>
324
								</td>
325
							</tr>
326
						</table>
327
					</td>
328
				</tr>
329
<?php
330
			$i = 0;
331
			foreach ($a_out as $natent):
332
				$iconfn = "pass";
333
				$textss = $textse = "";
334
				if ($mode == "disabled" || $mode == "automatic" || isset($natent['disabled'])) {
335
					$textss = "<span class=\"gray\">";
336
					$textse = "</span>";
337
					$iconfn .= "_d";
338
				}
339

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

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

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

    
353
				$alias_src_span_end = $alias_popup["src_end"];
354
				$alias_src_port_span_end = $alias_popup["srcport_end"];
355
				$alias_dst_span_end = $alias_popup["dst_end"];
356
				$alias_dst_port_span_end = $alias_popup["dstport_end"];
357
?>
358
				<tr valign="top" id="fr<?=$i;?>">
359
					<td class="listt">
360
						<input type="checkbox" id="frc<?=$i;?>" name="rule[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
361
					</td>
362
					<td class="listt" align="center">
363
<?php
364
					if ($mode == "disabled" || $mode == "automatic"):
365
?>
366
						<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0"
367
							title="<?=gettext("This rule is being ignored");?>" alt="icon" />
368
<?php
369
					else:
370
?>
371
						<a href="?act=toggle&amp;id=<?=$i;?>">
372
							<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0"
373
								title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" />
374
						</a>
375
<?php
376
						endif;
377
?>
378
					</td>
379
					<td class="listlr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
380
						<?php echo $textss . htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . $textse; ?>
381
						&nbsp;
382
					</td>
383
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
384
						<?PHP $natent['source']['network'] = ($natent['source']['network'] == "(self)") ? "This Firewall" : $natent['source']['network']; ?>
385
						<?php echo $textss . $alias_src_span_begin . $natent['source']['network'] . $alias_src_span_end . $textse;?>
386
					</td>
387
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
388
<?php
389
						echo $textss;
390
						echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
391
						if (!$natent['sourceport'])
392
							echo "*";
393
						else
394
							echo $alias_src_port_span_begin . $natent['sourceport'] . $alias_src_port_span_end;
395
						echo $textse;
396
?>
397
					</td>
398
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
399
<?php
400
						echo $textss;
401
						if (isset($natent['destination']['any']))
402
							echo "*";
403
						else {
404
							if (isset($natent['destination']['not']))
405
								echo "!&nbsp;";
406
							echo $alias_dst_span_begin . $natent['destination']['address'] . $alias_dst_span_end;
407
						}
408
						echo $textse;
409
?>
410
					</td>
411
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
412
<?php
413
						echo $textss;
414
						echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
415
						if (!$natent['dstport'])
416
							echo "*";
417
						else
418
							echo $alias_dst_port_span_begin . $natent['dstport'] . $alias_dst_port_span_end;
419
						echo $textse;
420
?>
421
					</td>
422
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
423
<?php
424
						echo $textss;
425
						if (isset($natent['nonat']))
426
							echo '<I>NO NAT</I>';
427
						elseif (!$natent['target'])
428
							echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
429
						elseif ($natent['target'] == "other-subnet")
430
							echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
431
						else
432
							echo $natent['target'];
433
						echo $textse;
434
?>
435
					</td>
436
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
437
<?php
438
						echo $textss;
439
						if (!$natent['natport'])
440
							echo "*";
441
						else
442
							echo $natent['natport'];
443
						echo $textse;
444
?>
445
					</td>
446
					<td class="listr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';" align="center">
447
<?php
448
						echo $textss;
449
						if(isset($natent['staticnatport']))
450
							echo gettext("YES");
451
						else
452
							echo gettext("NO");
453
						echo $textse;
454
?>
455
					</td>
456
					<td class="listbg" onclick="fr_toggle(<?=$i;?>)" ondblclick="document.location='firewall_nat_out_edit.php?id=<?=$i;?>';">
457
						<?=htmlspecialchars($natent['descr']);?>&nbsp;
458
					</td>
459
					<td class="list nowrap" valign="middle">
460
						<table border="0" cellspacing="0" cellpadding="1" summary="move">
461
							<tr>
462
								<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>
463
								<td>
464
									<a href="firewall_nat_out_edit.php?id=<?=$i;?>">
465
										<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit mapping");?>" alt="edit" />
466
									</a>
467
								</td>
468
							</tr>
469
							<tr>
470
								<td align="center" valign="middle">
471
									<a href="firewall_nat_out.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this rule?");?>')">
472
										<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule");?>" alt="delete" />
473
									</a>
474
								</td>
475
								<td>
476
									<a href="firewall_nat_out_edit.php?dup=<?=$i;?>">
477
										<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" />
478
									</a>
479
								</td>
480
							</tr>
481
						</table>
482
					</td>
483
				</tr>
484
<?php
485
				$i++;
486
			endforeach;
487
?>
488
				<tr valign="top" id="fr<?=$i;?>">
489
					<td class="list" colspan="11"></td>
490
					<td class="list nowrap" valign="middle">
491
						<table border="0" cellspacing="0" cellpadding="1" summary="edit">
492
							<tr>
493
								<td>
494
<?php
495
								if ($i == 0):
496
?>
497
									<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" />
498
<?php
499
								else:
500
?>
501
									<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");?>" />
502
<?php
503
								endif;
504
?>
505
								</td>
506
								<td>
507
									<a href="firewall_nat_out_edit.php">
508
										<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add new mapping");?>" alt="add" />
509
									</a>
510
								</td>
511
							</tr>
512
							<tr>
513
								<td>
514
<?php
515
								if ($i == 0):
516
?>
517
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x_d.gif" width="17" height="17" title="<?=gettext("delete selected rules");?>" border="0" alt="delete" />
518
<?php
519
								else:
520
?>
521
									<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?");?>')" />
522
<?php
523
								endif;
524
?>
525
								</td>
526
							</tr>
527
						</table>
528
					</td>
529
				</tr>
530
<?php
531
			if ($mode == "automatic" || $mode == "hybrid"):
532
				if(empty($FilterIflist))
533
					filter_generate_optcfg_array();
534
				if(empty($GatewaysList))
535
					filter_generate_gateways();
536
				$automatic_rules = filter_nat_rules_outbound_automatic(implode(" ", filter_nat_rules_automatic_tonathosts()));
537
				unset($FilterIflist, $GatewaysList);
538
?>
539
				<tr><td colspan="5"><b>&nbsp;<?=gettext("Automatic rules:"); ?></b></td></tr>
540
				<tr><td>&nbsp;</td></tr>
541
				<tr id="frheader">
542
					<td width="3%" class="list">&nbsp;</td>
543
					<td width="3%" class="list">&nbsp;</td>
544
					<td width="10%" class="listhdrr"><?=gettext("Interface");?></td>
545
					<td width="15%" class="listhdrr"><?=gettext("Source");?></td>
546
					<td width="10%" class="listhdrr"><?=gettext("Source Port");?></td>
547
					<td width="15%" class="listhdrr"><?=gettext("Destination");?></td>
548
					<td width="10%" class="listhdrr"><?=gettext("Destination Port");?></td>
549
					<td width="15%" class="listhdrr"><?=gettext("NAT Address");?></td>
550
					<td width="10%" class="listhdrr"><?=gettext("NAT Port");?></td>
551
					<td width="10%" class="listhdrr"><?=gettext("Static Port");?></td>
552
					<td width="25%" class="listhdr"><?=gettext("Description");?></td>
553
					<td width="5%" class="list">&nbsp;</td>
554
				</tr>
555
<?php
556
				foreach ($automatic_rules as $natent):
557
?>
558
					<tr valign="top">
559
						<td class="list">&nbsp;</td>
560
						<td class="listt" align="center">
561
							<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0" title="<?=gettext("automatic outbound nat");?>" alt="icon" />
562
						</td>
563
						<td class="listlr" style="background-color: #E0E0E0">
564
							<?php echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])); ?>
565
							&nbsp;
566
						</td>
567
						<td class="listr" style="background-color: #E0E0E0">
568
							<?=$natent['source']['network'];?>
569
						</td>
570
						<td class="listr" style="background-color: #E0E0E0">
571
<?php
572
							echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
573
							if (!$natent['sourceport'])
574
								echo "*";
575
							else
576
								echo $natent['sourceport'];
577
?>
578
						</td>
579
						<td class="listr" style="background-color: #E0E0E0">
580
<?php
581
							if (isset($natent['destination']['any']))
582
								echo "*";
583
							else {
584
								if (isset($natent['destination']['not']))
585
									echo "!&nbsp;";
586
								echo $natent['destination']['address'];
587
							}
588
?>
589
						</td>
590
						<td class="listr" style="background-color: #E0E0E0">
591
<?php
592
							echo ($natent['protocol']) ? $natent['protocol'] . '/' : "" ;
593
							if (!$natent['dstport'])
594
								echo "*";
595
							else
596
								echo $natent['dstport'];
597
?>
598
						</td>
599
						<td class="listr" style="background-color: #E0E0E0">
600
<?php
601
							if (isset($natent['nonat']))
602
								echo '<I>NO NAT</I>';
603
							elseif (!$natent['target'])
604
								echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface'])) . " address";
605
							elseif ($natent['target'] == "other-subnet")
606
								echo $natent['targetip'] . '/' . $natent['targetip_subnet'];
607
							else
608
								echo $natent['target'];
609
?>
610
						</td>
611
						<td class="listr" style="background-color: #E0E0E0">
612
<?php
613
							if (!$natent['natport'])
614
								echo "*";
615
							else
616
								echo $natent['natport'];
617
?>
618
						</td>
619
						<td class="listr" style="background-color: #E0E0E0">
620
<?php
621
							if(isset($natent['staticnatport']))
622
								echo gettext("YES");
623
							else
624
								echo gettext("NO");
625
?>
626
						</td>
627
						<td class="listbg">
628
							<?=htmlspecialchars($natent['descr']);?>&nbsp;
629
						</td>
630
						<td class="list">&nbsp;</td>
631
					</tr>
632
<?php
633
				endforeach;
634
			endif;
635
?>
636
				<tr>
637
					<td colspan="12">
638
						<p><span class="vexpl">
639
							<span class="red"><strong><?=gettext("Note:"); ?><br /></strong></span>
640
							<?=gettext("If automatic outbound NAT selected, a mapping is automatically created " .
641
								"for each interface's subnet (except WAN-type connections) and the rules " .
642
								"on \"Mappings\" section of this page are ignored.<br /><br /> " .
643
								"If manual outbound NAT is selected, outbound NAT rules will not be " .
644
								"automatically generated and only the mappings you specify on this page " .
645
								"will be used. <br /><br /> " .
646
								"If hybrid outbound NAT is selected, mappings you specify on this page will " .
647
								"be used, followed by the automatically generated ones. <br /><br />" .
648
								"If disable outbound NAT is selected, no rules will be used. <br /><br />" .
649
								"If a target address other than an interface's IP address is used, " .
650
								"then depending on the way the WAN connection is setup, a "); ?>
651
								<a href="firewall_virtual_ip.php"><?=gettext("Virtual IP"); ?></a>
652
								<?= gettext(" may also be required.") ?>
653
						</span></p>
654
					</td>
655
				</tr>
656
			</table>
657
			</div>
658
		</td>
659
	</tr>
660
</table>
661
</form>
662
<?php include("fend.inc"); ?>
663
</body>
664
</html>
(69-69/252)