Project

General

Profile

Download (6.23 KB) Statistics
| Branch: | Tag: | Revision:
1 19ae0929 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	firewall_nat_server.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 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-firewall-nat-nataddresses
34
##|*NAME=Firewall: NAT: NAT Addresses page
35
##|*DESCR=Allow access to the 'Firewall: NAT: NAT Addresses' page.
36
##|*MATCH=firewall_nat_server.php*
37
##|-PRIV
38
39
40 5b237745 Scott Ullrich
require("guiconfig.inc");
41
42
if (!is_array($config['nat']['servernat'])) {
43
	$config['nat']['servernat'] = array();
44
}
45
$a_snat = &$config['nat']['servernat'];
46
nat_server_rules_sort();
47
48
if ($_POST) {
49
50
	$pconfig = $_POST;
51
52
	if ($_POST['apply']) {
53
		$retval = 0;
54 920b3bb0 Scott Ullrich
55
		config_lock();
56
		$retval |= filter_configure();
57
		config_unlock();
58
59 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
60 19ae0929 Scott Ullrich
61 5b237745 Scott Ullrich
		if ($retval == 0) {
62
			if (file_exists($d_natconfdirty_path))
63
				unlink($d_natconfdirty_path);
64
			if (file_exists($d_filterconfdirty_path))
65
				unlink($d_filterconfdirty_path);
66
		}
67
	}
68
}
69
70
if ($_GET['act'] == "del") {
71
	if ($a_snat[$_GET['id']]) {
72
		/* make sure no inbound NAT mappings reference this entry */
73
		if (is_array($config['nat']['rule'])) {
74
			foreach ($config['nat']['rule'] as $rule) {
75
				if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
76
					$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
77
					break;
78
				}
79
			}
80
		}
81 19ae0929 Scott Ullrich
82 5b237745 Scott Ullrich
		if (!$input_errors) {
83
			unset($a_snat[$_GET['id']]);
84
			write_config();
85
			touch($d_natconfdirty_path);
86
			header("Location: firewall_nat_server.php");
87
			exit;
88
		}
89
	}
90
}
91 6eb17647 Scott Ullrich
92 d88c6a9f Scott Ullrich
$pgtitle = array("Firewall","NAT","NAT Addresses");
93 6eb17647 Scott Ullrich
include("head.inc");
94
95 24f600b0 Scott Ullrich
?>
96 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
97
<?php include("fbegin.inc"); ?>
98
<form action="firewall_nat_server.php" method="post">
99
<?php if ($input_errors) print_input_errors($input_errors); ?>
100
<?php if ($savemsg) print_info_box($savemsg); ?>
101
<?php if (file_exists($d_natconfdirty_path)): ?><p>
102
<?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>
103
<?php endif; ?>
104
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
105 a8726a3d Scott Ullrich
<?php
106
	$tab_array = array();
107 183a4aae Bill Marquette
	$tab_array[0] = array("Port Forward", false, "firewall_nat.php");
108
	$tab_array[1] = array("NAT Addresses", true, "firewall_nat_server.php");
109 a8726a3d Scott Ullrich
	$tab_array[2] = array("1:1", false, "firewall_nat_1to1.php");
110
	$tab_array[3] = array("Outbound", false, "firewall_nat_out.php");
111 183a4aae Bill Marquette
	$tab_array[4] = array("Outbound Load Balancing", false, "firewall_nat_out_load_balancing.php");
112 a8726a3d Scott Ullrich
	display_top_tabs($tab_array);
113
?>
114 5b237745 Scott Ullrich
  </td></tr>
115 19ae0929 Scott Ullrich
  <tr>
116 d732f186 Bill Marquette
    <td>
117
	<div id="mainarea">
118
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
119 19ae0929 Scott Ullrich
                <tr>
120 5b237745 Scott Ullrich
                  <td width="40%" class="listhdrr">External IP address</td>
121
                  <td width="50%" class="listhdr">Description</td>
122
                  <td width="10%" class="list"></td>
123
				</tr>
124
			  <?php $i = 0; foreach ($a_snat as $natent): ?>
125 19ae0929 Scott Ullrich
                <tr>
126 b261bc51 Bill Marquette
                  <td class="listlr" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
127 5b237745 Scott Ullrich
                    <?=$natent['ipaddr'];?>
128
                  </td>
129 b261bc51 Bill Marquette
                  <td class="listbg" ondblclick="document.location='firewall_nat_server_edit.php?id=<?=$i;?>';">
130 64286300 Scott Ullrich
                    <?=htmlspecialchars($natent['descr']);?>&nbsp;
131 5b237745 Scott Ullrich
                  </td>
132 c39b8aa6 Bill Marquette
                  <td class="list" nowrap>
133
                    <table border="0" cellspacing="0" cellpadding="1">
134
                      <tr>
135 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>
136
                        <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>
137 c39b8aa6 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="2"></td>
144 c39b8aa6 Bill Marquette
                  <td class="list">
145
                    <table border="0" cellspacing="0" cellpadding="1">
146
                      <tr>
147 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>
148 c39b8aa6 Bill Marquette
                      </tr>
149
                    </table>
150
                  </td>
151
                </tr>
152 d732f186 Bill Marquette
		<tr>
153
		  <td colspan="2">
154
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
155 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>
156 d732f186 Bill Marquette
		  </td>
157
		</tr>
158
              </table>
159
	   </div>
160
	</table>
161 5b237745 Scott Ullrich
            </form>
162
<?php include("fend.inc"); ?>
163
</body>
164
</html>