Project

General

Profile

Download (5.54 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	firewall_nat_1to1.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	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

    
20
	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
		if (!file_exists($d_sysrebootreqd_path)) {
47
			config_lock();
48
			$retval |= filter_configure();
49
			config_unlock();
50
		}
51
		$savemsg = get_std_save_message($retval);
52

    
53
		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
?>
72
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
73
<html>
74
<head>
75
<title><?=gentitle("Firewall: NAT");?></title>
76
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
77
<link href="gui.css" rel="stylesheet" type="text/css">
78
</head>
79

    
80
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
81
<?php include("fbegin.inc"); ?>
82
<p class="pgtitle">Firewall: NAT</p>
83
<form action="firewall_nat_1to1.php" method="post">
84
<?php if ($savemsg) print_info_box($savemsg); ?>
85
<?php if (file_exists($d_natconfdirty_path)): ?><p>
86
<?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>
87
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
88
<?php endif; ?>
89
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
90
  <ul id="tabnav">
91
    <li class="tabinact"><a href="firewall_nat.php">Inbound</a></li>
92
    <li class="tabinact"><a href="firewall_nat_server.php">Server NAT</a></li>
93
    <li class="tabact">1:1</li>
94
    <li class="tabinact"><a href="firewall_nat_out.php">Outbound</a></li>
95
    <li class="tabinact"><a href="firewall_nat_out_load_balancing.php">Outbound Load Balancing</a></li>
96
  </ul>
97
  </td></tr>
98
  <tr>
99
    <td class="tabcont">
100
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
101
                <tr>
102
				  <td width="10%" class="listhdrr">Interface</td>
103
                  <td width="20%" class="listhdrr">External IP</td>
104
                  <td width="20%" class="listhdrr">Internal IP</td>
105
                  <td width="40%" class="listhdr">Description</td>
106
                  <td width="10%" class="list"></td>
107
				</tr>
108
			  <?php $i = 0; foreach ($a_1to1 as $natent): ?>
109
                <tr>
110
				  <td class="listlr">
111
                  <?php
112
					if (!$natent['interface'] || ($natent['interface'] == "wan"))
113
						echo "WAN";
114
					else
115
						echo htmlspecialchars($config['interfaces'][$natent['interface']]['descr']);
116
				  ?>
117
                  </td>
118
                  <td class="listr">
119
                    <?php echo $natent['external'];
120
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
121
                  </td>
122
                  <td class="listr">
123
                    <?php echo $natent['internal'];
124
					if ($natent['subnet']) echo "/" . $natent['subnet']; ?>
125
                  </td>
126
                  <td class="listbg">
127
                    <font color="#ffffff"><?=htmlspecialchars($natent['descr']);?>&nbsp;
128
                  </td>
129
                  <td class="list" nowrap> <a href="firewall_nat_1to1_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
130
                     &nbsp;<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>
131
				</tr>
132
			  <?php $i++; endforeach; ?>
133
                <tr>
134
                  <td class="list" colspan="4"></td>
135
                  <td class="list"> <a href="firewall_nat_1to1_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
136
				</tr>
137
              </table>
138
			  			        <p><span class="vexpl"><span class="red"><strong>Note:<br>
139
                      </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>
140
</td>
141
</tr>
142
</table>
143
</form>
144
<?php include("fend.inc"); ?>
145
</body>
146
</html>
(22-22/98)