1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
19ae0929
|
Scott Ullrich
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
firewall_nat_server.php
|
6 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
7 |
19ae0929
|
Scott Ullrich
|
|
8 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
9 |
|
|
All rights reserved.
|
10 |
19ae0929
|
Scott Ullrich
|
|
11 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
19ae0929
|
Scott Ullrich
|
|
14 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
19ae0929
|
Scott Ullrich
|
|
17 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
19ae0929
|
Scott Ullrich
|
|
21 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
require("guiconfig.inc");
|
34 |
|
|
|
35 |
|
|
if (!is_array($config['nat']['servernat'])) {
|
36 |
|
|
$config['nat']['servernat'] = array();
|
37 |
|
|
}
|
38 |
|
|
$a_snat = &$config['nat']['servernat'];
|
39 |
|
|
nat_server_rules_sort();
|
40 |
|
|
|
41 |
|
|
if ($_POST) {
|
42 |
|
|
|
43 |
|
|
$pconfig = $_POST;
|
44 |
|
|
|
45 |
|
|
if ($_POST['apply']) {
|
46 |
|
|
$retval = 0;
|
47 |
|
|
if (!file_exists($d_sysrebootreqd_path)) {
|
48 |
|
|
config_lock();
|
49 |
|
|
$retval |= filter_configure();
|
50 |
|
|
config_unlock();
|
51 |
|
|
}
|
52 |
|
|
$savemsg = get_std_save_message($retval);
|
53 |
19ae0929
|
Scott Ullrich
|
|
54 |
5b237745
|
Scott Ullrich
|
if ($retval == 0) {
|
55 |
|
|
if (file_exists($d_natconfdirty_path))
|
56 |
|
|
unlink($d_natconfdirty_path);
|
57 |
|
|
if (file_exists($d_filterconfdirty_path))
|
58 |
|
|
unlink($d_filterconfdirty_path);
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
if ($_GET['act'] == "del") {
|
64 |
|
|
if ($a_snat[$_GET['id']]) {
|
65 |
|
|
/* make sure no inbound NAT mappings reference this entry */
|
66 |
|
|
if (is_array($config['nat']['rule'])) {
|
67 |
|
|
foreach ($config['nat']['rule'] as $rule) {
|
68 |
|
|
if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
|
69 |
|
|
$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
|
70 |
|
|
break;
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
19ae0929
|
Scott Ullrich
|
|
75 |
5b237745
|
Scott Ullrich
|
if (!$input_errors) {
|
76 |
|
|
unset($a_snat[$_GET['id']]);
|
77 |
|
|
write_config();
|
78 |
|
|
touch($d_natconfdirty_path);
|
79 |
|
|
header("Location: firewall_nat_server.php");
|
80 |
|
|
exit;
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
6eb17647
|
Scott Ullrich
|
|
85 |
183a4aae
|
Bill Marquette
|
$pgtitle = "Firewall: NAT: NAT Addresses";
|
86 |
6eb17647
|
Scott Ullrich
|
include("head.inc");
|
87 |
|
|
|
88 |
24f600b0
|
Scott Ullrich
|
?>
|
89 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
90 |
|
|
<?php include("fbegin.inc"); ?>
|
91 |
da7ae7ef
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
92 |
5b237745
|
Scott Ullrich
|
<form action="firewall_nat_server.php" method="post">
|
93 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
94 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
95 |
|
|
<?php if (file_exists($d_natconfdirty_path)): ?><p>
|
96 |
|
|
<?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>
|
97 |
|
|
<?php endif; ?>
|
98 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
99 |
a8726a3d
|
Scott Ullrich
|
<?php
|
100 |
|
|
$tab_array = array();
|
101 |
183a4aae
|
Bill Marquette
|
$tab_array[0] = array("Port Forward", false, "firewall_nat.php");
|
102 |
|
|
$tab_array[1] = array("NAT Addresses", true, "firewall_nat_server.php");
|
103 |
a8726a3d
|
Scott Ullrich
|
$tab_array[2] = array("1:1", false, "firewall_nat_1to1.php");
|
104 |
|
|
$tab_array[3] = array("Outbound", false, "firewall_nat_out.php");
|
105 |
183a4aae
|
Bill Marquette
|
$tab_array[4] = array("Outbound Load Balancing", false, "firewall_nat_out_load_balancing.php");
|
106 |
a8726a3d
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
107 |
|
|
?>
|
108 |
5b237745
|
Scott Ullrich
|
</td></tr>
|
109 |
19ae0929
|
Scott Ullrich
|
<tr>
|
110 |
d732f186
|
Bill Marquette
|
<td>
|
111 |
|
|
<div id="mainarea">
|
112 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
113 |
19ae0929
|
Scott Ullrich
|
<tr>
|
114 |
5b237745
|
Scott Ullrich
|
<td width="40%" class="listhdrr">External IP address</td>
|
115 |
|
|
<td width="50%" class="listhdr">Description</td>
|
116 |
|
|
<td width="10%" class="list"></td>
|
117 |
|
|
</tr>
|
118 |
|
|
<?php $i = 0; foreach ($a_snat as $natent): ?>
|
119 |
19ae0929
|
Scott Ullrich
|
<tr>
|
120 |
b261bc51
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
|
121 |
5b237745
|
Scott Ullrich
|
<?=$natent['ipaddr'];?>
|
122 |
|
|
</td>
|
123 |
b261bc51
|
Bill Marquette
|
<td class="listbg" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
|
124 |
19ae0929
|
Scott Ullrich
|
<font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>
|
125 |
5b237745
|
Scott Ullrich
|
</td>
|
126 |
c39b8aa6
|
Bill Marquette
|
<td class="list" nowrap>
|
127 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
128 |
|
|
<tr>
|
129 |
677c0869
|
Erik Kristensen
|
<td valign="middle"><a href="firewall_nat_server_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
|
130 |
|
|
<td valign="middle"><a href="firewall_nat_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
131 |
c39b8aa6
|
Bill Marquette
|
</tr>
|
132 |
|
|
</table>
|
133 |
|
|
</td>
|
134 |
|
|
</tr>
|
135 |
|
|
<?php $i++; endforeach; ?>
|
136 |
19ae0929
|
Scott Ullrich
|
<tr>
|
137 |
5b237745
|
Scott Ullrich
|
<td class="list" colspan="2"></td>
|
138 |
c39b8aa6
|
Bill Marquette
|
<td class="list">
|
139 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
140 |
|
|
<tr>
|
141 |
677c0869
|
Erik Kristensen
|
<td valign="middle"><a href="firewall_nat_server_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
142 |
c39b8aa6
|
Bill Marquette
|
</tr>
|
143 |
|
|
</table>
|
144 |
|
|
</td>
|
145 |
|
|
</tr>
|
146 |
d732f186
|
Bill Marquette
|
<tr>
|
147 |
|
|
<td colspan="2">
|
148 |
|
|
<p><span class="vexpl"><span class="red"><strong>Note:<br>
|
149 |
1425e067
|
Bill Marquette
|
</strong></span>The external IP addresses defined on this page may be used in <a href="firewall_nat.php">inbound NAT</a> mappings. Depending on the way your WAN connection is setup, you may also need a <a href="services_virtual_ip.php">Virtual IP</a>.</span></p>
|
150 |
d732f186
|
Bill Marquette
|
</td>
|
151 |
|
|
</tr>
|
152 |
|
|
</table>
|
153 |
|
|
</div>
|
154 |
|
|
</table>
|
155 |
5b237745
|
Scott Ullrich
|
</form>
|
156 |
|
|
<?php include("fend.inc"); ?>
|
157 |
|
|
</body>
|
158 |
|
|
</html>
|