Projet

Général

Profil

Télécharger (23,3 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / firewall_nat_out.php @ 0fab7eb1

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