Project

General

Profile

Download (6.5 KB) Statistics
| Branch: | Tag: | Revision:
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
32
require("guiconfig.inc");
33
34
if (!is_array($config['nat']['onetoone'])) {
35
	$config['nat']['onetoone'] = array();
36
}
37
$a_1to1 = &$config['nat']['onetoone'];
38
nat_1to1_rules_sort();
39
40
if ($_POST) {
41
42
	$pconfig = $_POST;
43
44
	if ($_POST['apply']) {
45
		$retval = 0;
46 920b3bb0 Scott Ullrich
47
		config_lock();
48
		$retval |= filter_configure();
49
		config_unlock();
50
51 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
52 19ae0929 Scott Ullrich
53 5b237745 Scott Ullrich
		if ($retval == 0) {
54
			if (file_exists($d_natconfdirty_path))
55
				unlink($d_natconfdirty_path);
56
			if (file_exists($d_filterconfdirty_path))
57
				unlink($d_filterconfdirty_path);
58
		}
59
	}
60
}
61
62
if ($_GET['act'] == "del") {
63
	if ($a_1to1[$_GET['id']]) {
64
		unset($a_1to1[$_GET['id']]);
65
		write_config();
66
		touch($d_natconfdirty_path);
67
		header("Location: firewall_nat_1to1.php");
68
		exit;
69
	}
70
}
71 6eb17647 Scott Ullrich
72
$pgtitle = "Firewall: NAT: 1:1";
73
include("head.inc");
74
75 24f600b0 Scott Ullrich
?>
76 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
77
<?php include("fbegin.inc"); ?>
78 da7ae7ef Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
79 5b237745 Scott Ullrich
<form action="firewall_nat_1to1.php" method="post">
80
<?php if ($savemsg) print_info_box($savemsg); ?>
81
<?php if (file_exists($d_natconfdirty_path)): ?><p>
82
<?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>
83
<?php endif; ?>
84
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
85 a8726a3d Scott Ullrich
<?php
86
	$tab_array = array();
87 1425e067 Bill Marquette
	$tab_array[] = array("Port Forward", false, "firewall_nat.php");
88
	$tab_array[] = array("1:1", true, "firewall_nat_1to1.php");
89
	$tab_array[] = array("Outbound", false, "firewall_nat_out.php");
90 a8726a3d Scott Ullrich
	display_top_tabs($tab_array);
91
?>
92 5b237745 Scott Ullrich
  </td></tr>
93 19ae0929 Scott Ullrich
  <tr>
94 d732f186 Bill Marquette
    <td>
95
	<div id="mainarea">
96
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
97 19ae0929 Scott Ullrich
                <tr>
98 d970cc7c Bill Marquette
		  <td width="10%" class="listhdrr">Interface</td>
99 5b237745 Scott Ullrich
                  <td width="20%" class="listhdrr">External IP</td>
100
                  <td width="20%" class="listhdrr">Internal IP</td>
101
                  <td width="40%" class="listhdr">Description</td>
102 d415d821 Seth Mos
                  <td width="10%" class="list">
103
                    <table border="0" cellspacing="0" cellpadding="1">
104
                      <tr>
105
			<td width="17"></td>
106
                        <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="add rule"></a></td>
107
                      </tr>
108
                    </table>
109
		  </td>
110 5b237745 Scott Ullrich
				</tr>
111
			  <?php $i = 0; foreach ($a_1to1 as $natent): ?>
112 19ae0929 Scott Ullrich
                <tr>
113 d970cc7c Bill Marquette
		  <td class="listlr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
114 5b237745 Scott Ullrich
                  <?php
115
					if (!$natent['interface'] || ($natent['interface'] == "wan"))
116
						echo "WAN";
117
					else
118
						echo htmlspecialchars($config['interfaces'][$natent['interface']]['descr']);
119
				  ?>
120
                  </td>
121 d970cc7c Bill Marquette
                  <td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
122 5b237745 Scott Ullrich
                    <?php echo $natent['external'];
123
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
124
                  </td>
125 d970cc7c Bill Marquette
                  <td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
126 5b237745 Scott Ullrich
                    <?php echo $natent['internal'];
127
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
128
                  </td>
129 d970cc7c Bill Marquette
                  <td class="listbg" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
130 19ae0929 Scott Ullrich
                    <font color="#ffffff"><?=htmlspecialchars($natent['descr']);?>&nbsp;
131 5b237745 Scott Ullrich
                  </td>
132 48d751fd Bill Marquette
                  <td class="list" nowrap>
133
                    <table border="0" cellspacing="0" cellpadding="1">
134
                      <tr>
135 f057bae4 Bill Marquette
                        <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="edit rule"></a></td>
136
                        <td valign="middle"><a href="firewall_nat_1to1.php?act=del&id=<?=$i;?>" onclick="return confirm('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="delete rule"></a></td>
137 48d751fd Bill Marquette
                      </tr>
138
                    </table>
139
                  </td>
140
                </tr>
141
		<?php $i++; endforeach; ?>
142 19ae0929 Scott Ullrich
                <tr>
143 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
144 48d751fd Bill Marquette
                  <td class="list">
145
                    <table border="0" cellspacing="0" cellpadding="1">
146
                      <tr>
147 d415d821 Seth Mos
			<td width="17"></td>
148 f057bae4 Bill Marquette
                        <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="add rule"></a></td>
149 48d751fd Bill Marquette
                      </tr>
150
                    </table>
151
                  </td>
152
                </tr>
153 d732f186 Bill Marquette
		<tr>
154
		  <td colspan="4">
155
		        <p><span class="vexpl"><span class="red"><strong>Note:<br>
156 1425e067 Bill Marquette
                      </strong></span>Depending on the way your WAN connection is setup, you may also need a <a href="firewall_virtual_ip.php">Virtual IP</a>.</span></p>
157 d732f186 Bill Marquette
		  </td>
158
		<tr>
159
              </table>
160
	    </div>
161
	</td>
162 5b237745 Scott Ullrich
</tr>
163
</table>
164
</form>
165
<?php include("fend.inc"); ?>
166
</body>
167
</html>