1
|
#!/usr/local/bin/php
|
2
|
<?php
|
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
|
require("guiconfig.inc");
|
35
|
|
36
|
if (!is_array($config['nat']['advancedoutbound']['rule']))
|
37
|
$config['nat']['advancedoutbound']['rule'] = array();
|
38
|
|
39
|
$a_out = &$config['nat']['advancedoutbound']['rule'];
|
40
|
nat_out_rules_sort();
|
41
|
|
42
|
if ($_POST) {
|
43
|
|
44
|
$pconfig = $_POST;
|
45
|
|
46
|
$config['nat']['advancedoutbound']['enable'] = ($_POST['enable']) ? true : false;
|
47
|
write_config();
|
48
|
|
49
|
$retval = 0;
|
50
|
|
51
|
if (!file_exists($d_sysrebootreqd_path)) {
|
52
|
config_lock();
|
53
|
$retval |= filter_configure();
|
54
|
config_unlock();
|
55
|
}
|
56
|
$savemsg = get_std_save_message($retval);
|
57
|
|
58
|
if ($retval == 0) {
|
59
|
if (file_exists($d_natconfdirty_path))
|
60
|
unlink($d_natconfdirty_path);
|
61
|
if (file_exists($d_filterconfdirty_path))
|
62
|
unlink($d_filterconfdirty_path);
|
63
|
}
|
64
|
}
|
65
|
|
66
|
if ($_GET['act'] == "del") {
|
67
|
if ($a_out[$_GET['id']]) {
|
68
|
unset($a_out[$_GET['id']]);
|
69
|
write_config();
|
70
|
touch($d_natconfdirty_path);
|
71
|
header("Location: firewall_nat_out.php");
|
72
|
exit;
|
73
|
}
|
74
|
}
|
75
|
?>
|
76
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
77
|
<html>
|
78
|
<head>
|
79
|
<title><?=gentitle("Firewall: NAT: Outbound");?></title>
|
80
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
81
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
82
|
</head>
|
83
|
|
84
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
85
|
<?php include("fbegin.inc"); ?>
|
86
|
<p class="pgtitle">Firewall: NAT: Outbound</p>
|
87
|
<form action="firewall_nat_out.php" method="post">
|
88
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
89
|
<?php if (file_exists($d_natconfdirty_path)): ?><p>
|
90
|
<?php print_info_box_np("The NAT configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
91
|
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
|
92
|
<?php endif; ?>
|
93
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
94
|
<ul id="tabnav">
|
95
|
<li class="tabinact"><a href="firewall_nat.php">Inbound</a></li>
|
96
|
<li class="tabinact"><a href="firewall_nat_server.php">Server NAT</a></li>
|
97
|
<li class="tabinact"><a href="firewall_nat_1to1.php">1:1</a></li>
|
98
|
<li class="tabact">Outbound</li>
|
99
|
<li class="tabinact"><a href="firewall_nat_out_load_balancing.php">Outbound Load Balancing</a></li>
|
100
|
</ul>
|
101
|
</td></tr>
|
102
|
<tr>
|
103
|
<td class="tabcont">
|
104
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
105
|
<tr>
|
106
|
<td class="vtable"><p>
|
107
|
<input name="enable" type="checkbox" id="enable" value="yes" <?php if (isset($config['nat']['advancedoutbound']['enable'])) echo "checked";?>>
|
108
|
<strong>Enable advanced outbound NAT<br>
|
109
|
</strong></p>
|
110
|
</td>
|
111
|
</tr>
|
112
|
<tr>
|
113
|
<td> <input name="submit" type="submit" class="formbtn" value="Save">
|
114
|
</td>
|
115
|
</tr>
|
116
|
<tr>
|
117
|
<td colspan="2"><p><span class="vexpl"><span class="red"><strong>Note:<br>
|
118
|
</strong></span>If advanced outbound NAT is enabled, no outbound NAT
|
119
|
rules will be automatically generated anymore. Instead, only the mappings
|
120
|
you specify below will be used. With advanced outbound NAT disabled,
|
121
|
a mapping is automatically created for each interface's subnet
|
122
|
(except WAN).</span> If you use target addresses other than the WAN interface's IP address, then depending on<span class="vexpl"> the way your WAN connection is setup, you may also need <a href="services_proxyarp.php">proxy ARP</a>.</span><br>
|
123
|
<br>
|
124
|
You may enter your own mappings below.</p>
|
125
|
</td>
|
126
|
</tr>
|
127
|
</table>
|
128
|
<br>
|
129
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
130
|
<tr>
|
131
|
<td width="10%" class="listhdrr">Interface</td>
|
132
|
<td width="20%" class="listhdrr">Source</td>
|
133
|
<td width="20%" class="listhdrr">Source Port</td>
|
134
|
<td width="20%" class="listhdrr">Destination</td>
|
135
|
<td width="20%" class="listhdrr">NAT Port</td>
|
136
|
<td width="20%" class="listhdrr">Target</td>
|
137
|
<td width="25%" class="listhdr">Description</td>
|
138
|
<td width="5%" class="list"></td>
|
139
|
</tr>
|
140
|
<?php $i = 0; foreach ($a_out as $natent): ?>
|
141
|
<tr>
|
142
|
<td class="listlr">
|
143
|
<?php
|
144
|
if (!$natent['interface'] || ($natent['interface'] == "wan"))
|
145
|
echo "WAN";
|
146
|
else
|
147
|
htmlspecialchars($config['interfaces'][$natent['interface']]['descr']);
|
148
|
?>
|
149
|
</td>
|
150
|
<td class="listr">
|
151
|
<?=$natent['source']['network'];?>
|
152
|
</td>
|
153
|
<td class="listr">
|
154
|
<?php
|
155
|
if (!$natent['sourceport'])
|
156
|
echo "*";
|
157
|
else
|
158
|
echo $natent['sourceport'];
|
159
|
?>
|
160
|
</td>
|
161
|
<td class="listr">
|
162
|
<?php
|
163
|
if (isset($natent['destination']['any']))
|
164
|
echo "*";
|
165
|
else {
|
166
|
if (isset($natent['destination']['not']))
|
167
|
echo "! ";
|
168
|
echo $natent['destination']['network'];
|
169
|
}
|
170
|
?>
|
171
|
</td>
|
172
|
<td class="listr">
|
173
|
<?php
|
174
|
if (!$natent['natport'])
|
175
|
echo "*";
|
176
|
else
|
177
|
echo $natent['natport'];
|
178
|
?>
|
179
|
</td>
|
180
|
<td class="listr">
|
181
|
<?php
|
182
|
if (!$natent['target'])
|
183
|
echo "*";
|
184
|
else
|
185
|
echo $natent['target'];
|
186
|
?>
|
187
|
</td>
|
188
|
<td class="listbg">
|
189
|
<font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>
|
190
|
</td>
|
191
|
<td class="list" nowrap> <a href="firewall_nat_out_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
|
192
|
<a href="firewall_nat_out.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this mapping?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
|
193
|
</tr>
|
194
|
<?php $i++; endforeach; ?>
|
195
|
<tr>
|
196
|
<td class="list" colspan="7"></td>
|
197
|
<td class="list"> <a href="firewall_nat_out_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
|
198
|
</tr>
|
199
|
</table>
|
200
|
</td>
|
201
|
</tr>
|
202
|
</table>
|
203
|
</form>
|
204
|
<?php include("fend.inc"); ?>
|
205
|
</body>
|
206
|
</html>
|