1 |
19ae0929
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
firewall_nat_1to1.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
19ae0929
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
19ae0929
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
19ae0929
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
19ae0929
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
19ae0929
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
7ac5a4cb
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: nat
|
33 |
|
|
*/
|
34 |
5b237745
|
Scott Ullrich
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-firewall-nat-1-1
|
37 |
|
|
##|*NAME=Firewall: NAT: 1:1 page
|
38 |
|
|
##|*DESCR=Allow access to the 'Firewall: NAT: 1:1' page.
|
39 |
|
|
##|*MATCH=firewall_nat_1to1.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
43 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
44 |
|
|
require_once("filter.inc");
|
45 |
|
|
require_once("shaper.inc");
|
46 |
5b237745
|
Scott Ullrich
|
|
47 |
|
|
if (!is_array($config['nat']['onetoone'])) {
|
48 |
|
|
$config['nat']['onetoone'] = array();
|
49 |
|
|
}
|
50 |
|
|
$a_1to1 = &$config['nat']['onetoone'];
|
51 |
|
|
|
52 |
|
|
if ($_POST) {
|
53 |
|
|
|
54 |
|
|
$pconfig = $_POST;
|
55 |
|
|
|
56 |
|
|
if ($_POST['apply']) {
|
57 |
|
|
$retval = 0;
|
58 |
920b3bb0
|
Scott Ullrich
|
$retval |= filter_configure();
|
59 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message($retval);
|
60 |
19ae0929
|
Scott Ullrich
|
|
61 |
5b237745
|
Scott Ullrich
|
if ($retval == 0) {
|
62 |
a368a026
|
Ermal Lu?i
|
clear_subsystem_dirty('natconf');
|
63 |
|
|
clear_subsystem_dirty('filter');
|
64 |
5b237745
|
Scott Ullrich
|
}
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
if ($_GET['act'] == "del") {
|
69 |
|
|
if ($a_1to1[$_GET['id']]) {
|
70 |
|
|
unset($a_1to1[$_GET['id']]);
|
71 |
|
|
write_config();
|
72 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('natconf');
|
73 |
5b237745
|
Scott Ullrich
|
header("Location: firewall_nat_1to1.php");
|
74 |
|
|
exit;
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
6eb17647
|
Scott Ullrich
|
|
78 |
08c18f5d
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("1:1"));
|
79 |
6eb17647
|
Scott Ullrich
|
include("head.inc");
|
80 |
|
|
|
81 |
24f600b0
|
Scott Ullrich
|
?>
|
82 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
83 |
|
|
<?php include("fbegin.inc"); ?>
|
84 |
|
|
<form action="firewall_nat_1to1.php" method="post">
|
85 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
86 |
a368a026
|
Ermal Lu?i
|
<?php if (is_subsystem_dirty('natconf')): ?><p>
|
87 |
cb42b4f7
|
Renato Botelho
|
<?php 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."));?><br>
|
88 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
89 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
90 |
a8726a3d
|
Scott Ullrich
|
<?php
|
91 |
|
|
$tab_array = array();
|
92 |
d975e2e4
|
Carlos Eduardo Ramos
|
$tab_array[] = array(gettext("Port Forward"), false, "firewall_nat.php");
|
93 |
cb42b4f7
|
Renato Botelho
|
$tab_array[] = array(gettext("1:1"), true, "firewall_nat_1to1.php");
|
94 |
d975e2e4
|
Carlos Eduardo Ramos
|
$tab_array[] = array(gettext("Outbound"), false, "firewall_nat_out.php");
|
95 |
a8726a3d
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
96 |
|
|
?>
|
97 |
5b237745
|
Scott Ullrich
|
</td></tr>
|
98 |
19ae0929
|
Scott Ullrich
|
<tr>
|
99 |
d732f186
|
Bill Marquette
|
<td>
|
100 |
|
|
<div id="mainarea">
|
101 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
102 |
19ae0929
|
Scott Ullrich
|
<tr>
|
103 |
cb42b4f7
|
Renato Botelho
|
<td width="10%" class="listhdrr"><?=gettext("Interface"); ?></td>
|
104 |
d975e2e4
|
Carlos Eduardo Ramos
|
<td width="20%" class="listhdrr"><?=gettext("External IP"); ?></td>
|
105 |
df0c55a3
|
Chris Buechler
|
<td width="15%" class="listhdrr"><?=gettext("Internal IP"); ?></td>
|
106 |
c12fb6cb
|
Ermal
|
<td width="15%" class="listhdrr"><?=gettext("Destination IP"); ?></td>
|
107 |
|
|
<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
|
108 |
d415d821
|
Seth Mos
|
<td width="10%" class="list">
|
109 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
110 |
|
|
<tr>
|
111 |
|
|
<td width="17"></td>
|
112 |
d975e2e4
|
Carlos Eduardo Ramos
|
<td valign="middle"><a href="firewall_nat_1to1_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add rule"); ?>"></a></td>
|
113 |
d415d821
|
Seth Mos
|
</tr>
|
114 |
|
|
</table>
|
115 |
|
|
</td>
|
116 |
5b237745
|
Scott Ullrich
|
</tr>
|
117 |
81f4ab8a
|
Ermal
|
<?php
|
118 |
35aa4df3
|
Erik Fonnesbeck
|
$textse = "</span>";
|
119 |
|
|
|
120 |
|
|
$i = 0; foreach ($a_1to1 as $natent):
|
121 |
|
|
|
122 |
81f4ab8a
|
Ermal
|
if (isset($natent['disabled']))
|
123 |
|
|
$textss = "<span class=\"gray\">";
|
124 |
|
|
else
|
125 |
35aa4df3
|
Erik Fonnesbeck
|
$textss = "<span>"; ?>
|
126 |
19ae0929
|
Scott Ullrich
|
<tr>
|
127 |
d970cc7c
|
Bill Marquette
|
<td class="listlr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
|
128 |
5b237745
|
Scott Ullrich
|
<?php
|
129 |
81f4ab8a
|
Ermal
|
echo $textss;
|
130 |
8b35aa77
|
Erik Fonnesbeck
|
if (!$natent['interface'])
|
131 |
|
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
|
132 |
5b237745
|
Scott Ullrich
|
else
|
133 |
8b35aa77
|
Erik Fonnesbeck
|
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
|
134 |
81f4ab8a
|
Ermal
|
echo $textse;
|
135 |
5b237745
|
Scott Ullrich
|
?>
|
136 |
|
|
</td>
|
137 |
d970cc7c
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
|
138 |
71809626
|
Erik Fonnesbeck
|
<?php
|
139 |
|
|
$source_net = pprint_address($natent['source']);
|
140 |
|
|
$source_cidr = strstr($source_net, '/');
|
141 |
|
|
echo $textss . $natent['external'] . $source_cidr . $textse;
|
142 |
|
|
?>
|
143 |
5b237745
|
Scott Ullrich
|
</td>
|
144 |
d970cc7c
|
Bill Marquette
|
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
|
145 |
71809626
|
Erik Fonnesbeck
|
<?php echo $textss . $source_net . $textse; ?>
|
146 |
c12fb6cb
|
Ermal
|
</td>
|
147 |
|
|
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
|
148 |
81f4ab8a
|
Ermal
|
<?php echo $textss . pprint_address($natent['destination']) . $textse; ?>
|
149 |
5b237745
|
Scott Ullrich
|
</td>
|
150 |
d970cc7c
|
Bill Marquette
|
<td class="listbg" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
|
151 |
81f4ab8a
|
Ermal
|
<?=$textss;?>
|
152 |
64286300
|
Scott Ullrich
|
<?=htmlspecialchars($natent['descr']);?>
|
153 |
81f4ab8a
|
Ermal
|
<?=$textse;?>
|
154 |
5b237745
|
Scott Ullrich
|
</td>
|
155 |
48d751fd
|
Bill Marquette
|
<td class="list" nowrap>
|
156 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
157 |
|
|
<tr>
|
158 |
d975e2e4
|
Carlos Eduardo Ramos
|
<td valign="middle"><a href="firewall_nat_1to1_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="<?=gettext("edit rule"); ?>"></a></td>
|
159 |
3ced0d25
|
Erik Fonnesbeck
|
<td valign="middle"><a href="firewall_nat_1to1.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("delete rule"); ?>"></a></td>
|
160 |
48d751fd
|
Bill Marquette
|
</tr>
|
161 |
|
|
</table>
|
162 |
|
|
</td>
|
163 |
|
|
</tr>
|
164 |
|
|
<?php $i++; endforeach; ?>
|
165 |
19ae0929
|
Scott Ullrich
|
<tr>
|
166 |
c12fb6cb
|
Ermal
|
<td class="list" colspan="5"></td>
|
167 |
48d751fd
|
Bill Marquette
|
<td class="list">
|
168 |
|
|
<table border="0" cellspacing="0" cellpadding="1">
|
169 |
|
|
<tr>
|
170 |
d415d821
|
Seth Mos
|
<td width="17"></td>
|
171 |
d975e2e4
|
Carlos Eduardo Ramos
|
<td valign="middle"><a href="firewall_nat_1to1_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="<?=gettext("add rule"); ?>"></a></td>
|
172 |
48d751fd
|
Bill Marquette
|
</tr>
|
173 |
|
|
</table>
|
174 |
|
|
</td>
|
175 |
|
|
</tr>
|
176 |
d732f186
|
Bill Marquette
|
<tr>
|
177 |
|
|
<td colspan="4">
|
178 |
5336d152
|
Carlos Eduardo Ramos
|
<p><span class="vexpl"><span class="red"><strong><?=gettext("Note:"); ?><br>
|
179 |
|
|
</strong></span><?=gettext("Depending on the way your WAN connection is setup, you may also need a"); ?> <a href="firewall_virtual_ip.php"><?=gettext("Virtual IP."); ?></a><br/>
|
180 |
d975e2e4
|
Carlos Eduardo Ramos
|
<?=gettext("If you add a 1:1 NAT entry for any of the interface IPs on this system, it will make this system inaccessible on that IP address. i.e. if " .
|
181 |
|
|
"you use your WAN IP address, any services on this system (IPsec, OpenVPN server, etc.) using the WAN IP address will no longer function."); ?></span></p>
|
182 |
d732f186
|
Bill Marquette
|
</td>
|
183 |
|
|
<tr>
|
184 |
|
|
</table>
|
185 |
|
|
</div>
|
186 |
|
|
</td>
|
187 |
5b237745
|
Scott Ullrich
|
</tr>
|
188 |
|
|
</table>
|
189 |
|
|
</form>
|
190 |
|
|
<?php include("fend.inc"); ?>
|
191 |
|
|
</body>
|
192 |
|
|
</html>
|