Project

General

Profile

Download (6.21 KB) Statistics
| Branch: | Tag: | Revision:
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_1to1.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']['onetoone'])) {
36
	$config['nat']['onetoone'] = array();
37
}
38
$a_1to1 = &$config['nat']['onetoone'];
39
nat_1to1_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_1to1[$_GET['id']]) {
65
		unset($a_1to1[$_GET['id']]);
66
		write_config();
67
		touch($d_natconfdirty_path);
68
		header("Location: firewall_nat_1to1.php");
69
		exit;
70
	}
71
}
72 6eb17647 Scott Ullrich
73
$pgtitle = "Firewall: NAT: 1:1";
74
include("head.inc");
75
76 24f600b0 Scott Ullrich
?>
77 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
78
<?php include("fbegin.inc"); ?>
79 da7ae7ef Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
80 5b237745 Scott Ullrich
<form action="firewall_nat_1to1.php" method="post">
81
<?php if ($savemsg) print_info_box($savemsg); ?>
82
<?php if (file_exists($d_natconfdirty_path)): ?><p>
83
<?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>
84
<?php endif; ?>
85 af4aa061 Scott Ullrich
<div id="mainarea">
86 5b237745 Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
87 a8726a3d Scott Ullrich
<?php
88
	$tab_array = array();
89 183a4aae Bill Marquette
	$tab_array[0] = array("Port Forward", false, "firewall_nat.php");
90
	$tab_array[1] = array("NAT Addresses", false, "firewall_nat_server.php");
91 a8726a3d Scott Ullrich
	$tab_array[2] = array("1:1", true, "firewall_nat_1to1.php");
92
	$tab_array[3] = array("Outbound", false, "firewall_nat_out.php");
93 183a4aae Bill Marquette
	$tab_array[4] = array("Outbound Load Balancing", false, "firewall_nat_out_load_balancing.php");
94 a8726a3d Scott Ullrich
	display_top_tabs($tab_array);
95
?>
96 5b237745 Scott Ullrich
  </td></tr>
97 19ae0929 Scott Ullrich
  <tr>
98 5b237745 Scott Ullrich
    <td class="tabcont">
99
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
100 19ae0929 Scott Ullrich
                <tr>
101 d970cc7c Bill Marquette
		  <td width="10%" class="listhdrr">Interface</td>
102 5b237745 Scott Ullrich
                  <td width="20%" class="listhdrr">External IP</td>
103
                  <td width="20%" class="listhdrr">Internal IP</td>
104
                  <td width="40%" class="listhdr">Description</td>
105
                  <td width="10%" class="list"></td>
106
				</tr>
107
			  <?php $i = 0; foreach ($a_1to1 as $natent): ?>
108 19ae0929 Scott Ullrich
                <tr>
109 d970cc7c Bill Marquette
		  <td class="listlr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
110 5b237745 Scott Ullrich
                  <?php
111
					if (!$natent['interface'] || ($natent['interface'] == "wan"))
112
						echo "WAN";
113
					else
114
						echo htmlspecialchars($config['interfaces'][$natent['interface']]['descr']);
115
				  ?>
116
                  </td>
117 d970cc7c Bill Marquette
                  <td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
118 5b237745 Scott Ullrich
                    <?php echo $natent['external'];
119
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
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['internal'];
123
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
124
                  </td>
125 d970cc7c Bill Marquette
                  <td class="listbg" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
126 19ae0929 Scott Ullrich
                    <font color="#ffffff"><?=htmlspecialchars($natent['descr']);?>&nbsp;
127 5b237745 Scott Ullrich
                  </td>
128 48d751fd Bill Marquette
                  <td class="list" nowrap>
129
                    <table border="0" cellspacing="0" cellpadding="1">
130
                      <tr>
131
                        <td valign="middle"><a href="firewall_nat_1to1_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
132
                        <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="x.gif" width="17" height="17" border="0"></a></td>
133
                      </tr>
134
                    </table>
135
                  </td>
136
                </tr>
137
		<?php $i++; endforeach; ?>
138 19ae0929 Scott Ullrich
                <tr>
139 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
140 48d751fd Bill Marquette
                  <td class="list">
141
                    <table border="0" cellspacing="0" cellpadding="1">
142
                      <tr>
143
                        <td valign="middle"><a href="firewall_nat_1to1_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
144
                      </tr>
145
                    </table>
146
                  </td>
147
                </tr>
148 5b237745 Scott Ullrich
              </table>
149
			  			        <p><span class="vexpl"><span class="red"><strong>Note:<br>
150
                      </strong></span>Depending on the way your WAN connection is setup, you may also need <a href="services_proxyarp.php">proxy ARP</a>.</span></p>
151
</td>
152
</tr>
153
</table>
154 af4aa061 Scott Ullrich
</div>
155 5b237745 Scott Ullrich
</form>
156
<?php include("fend.inc"); ?>
157 af4aa061 Scott Ullrich
<script type="text/javascript">
158
NiftyCheck();
159
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
160
</script>
161 5b237745 Scott Ullrich
</body>
162
</html>