Project

General

Profile

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