Project

General

Profile

Download (7.75 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
    firewall_nat_out.php
5
    Copyright (C) 2004 Scott Ullrich
6
    All rights reserved.
7

    
8
    originally part of m0n0wall (http://m0n0.ch/wall)
9
    Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
    All rights reserved.
11

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

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

    
18
    2. Redistributions in binary form must reproduce the above copyright
19
       notice, this list of conditions and the following disclaimer in the
20
       documentation and/or other materials provided with the distribution.
21

    
22
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
    POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
require("guiconfig.inc");
35

    
36
if (!is_array($config['nat']['advancedoutbound']['rule']))
37
    $config['nat']['advancedoutbound']['rule'] = array();
38

    
39
$a_out = &$config['nat']['advancedoutbound']['rule'];
40
nat_out_rules_sort();
41

    
42
if ($_POST) {
43

    
44
    $pconfig = $_POST;
45

    
46
    $config['nat']['advancedoutbound']['enable'] = ($_POST['enable']) ? true : false;
47
    write_config();
48

    
49
    $retval = 0;
50

    
51
    if (!file_exists($d_sysrebootreqd_path)) {
52
		config_lock();
53
        $retval |= filter_configure();
54
		config_unlock();
55
    }
56
    $savemsg = get_std_save_message($retval);
57

    
58
    if ($retval == 0) {
59
        if (file_exists($d_natconfdirty_path))
60
            unlink($d_natconfdirty_path);
61
        if (file_exists($d_filterconfdirty_path))
62
            unlink($d_filterconfdirty_path);
63
    }
64
}
65

    
66
if ($_GET['act'] == "del") {
67
    if ($a_out[$_GET['id']]) {
68
        unset($a_out[$_GET['id']]);
69
        write_config();
70
        touch($d_natconfdirty_path);
71
        header("Location: firewall_nat_out.php");
72
        exit;
73
    }
74
}
75
?>
76
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
77
<html>
78
<head>
79
<title><?=gentitle("Firewall: NAT");?></title>
80
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
81
<link href="gui.css" rel="stylesheet" type="text/css">
82
</head>
83

    
84
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
85
<?php include("fbegin.inc"); ?>
86
<p class="pgtitle">Firewall: NAT</p>
87
<form action="firewall_nat_out.php" method="post">
88
<?php if ($savemsg) print_info_box($savemsg); ?>
89
<?php if (file_exists($d_natconfdirty_path)): ?><p>
90
<?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>
91
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
92
<?php endif; ?>
93
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
94
  <ul id="tabnav">
95
    <li class="tabinact"><a href="firewall_nat.php">Inbound</a></li>
96
    <li class="tabinact"><a href="firewall_nat_server.php">Server NAT</a></li>
97
    <li class="tabinact"><a href="firewall_nat_1to1.php">1:1</a></li>
98
    <li class="tabact">Outbound</li>
99
    <li class="tabinact"><a href="firewall_nat_out_load_balancing.php">Outbound Load Balancing</a></li>
100
  </ul>
101
  </td></tr>
102
  <tr>
103
    <td class="tabcont">
104
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
105
                <tr>
106
                  <td class="vtable"><p>
107
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if (isset($config['nat']['advancedoutbound']['enable'])) echo "checked";?>>
108
                      <strong>Enable advanced outbound NAT<br>
109
                      </strong></p>
110
                  </td>
111
                </tr>
112
                <tr>
113
                  <td> <input name="submit" type="submit" class="formbtn" value="Save">
114
                  </td>
115
                </tr>
116
                <tr>
117
                  <td colspan="2"><p><span class="vexpl"><span class="red"><strong>Note:<br>
118
                      </strong></span>If advanced outbound NAT is enabled, no outbound NAT
119
                      rules will be automatically generated anymore. Instead, only the mappings
120
                      you specify below will be used. With advanced outbound NAT disabled,
121
                      a mapping is automatically created for each interface's subnet
122
                      (except WAN).</span> If you use target addresses other than the WAN interface's IP address, then depending on<span class="vexpl"> the way your WAN connection is setup, you may also need <a href="services_proxyarp.php">proxy ARP</a>.</span><br>
123
                      <br>
124
                      You may enter your own mappings below.</p>
125
                    </td>
126
                </tr>
127
              </table>
128
              &nbsp;<br>
129
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
130
                <tr>
131
                  <td width="10%" class="listhdrr">Interface</td>
132
                  <td width="20%" class="listhdrr">Source</td>
133
                  <td width="20%" class="listhdrr">Destination</td>
134
                  <td width="20%" class="listhdrr">Target</td>
135
                  <td width="25%" class="listhdr">Description</td>
136
                  <td width="5%" class="list"></td>
137
                </tr>
138
              <?php $i = 0; foreach ($a_out as $natent): ?>
139
                <tr>
140
                  <td class="listlr">
141
                    <?php
142
					if (!$natent['interface'] || ($natent['interface'] == "wan"))
143
					  	echo "WAN";
144
					else
145
						htmlspecialchars($config['interfaces'][$natent['interface']]['descr']);
146
					?>
147
                  </td>
148
                  <td class="listr">
149
                    <?=$natent['source']['network'];?>
150
                  </td>
151
                  <td class="listr">
152
                    <?php
153
                      if (isset($natent['destination']['any']))
154
                          echo "*";
155
                      else {
156
                          if (isset($natent['destination']['not']))
157
                              echo "!&nbsp;";
158
                          echo $natent['destination']['network'];
159
                      }
160
                    ?>
161
                  </td>
162
                  <td class="listr">
163
                    <?php
164
                      if (!$natent['target'])
165
                          echo "*";
166
                      else
167
                          echo $natent['target'];
168
                    ?>
169
                  </td>
170
                  <td class="listbg">
171
                    <font color="#FFFFFF"><?=htmlspecialchars($natent['descr']);?>&nbsp;
172
                  </td>
173
                  <td class="list" nowrap> <a href="firewall_nat_out_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
174
                     &nbsp;<a href="firewall_nat_out.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>
175
                </tr>
176
              <?php $i++; endforeach; ?>
177
                <tr>
178
                  <td class="list" colspan="5"></td>
179
                  <td class="list"> <a href="firewall_nat_out_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
180
                </tr>
181
              </table>
182
</td>
183
  </tr>
184
</table>
185
            </form>
186
<?php include("fend.inc"); ?>
187
</body>
188
</html>
(25-25/90)