Project

General

Profile

Download (3.49 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php -f
2
<?php
3
/*
4
	rc.initial.setlanip
5
	part of m0n0wall (http://m0n0.ch/wall)
6 bbc3533f Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 bbc3533f 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 bbc3533f 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 bbc3533f 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 bbc3533f 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
	/* parse the configuration and include all functions used below */
33
	require_once("config.inc");
34
	require_once("functions.inc");
35 bbc3533f Scott Ullrich
36 5b237745 Scott Ullrich
	$fp = fopen('php://stdin', 'r');
37 bbc3533f Scott Ullrich
38 5b237745 Scott Ullrich
	do {
39
		echo "\nEnter the new LAN IP address: ";
40
		$lanip = chop(fgets($fp));
41
		if ($lanip === "") {
42
			exit(0);
43
		}
44
	} while (!is_ipaddr($lanip));
45
46
	echo "\nSubnet masks are entered as bit counts (as in CIDR notation) in m0n0wall.\n";
47
	echo "e.g. 255.255.255.0 = 24\n";
48
	echo "     255.255.0.0   = 16\n";
49
	echo "     255.0.0.0     = 8\n\n";
50 bbc3533f Scott Ullrich
51 5b237745 Scott Ullrich
	do {
52
		echo "Enter the new LAN subnet bit count: ";
53
		$lanbits = chop(fgets($fp));
54
		if ($lanbits === "") {
55
			exit(0);
56
		}
57
	} while (!is_numeric($lanbits) || ($lanbits < 1) || ($lanbits > 31));
58 bbc3533f Scott Ullrich
59 5b237745 Scott Ullrich
	$config['interfaces']['lan']['ipaddr'] = $lanip;
60
	$config['interfaces']['lan']['subnet'] = $lanbits;
61 bbc3533f Scott Ullrich
62
	echo "\nDo you want to enable the DHCP server on LAN [y|n]?  ";
63
64 5b237745 Scott Ullrich
	if (strcasecmp(chop(fgets($fp)), "y") == 0) {
65
		do {
66
			echo "Enter the start address of the client address range: ";
67
			$dhcpstartip = chop(fgets($fp));
68
			if ($dhcpstartip === "") {
69
				exit(0);
70
			}
71
		} while (!is_ipaddr($dhcpstartip));
72 bbc3533f Scott Ullrich
73 5b237745 Scott Ullrich
		do {
74
			echo "Enter the end address of the client address range: ";
75
			$dhcpendip = chop(fgets($fp));
76
			if ($dhcpendip === "") {
77
				exit(0);
78
			}
79
		} while (!is_ipaddr($dhcpendip));
80 bbc3533f Scott Ullrich
81 5b237745 Scott Ullrich
		$config['dhcpd']['lan']['enable'] = true;
82
		$config['dhcpd']['lan']['range']['from'] = $dhcpstartip;
83
		$config['dhcpd']['lan']['range']['to'] = $dhcpendip;
84
	} else {
85
		unset($config['dhcpd']['lan']['enable']);
86
	}
87 bbc3533f Scott Ullrich
88 5b237745 Scott Ullrich
	if ($config['system']['webgui']['protocol'] == "https") {
89 bbc3533f Scott Ullrich
90 5b237745 Scott Ullrich
		echo "\nDo you want to revert to HTTP as the webGUI protocol? (y/n) ";
91 bbc3533f Scott Ullrich
92 5b237745 Scott Ullrich
		if (strcasecmp(chop(fgets($fp)), "y") == 0)
93
			$config['system']['webgui']['protocol'] = "http";
94
	}
95 bbc3533f Scott Ullrich
96 5b237745 Scott Ullrich
	if (isset($config['system']['webgui']['noantilockout'])) {
97
		echo "\nNote: the anti-lockout rule on LAN has been re-enabled.\n";
98
		unset($config['system']['webgui']['noantilockout']);
99
	}
100 bbc3533f Scott Ullrich
101 5b237745 Scott Ullrich
	write_config();
102
	interfaces_lan_configure();
103 bbc3533f Scott Ullrich
104 5b237745 Scott Ullrich
	echo <<<EOD
105 bbc3533f Scott Ullrich
106 5b237745 Scott Ullrich
The LAN IP address has been set to $lanip/$lanbits.
107
You can now access the webGUI by opening the following URL
108
in your browser:
109
110
http://$lanip/
111
112
Press ENTER to continue.
113
114
EOD;
115
116
	fgets($fp);
117
?>