1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
interfaces_lan.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
|
$lancfg = &$config['interfaces']['lan'];
|
35
|
$optcfg = &$config['interfaces']['lan'];
|
36
|
$pconfig['ipaddr'] = $config['interfaces']['lan']['ipaddr'];
|
37
|
$pconfig['subnet'] = $config['interfaces']['lan']['subnet'];
|
38
|
|
39
|
/* Wireless interface? */
|
40
|
if (isset($optcfg['wireless'])) {
|
41
|
require("interfaces_wlan.inc");
|
42
|
wireless_config_init();
|
43
|
}
|
44
|
|
45
|
if ($_POST) {
|
46
|
|
47
|
unset($input_errors);
|
48
|
$pconfig = $_POST;
|
49
|
|
50
|
/* input validation */
|
51
|
$reqdfields = explode(" ", "ipaddr subnet");
|
52
|
$reqdfieldsn = explode(",", "IP address,Subnet bit count");
|
53
|
|
54
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
55
|
|
56
|
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
|
57
|
$input_errors[] = "A valid IP address must be specified.";
|
58
|
}
|
59
|
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
|
60
|
$input_errors[] = "A valid subnet bit count must be specified.";
|
61
|
}
|
62
|
|
63
|
/* Wireless interface? */
|
64
|
if (isset($optcfg['wireless'])) {
|
65
|
$wi_input_errors = wireless_config_post();
|
66
|
if ($wi_input_errors) {
|
67
|
$input_errors = array_merge($input_errors, $wi_input_errors);
|
68
|
}
|
69
|
}
|
70
|
|
71
|
if (!$input_errors) {
|
72
|
$config['interfaces']['lan']['ipaddr'] = $_POST['ipaddr'];
|
73
|
$config['interfaces']['lan']['subnet'] = $_POST['subnet'];
|
74
|
|
75
|
$dhcpd_was_enabled = 0;
|
76
|
if (isset($config['dhcpd']['enable'])) {
|
77
|
unset($config['dhcpd']['enable']);
|
78
|
$dhcpd_was_enabled = 1;
|
79
|
}
|
80
|
|
81
|
write_config();
|
82
|
touch($d_sysrebootreqd_path);
|
83
|
|
84
|
$savemsg = get_std_save_message(0);
|
85
|
|
86
|
if ($dhcpd_was_enabled)
|
87
|
$savemsg .= "<br>Note that the DHCP server has been disabled.<br>Please review its configuration " .
|
88
|
"and enable it again prior to rebooting.";
|
89
|
}
|
90
|
}
|
91
|
?>
|
92
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
93
|
<html>
|
94
|
<head>
|
95
|
<title><?=gentitle("Interfaces: LAN");?></title>
|
96
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
97
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
98
|
<script language="JavaScript">
|
99
|
<!--
|
100
|
function gen_bits(ipaddr) {
|
101
|
if (ipaddr.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
|
102
|
var adr = ipaddr.split(/\./);
|
103
|
if (adr[0] > 255 || adr[1] > 255 || adr[2] > 255 || adr[3] > 255)
|
104
|
return "";
|
105
|
if (adr[0] == 0 && adr[1] == 0 && adr[2] == 0 && adr[3] == 0)
|
106
|
return "";
|
107
|
|
108
|
if (adr[0] <= 127)
|
109
|
return "8";
|
110
|
else if (adr[0] <= 191)
|
111
|
return "16";
|
112
|
else
|
113
|
return "24";
|
114
|
}
|
115
|
else
|
116
|
return "";
|
117
|
}
|
118
|
function ipaddr_change() {
|
119
|
document.iform.subnet.value = gen_bits(document.iform.ipaddr.value);
|
120
|
}
|
121
|
// -->
|
122
|
</script>
|
123
|
</head>
|
124
|
|
125
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
126
|
<?php include("fbegin.inc"); ?>
|
127
|
<p class="pgtitle">Interfaces: LAN</p>
|
128
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
129
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
130
|
<form action="interfaces_lan.php" method="post" name="iform" id="iform">
|
131
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
132
|
<tr>
|
133
|
<td width="22%" valign="top" class="vncellreq">IP address</td>
|
134
|
<td width="78%" class="vtable">
|
135
|
<input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
|
136
|
/
|
137
|
<select name="subnet" class="formfld" id="subnet">
|
138
|
<?php for ($i = 31; $i > 0; $i--): ?>
|
139
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['subnet']) echo "selected"; ?>>
|
140
|
<?=$i;?>
|
141
|
</option>
|
142
|
<?php endfor; ?>
|
143
|
</select></td>
|
144
|
</tr>
|
145
|
<?php /* Wireless interface? */
|
146
|
if (isset($optcfg['wireless']))
|
147
|
wireless_config_print();
|
148
|
?>
|
149
|
<tr>
|
150
|
<td width="22%" valign="top"> </td>
|
151
|
<td width="78%">
|
152
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
153
|
</td>
|
154
|
</tr>
|
155
|
<tr>
|
156
|
<td width="22%" valign="top"> </td>
|
157
|
<td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
|
158
|
</strong></span>after you click "Save", you must
|
159
|
reboot your firewall for changes to take effect. You may also
|
160
|
have to do one or more of the following steps before you can
|
161
|
access your firewall again:
|
162
|
<ul>
|
163
|
<li>change the IP address of your computer</li>
|
164
|
<li>renew its DHCP lease</li>
|
165
|
<li>access the webGUI with the new IP address</li>
|
166
|
</ul>
|
167
|
</span></td>
|
168
|
</tr>
|
169
|
</table>
|
170
|
</form>
|
171
|
<?php include("fend.inc"); ?>
|
172
|
</body>
|
173
|
</html>
|