Project

General

Profile

Download (3.54 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php -f
2
<?php
3
/* $Id$ */
4
/*
5
	rc.initial.setlanip
6
	part of m0n0wall (http://m0n0.ch/wall)
7

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

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

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

    
17
	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

    
21
	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

    
37
	$fp = fopen('php://stdin', 'r');
38

    
39
	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
	echo "\nSubnet masks are entered as bit counts (as in CIDR notation) in pfSense.\n";
48
	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

    
52
	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

    
60
	$config['interfaces']['lan']['ipaddr'] = $lanip;
61
	$config['interfaces']['lan']['subnet'] = $lanbits;
62

    
63
	echo "\nDo you want to enable the DHCP server on LAN [y|n]?  ";
64

    
65
	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

    
74
		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

    
82
		$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

    
89
	if ($config['system']['webgui']['protocol'] == "https") {
90

    
91
		echo "\nDo you want to revert to HTTP as the webGUI protocol? (y/n) ";
92

    
93
		if (strcasecmp(chop(fgets($fp)), "y") == 0)
94
			$config['system']['webgui']['protocol'] = "http";
95
	}
96

    
97
	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

    
102
	write_config("LAN IP configuration from console menu");
103
	interfaces_lan_configure();
104

    
105
	echo <<<EOD
106

    
107
The LAN IP address has been set to $lanip/$lanbits.
108
You can now access the webGUI by opening the following URL
109
in your web browser:
110

    
111
http://$lanip/
112

    
113
Press ENTER to continue.
114

    
115
EOD;
116

    
117
	fgets($fp);
118
?>
(41-41/63)