Project

General

Profile

Download (3.54 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php -f
2
<?php
3 1b8df11b Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	rc.initial.setlanip
6
	part of m0n0wall (http://m0n0.ch/wall)
7 bbc3533f Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 bbc3533f Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 bbc3533f Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 bbc3533f Scott Ullrich
17 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 bbc3533f Scott Ullrich
21 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
	/* parse the configuration and include all functions used below */
34
	require_once("config.inc");
35
	require_once("functions.inc");
36 bbc3533f Scott Ullrich
37 5b237745 Scott Ullrich
	$fp = fopen('php://stdin', 'r');
38 bbc3533f Scott Ullrich
39 5b237745 Scott Ullrich
	do {
40
		echo "\nEnter the new LAN IP address: ";
41
		$lanip = chop(fgets($fp));
42
		if ($lanip === "") {
43
			exit(0);
44
		}
45
	} while (!is_ipaddr($lanip));
46
47 2ad0b6d2 Colin Smith
	echo "\nSubnet masks are entered as bit counts (as in CIDR notation) in pfSense.\n";
48 5b237745 Scott Ullrich
	echo "e.g. 255.255.255.0 = 24\n";
49
	echo "     255.255.0.0   = 16\n";
50
	echo "     255.0.0.0     = 8\n\n";
51 bbc3533f Scott Ullrich
52 5b237745 Scott Ullrich
	do {
53
		echo "Enter the new LAN subnet bit count: ";
54
		$lanbits = chop(fgets($fp));
55
		if ($lanbits === "") {
56
			exit(0);
57
		}
58
	} while (!is_numeric($lanbits) || ($lanbits < 1) || ($lanbits > 31));
59 bbc3533f Scott Ullrich
60 5b237745 Scott Ullrich
	$config['interfaces']['lan']['ipaddr'] = $lanip;
61
	$config['interfaces']['lan']['subnet'] = $lanbits;
62 bbc3533f Scott Ullrich
63
	echo "\nDo you want to enable the DHCP server on LAN [y|n]?  ";
64
65 5b237745 Scott Ullrich
	if (strcasecmp(chop(fgets($fp)), "y") == 0) {
66
		do {
67
			echo "Enter the start address of the client address range: ";
68
			$dhcpstartip = chop(fgets($fp));
69
			if ($dhcpstartip === "") {
70
				exit(0);
71
			}
72
		} while (!is_ipaddr($dhcpstartip));
73 bbc3533f Scott Ullrich
74 5b237745 Scott Ullrich
		do {
75
			echo "Enter the end address of the client address range: ";
76
			$dhcpendip = chop(fgets($fp));
77
			if ($dhcpendip === "") {
78
				exit(0);
79
			}
80
		} while (!is_ipaddr($dhcpendip));
81 bbc3533f Scott Ullrich
82 5b237745 Scott Ullrich
		$config['dhcpd']['lan']['enable'] = true;
83
		$config['dhcpd']['lan']['range']['from'] = $dhcpstartip;
84
		$config['dhcpd']['lan']['range']['to'] = $dhcpendip;
85
	} else {
86
		unset($config['dhcpd']['lan']['enable']);
87
	}
88 bbc3533f Scott Ullrich
89 5b237745 Scott Ullrich
	if ($config['system']['webgui']['protocol'] == "https") {
90 bbc3533f Scott Ullrich
91 5b237745 Scott Ullrich
		echo "\nDo you want to revert to HTTP as the webGUI protocol? (y/n) ";
92 bbc3533f Scott Ullrich
93 5b237745 Scott Ullrich
		if (strcasecmp(chop(fgets($fp)), "y") == 0)
94
			$config['system']['webgui']['protocol'] = "http";
95
	}
96 bbc3533f Scott Ullrich
97 5b237745 Scott Ullrich
	if (isset($config['system']['webgui']['noantilockout'])) {
98
		echo "\nNote: the anti-lockout rule on LAN has been re-enabled.\n";
99
		unset($config['system']['webgui']['noantilockout']);
100
	}
101 bbc3533f Scott Ullrich
102 5929e4c0 Bill Marquette
	write_config("LAN IP configuration from console menu");
103 5b237745 Scott Ullrich
	interfaces_lan_configure();
104 bbc3533f Scott Ullrich
105 5b237745 Scott Ullrich
	echo <<<EOD
106 bbc3533f Scott Ullrich
107 5b237745 Scott Ullrich
The LAN IP address has been set to $lanip/$lanbits.
108
You can now access the webGUI by opening the following URL
109 ca2e329a Scott Ullrich
in your web browser:
110 5b237745 Scott Ullrich
111
http://$lanip/
112
113
Press ENTER to continue.
114
115
EOD;
116
117
	fgets($fp);
118
?>