Project

General

Profile

Download (33.1 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 e2cd32df Scott Ullrich
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	interfaces_wan.php
6 c3b3cd36 Scott Ullrich
        Copyright (C) 2004 Scott Ullrich
7
	All rights reserved.
8
        
9
	originally part of m0n0wall (http://m0n0.ch/wall)
10 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12 e2cd32df Scott Ullrich
13 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15 e2cd32df Scott Ullrich
16 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18 e2cd32df Scott Ullrich
19 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22 e2cd32df Scott Ullrich
23 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
require("guiconfig.inc");
36
37
$wancfg = &$config['interfaces']['wan'];
38 8bb29531 Scott Ullrich
$optcfg = &$config['interfaces']['wan'];
39 5b237745 Scott Ullrich
40
$pconfig['username'] = $config['pppoe']['username'];
41
$pconfig['password'] = $config['pppoe']['password'];
42
$pconfig['provider'] = $config['pppoe']['provider'];
43 a23d7248 Scott Ullrich
$pconfig['pppoe_dialondemand'] = isset($config['pppoe']['ondemand']);
44 5b237745 Scott Ullrich
$pconfig['pppoe_idletimeout'] = $config['pppoe']['timeout'];
45
46
$pconfig['pptp_username'] = $config['pptp']['username'];
47
$pconfig['pptp_password'] = $config['pptp']['password'];
48
$pconfig['pptp_local'] = $config['pptp']['local'];
49
$pconfig['pptp_subnet'] = $config['pptp']['subnet'];
50
$pconfig['pptp_remote'] = $config['pptp']['remote'];
51 a23d7248 Scott Ullrich
$pconfig['pptp_dialondemand'] = isset($config['pptp']['ondemand']);
52 5b237745 Scott Ullrich
$pconfig['pptp_idletimeout'] = $config['pptp']['timeout'];
53
54
$pconfig['bigpond_username'] = $config['bigpond']['username'];
55
$pconfig['bigpond_password'] = $config['bigpond']['password'];
56
$pconfig['bigpond_authserver'] = $config['bigpond']['authserver'];
57
$pconfig['bigpond_authdomain'] = $config['bigpond']['authdomain'];
58
$pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinterval'];
59
60
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
61
62
if ($wancfg['ipaddr'] == "dhcp") {
63
	$pconfig['type'] = "DHCP";
64
} else if ($wancfg['ipaddr'] == "pppoe") {
65
	$pconfig['type'] = "PPPoE";
66
} else if ($wancfg['ipaddr'] == "pptp") {
67
	$pconfig['type'] = "PPTP";
68
} else if ($wancfg['ipaddr'] == "bigpond") {
69
	$pconfig['type'] = "BigPond";
70
} else {
71
	$pconfig['type'] = "Static";
72
	$pconfig['ipaddr'] = $wancfg['ipaddr'];
73
	$pconfig['subnet'] = $wancfg['subnet'];
74 88f66e13 Bill Marquette
	$pconfig['gateway'] = $config['system']['gateway'];
75 a23d7248 Scott Ullrich
	$pconfig['pointtopoint'] = $wancfg['pointtopoint'];
76 5b237745 Scott Ullrich
}
77
78
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
79 ff1955ee Bill Marquette
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
80 5b237745 Scott Ullrich
$pconfig['spoofmac'] = $wancfg['spoofmac'];
81
$pconfig['mtu'] = $wancfg['mtu'];
82
83
/* Wireless interface? */
84 b7f01f59 Bill Marquette
if (isset($wancfg['wireless'])) {
85 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
86
	wireless_config_init();
87
}
88
89
if ($_POST) {
90
91
	unset($input_errors);
92
	$pconfig = $_POST;
93
94
	/* input validation */
95
	if ($_POST['type'] == "Static") {
96
		$reqdfields = explode(" ", "ipaddr subnet gateway");
97
		$reqdfieldsn = explode(",", "IP address,Subnet bit count,Gateway");
98
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
99
	} else if ($_POST['type'] == "PPPoE") {
100
		if ($_POST['pppoe_dialondemand']) {
101
			$reqdfields = explode(" ", "username password pppoe_dialondemand pppoe_idletimeout");
102
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password,Dial on demand,Idle timeout value");
103
		} else {
104
			$reqdfields = explode(" ", "username password");
105
			$reqdfieldsn = explode(",", "PPPoE username,PPPoE password");
106
		}
107
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
108
	} else if ($_POST['type'] == "PPTP") {
109
		if ($_POST['pptp_dialondemand']) {
110
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
111
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address,Dial on demand,Idle timeout value");
112
		} else {
113
			$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote");
114
			$reqdfieldsn = explode(",", "PPTP username,PPTP password,PPTP local IP address,PPTP subnet,PPTP remote IP address");
115
		}
116
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
117
	} else if ($_POST['type'] == "BigPond") {
118
		$reqdfields = explode(" ", "bigpond_username bigpond_password");
119
		$reqdfieldsn = explode(",", "BigPond username,BigPond password");
120
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
121
	}
122 e2cd32df Scott Ullrich
123 4f3401e0 Bill Marquette
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
124
        $_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
125
126 5b237745 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
127
		$input_errors[] = "A valid IP address must be specified.";
128
	}
129
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
130
		$input_errors[] = "A valid subnet bit count must be specified.";
131
	}
132
	if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
133
		$input_errors[] = "A valid gateway must be specified.";
134
	}
135 a23d7248 Scott Ullrich
	if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
136
		$input_errors[] = "A valid point-to-point IP address must be specified.";
137
	}
138 5b237745 Scott Ullrich
	if (($_POST['provider'] && !is_domain($_POST['provider']))) {
139
		$input_errors[] = "The service name contains invalid characters.";
140
	}
141 a23d7248 Scott Ullrich
	if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
142 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
143
	}
144
	if (($_POST['pptp_local'] && !is_ipaddr($_POST['pptp_local']))) {
145
		$input_errors[] = "A valid PPTP local IP address must be specified.";
146
	}
147
	if (($_POST['pptp_subnet'] && !is_numeric($_POST['pptp_subnet']))) {
148
		$input_errors[] = "A valid PPTP subnet bit count must be specified.";
149
	}
150
	if (($_POST['pptp_remote'] && !is_ipaddr($_POST['pptp_remote']))) {
151
		$input_errors[] = "A valid PPTP remote IP address must be specified.";
152
	}
153 a23d7248 Scott Ullrich
	if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
154 5b237745 Scott Ullrich
		$input_errors[] = "The idle timeout value must be an integer.";
155
	}
156
	if (($_POST['bigpond_authserver'] && !is_domain($_POST['bigpond_authserver']))) {
157
		$input_errors[] = "The authentication server name contains invalid characters.";
158
	}
159
	if (($_POST['bigpond_authdomain'] && !is_domain($_POST['bigpond_authdomain']))) {
160
		$input_errors[] = "The authentication domain name contains invalid characters.";
161
	}
162
	if ($_POST['bigpond_minheartbeatinterval'] && !is_numericint($_POST['bigpond_minheartbeatinterval'])) {
163
		$input_errors[] = "The minimum heartbeat interval must be an integer.";
164
	}
165
	if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
166
		$input_errors[] = "A valid MAC address must be specified.";
167
	}
168
	if ($_POST['mtu'] && (($_POST['mtu'] < 576) || ($_POST['mtu'] > 1500))) {
169
		$input_errors[] = "The MTU must be between 576 and 1500 bytes.";
170
	}
171 e2cd32df Scott Ullrich
172 5b237745 Scott Ullrich
	/* Wireless interface? */
173 b7f01f59 Bill Marquette
	if (isset($wancfg['wireless'])) {
174 5b237745 Scott Ullrich
		$wi_input_errors = wireless_config_post();
175
		if ($wi_input_errors) {
176
			$input_errors = array_merge($input_errors, $wi_input_errors);
177
		}
178
	}
179
180
	if (!$input_errors) {
181 e2cd32df Scott Ullrich
182 5b237745 Scott Ullrich
		unset($wancfg['ipaddr']);
183
		unset($wancfg['subnet']);
184 88f66e13 Bill Marquette
		unset($config['system']['gateway']);
185 a23d7248 Scott Ullrich
		unset($wancfg['pointtopoint']);
186 5b237745 Scott Ullrich
		unset($wancfg['dhcphostname']);
187
		unset($config['pppoe']['username']);
188
		unset($config['pppoe']['password']);
189
		unset($config['pppoe']['provider']);
190
		unset($config['pppoe']['ondemand']);
191
		unset($config['pppoe']['timeout']);
192
		unset($config['pptp']['username']);
193
		unset($config['pptp']['password']);
194
		unset($config['pptp']['local']);
195
		unset($config['pptp']['subnet']);
196
		unset($config['pptp']['remote']);
197
		unset($config['pptp']['ondemand']);
198
		unset($config['pptp']['timeout']);
199
		unset($config['bigpond']['username']);
200
		unset($config['bigpond']['password']);
201
		unset($config['bigpond']['authserver']);
202
		unset($config['bigpond']['authdomain']);
203
		unset($config['bigpond']['minheartbeatinterval']);
204 e2cd32df Scott Ullrich
205 5b237745 Scott Ullrich
		if ($_POST['type'] == "Static") {
206
			$wancfg['ipaddr'] = $_POST['ipaddr'];
207
			$wancfg['subnet'] = $_POST['subnet'];
208 88f66e13 Bill Marquette
			$config['system']['gateway'] = $_POST['gateway'];
209 a23d7248 Scott Ullrich
			if (isset($wancfg['ispointtopoint']))
210
				$wancfg['pointtopoint'] = $_POST['pointtopoint'];
211 5b237745 Scott Ullrich
		} else if ($_POST['type'] == "DHCP") {
212
			$wancfg['ipaddr'] = "dhcp";
213
			$wancfg['dhcphostname'] = $_POST['dhcphostname'];
214
		} else if ($_POST['type'] == "PPPoE") {
215
			$wancfg['ipaddr'] = "pppoe";
216
			$config['pppoe']['username'] = $_POST['username'];
217
			$config['pppoe']['password'] = $_POST['password'];
218
			$config['pppoe']['provider'] = $_POST['provider'];
219 a23d7248 Scott Ullrich
			$config['pppoe']['ondemand'] = $_POST['pppoe_dialondemand'] ? true : false;
220 5b237745 Scott Ullrich
			$config['pppoe']['timeout'] = $_POST['pppoe_idletimeout'];
221
		} else if ($_POST['type'] == "PPTP") {
222
			$wancfg['ipaddr'] = "pptp";
223
			$config['pptp']['username'] = $_POST['pptp_username'];
224
			$config['pptp']['password'] = $_POST['pptp_password'];
225
			$config['pptp']['local'] = $_POST['pptp_local'];
226
			$config['pptp']['subnet'] = $_POST['pptp_subnet'];
227
			$config['pptp']['remote'] = $_POST['pptp_remote'];
228 a23d7248 Scott Ullrich
			$config['pptp']['ondemand'] = $_POST['pptp_dialondemand'] ? true : false;
229 5b237745 Scott Ullrich
			$config['pptp']['timeout'] = $_POST['pptp_idletimeout'];
230
		} else if ($_POST['type'] == "BigPond") {
231
			$wancfg['ipaddr'] = "bigpond";
232
			$config['bigpond']['username'] = $_POST['bigpond_username'];
233
			$config['bigpond']['password'] = $_POST['bigpond_password'];
234
			$config['bigpond']['authserver'] = $_POST['bigpond_authserver'];
235
			$config['bigpond']['authdomain'] = $_POST['bigpond_authdomain'];
236
			$config['bigpond']['minheartbeatinterval'] = $_POST['bigpond_minheartbeatinterval'];
237
		}
238 e2cd32df Scott Ullrich
239 001fdeea Scott Ullrich
		if($_POST['bandwidth'] <> "" and $_POST['bandwidthtype'] <> "") {
240
			$wancfg['bandwidth'] = $_POST['bandwidth'];
241
			$wancfg['bandwidthtype'] = $_POST['bandwidthtype'];
242
		} else {
243
			unset($wancfg['bandwidth']);
244
			unset($wancfg['bandwidthtype']);
245
		}
246 9ce0cacc Scott Ullrich
247 5b237745 Scott Ullrich
		$wancfg['blockpriv'] = $_POST['blockpriv'] ? true : false;
248 ff1955ee Bill Marquette
		$wancfg['blockbogons'] = $_POST['blockbogons'] ? true : false;
249 5b237745 Scott Ullrich
		$wancfg['spoofmac'] = $_POST['spoofmac'];
250
		$wancfg['mtu'] = $_POST['mtu'];
251 e2cd32df Scott Ullrich
252 5b237745 Scott Ullrich
		write_config();
253 e2cd32df Scott Ullrich
254 5b237745 Scott Ullrich
		$retval = 0;
255 c3b3cd36 Scott Ullrich
		config_lock();
256
		$retval = interfaces_wan_configure();
257
		config_unlock();
258 11a4b1a0 Scott Ullrich
259
		/* setup carp interfaces */
260
		interfaces_carp_configure();
261
	
262
		/* bring up carp interfaces */
263
		interfaces_carp_bringup();		
264
			
265 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
266
	}
267
}
268 7f43ca88 Scott Ullrich
269
$pgtitle = "Interfaces: WAN";
270
include("head.inc");
271
272 5b237745 Scott Ullrich
?>
273 7f43ca88 Scott Ullrich
274 5b237745 Scott Ullrich
<script language="JavaScript">
275
<!--
276
function enable_change(enable_change) {
277
	if (document.iform.pppoe_dialondemand.checked || enable_change) {
278
		document.iform.pppoe_idletimeout.disabled = 0;
279
	} else {
280
		document.iform.pppoe_idletimeout.disabled = 1;
281
	}
282
}
283
284
function enable_change_pptp(enable_change_pptp) {
285
	if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
286
		document.iform.pptp_idletimeout.disabled = 0;
287
		document.iform.pptp_local.disabled = 0;
288
		document.iform.pptp_remote.disabled = 0;
289
	} else {
290
		document.iform.pptp_idletimeout.disabled = 1;
291
	}
292
}
293
294
function type_change(enable_change,enable_change_pptp) {
295
	switch (document.iform.type.selectedIndex) {
296
		case 0:
297
			document.iform.username.disabled = 1;
298
			document.iform.password.disabled = 1;
299
			document.iform.provider.disabled = 1;
300
			document.iform.pppoe_dialondemand.disabled = 1;
301
			document.iform.pppoe_idletimeout.disabled = 1;
302
			document.iform.ipaddr.disabled = 0;
303
			document.iform.subnet.disabled = 0;
304
			document.iform.gateway.disabled = 0;
305
			document.iform.pptp_username.disabled = 1;
306
			document.iform.pptp_password.disabled = 1;
307
			document.iform.pptp_local.disabled = 1;
308
			document.iform.pptp_subnet.disabled = 1;
309
			document.iform.pptp_remote.disabled = 1;
310
			document.iform.pptp_dialondemand.disabled = 1;
311
			document.iform.pptp_idletimeout.disabled = 1;
312
			document.iform.bigpond_username.disabled = 1;
313
			document.iform.bigpond_password.disabled = 1;
314
			document.iform.bigpond_authserver.disabled = 1;
315
			document.iform.bigpond_authdomain.disabled = 1;
316
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
317
			document.iform.dhcphostname.disabled = 1;
318
			break;
319
		case 1:
320
			document.iform.username.disabled = 1;
321
			document.iform.password.disabled = 1;
322
			document.iform.provider.disabled = 1;
323
			document.iform.pppoe_dialondemand.disabled = 1;
324
			document.iform.pppoe_idletimeout.disabled = 1;
325
			document.iform.ipaddr.disabled = 1;
326
			document.iform.subnet.disabled = 1;
327
			document.iform.gateway.disabled = 1;
328
			document.iform.pptp_username.disabled = 1;
329
			document.iform.pptp_password.disabled = 1;
330
			document.iform.pptp_local.disabled = 1;
331
			document.iform.pptp_subnet.disabled = 1;
332
			document.iform.pptp_remote.disabled = 1;
333
			document.iform.pptp_dialondemand.disabled = 1;
334
			document.iform.pptp_idletimeout.disabled = 1;
335
			document.iform.bigpond_username.disabled = 1;
336
			document.iform.bigpond_password.disabled = 1;
337
			document.iform.bigpond_authserver.disabled = 1;
338
			document.iform.bigpond_authdomain.disabled = 1;
339
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
340
			document.iform.dhcphostname.disabled = 0;
341
			break;
342
		case 2:
343
			document.iform.username.disabled = 0;
344
			document.iform.password.disabled = 0;
345
			document.iform.provider.disabled = 0;
346
			document.iform.pppoe_dialondemand.disabled = 0;
347
			if (document.iform.pppoe_dialondemand.checked || enable_change) {
348
				document.iform.pppoe_idletimeout.disabled = 0;
349
			} else {
350
				document.iform.pppoe_idletimeout.disabled = 1;
351
			}
352
			document.iform.ipaddr.disabled = 1;
353
			document.iform.subnet.disabled = 1;
354
			document.iform.gateway.disabled = 1;
355
			document.iform.pptp_username.disabled = 1;
356
			document.iform.pptp_password.disabled = 1;
357
			document.iform.pptp_local.disabled = 1;
358
			document.iform.pptp_subnet.disabled = 1;
359
			document.iform.pptp_remote.disabled = 1;
360
			document.iform.pptp_dialondemand.disabled = 1;
361
			document.iform.pptp_idletimeout.disabled = 1;
362
			document.iform.bigpond_username.disabled = 1;
363
			document.iform.bigpond_password.disabled = 1;
364
			document.iform.bigpond_authserver.disabled = 1;
365
			document.iform.bigpond_authdomain.disabled = 1;
366
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
367
			document.iform.dhcphostname.disabled = 1;
368
			break;
369
		case 3:
370
			document.iform.username.disabled = 1;
371
			document.iform.password.disabled = 1;
372
			document.iform.provider.disabled = 1;
373
			document.iform.pppoe_dialondemand.disabled = 1;
374
			document.iform.pppoe_idletimeout.disabled = 1;
375
			document.iform.ipaddr.disabled = 1;
376
			document.iform.subnet.disabled = 1;
377
			document.iform.gateway.disabled = 1;
378
			document.iform.pptp_username.disabled = 0;
379
			document.iform.pptp_password.disabled = 0;
380
			document.iform.pptp_local.disabled = 0;
381
			document.iform.pptp_subnet.disabled = 0;
382
			document.iform.pptp_remote.disabled = 0;
383
			document.iform.pptp_dialondemand.disabled = 0;
384
			if (document.iform.pptp_dialondemand.checked || enable_change_pptp) {
385
				document.iform.pptp_idletimeout.disabled = 0;
386
			} else {
387
				document.iform.pptp_idletimeout.disabled = 1;
388
			}
389
			document.iform.bigpond_username.disabled = 1;
390
			document.iform.bigpond_password.disabled = 1;
391
			document.iform.bigpond_authserver.disabled = 1;
392
			document.iform.bigpond_authdomain.disabled = 1;
393
			document.iform.bigpond_minheartbeatinterval.disabled = 1;
394
			document.iform.dhcphostname.disabled = 1;
395
			break;
396
		case 4:
397
			document.iform.username.disabled = 1;
398
			document.iform.password.disabled = 1;
399
			document.iform.provider.disabled = 1;
400
			document.iform.pppoe_dialondemand.disabled = 1;
401
			document.iform.pppoe_idletimeout.disabled = 1;
402
			document.iform.ipaddr.disabled = 1;
403
			document.iform.subnet.disabled = 1;
404
			document.iform.gateway.disabled = 1;
405
			document.iform.pptp_username.disabled = 1;
406
			document.iform.pptp_password.disabled = 1;
407
			document.iform.pptp_local.disabled = 1;
408
			document.iform.pptp_subnet.disabled = 1;
409
			document.iform.pptp_remote.disabled = 1;
410
			document.iform.pptp_dialondemand.disabled = 1;
411
			document.iform.pptp_idletimeout.disabled = 1;
412
			document.iform.bigpond_username.disabled = 0;
413
			document.iform.bigpond_password.disabled = 0;
414
			document.iform.bigpond_authserver.disabled = 0;
415
			document.iform.bigpond_authdomain.disabled = 0;
416
			document.iform.bigpond_minheartbeatinterval.disabled = 0;
417
			document.iform.dhcphostname.disabled = 1;
418
			break;
419
	}
420
}
421
//-->
422
</script>
423
424
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
425
<?php include("fbegin.inc"); ?>
426
<p class="pgtitle">Interfaces: WAN</p>
427
<?php if ($input_errors) print_input_errors($input_errors); ?>
428
<?php if ($savemsg) print_info_box($savemsg); ?>
429
            <form action="interfaces_wan.php" method="post" name="iform" id="iform">
430
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
431 e2cd32df Scott Ullrich
                <tr>
432 5b237745 Scott Ullrich
                  <td valign="middle"><strong>Type</strong></td>
433
                  <td> <select name="type" class="formfld" id="type" onchange="type_change()">
434
                      <?php $opts = split(" ", "Static DHCP PPPoE PPTP BigPond");
435
				foreach ($opts as $opt): ?>
436 e2cd32df Scott Ullrich
                      <option <?php if ($opt == $pconfig['type']) echo "selected";?>>
437 5b237745 Scott Ullrich
                      <?=htmlspecialchars($opt);?>
438
                      </option>
439
                      <?php endforeach; ?>
440
                    </select></td>
441
                </tr>
442 e2cd32df Scott Ullrich
                <tr>
443 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="4"></td>
444
                </tr>
445 e2cd32df Scott Ullrich
                <tr>
446 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">General configuration</td>
447 5b237745 Scott Ullrich
                </tr>
448 e2cd32df Scott Ullrich
                <tr>
449 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MAC address</td>
450 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="spoofmac" type="text" class="formfld" id="spoofmac" size="30" value="<?=htmlspecialchars($pconfig['spoofmac']);?>">
451 1e694bee Scott Ullrich
		    <?php
452
			$ip = getenv('REMOTE_ADDR');
453
			$mac = `/usr/sbin/arp -an | grep {$ip} | cut -d" " -f4`;
454
			$mac = str_replace("\n","",$mac);
455
		    ?>
456
		    <a OnClick="document.forms[0].spoofmac.value='<?=$mac?>';" href="#">Copy my MAC address</a>   
457
		    <br>
458 e2cd32df Scott Ullrich
                    This field can be used to modify (&quot;spoof&quot;) the MAC
459 5b237745 Scott Ullrich
                    address of the WAN interface<br>
460
                    (may be required with some cable connections)<br>
461 e2cd32df Scott Ullrich
                    Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx
462 5b237745 Scott Ullrich
                    or leave blank</td>
463
                </tr>
464 e2cd32df Scott Ullrich
                <tr>
465 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">MTU</td>
466 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="mtu" type="text" class="formfld" id="mtu" size="8" value="<?=htmlspecialchars($pconfig['mtu']);?>">
467 5b237745 Scott Ullrich
                    <br>
468 e2cd32df Scott Ullrich
                    If you enter a value in this field, then MSS clamping for
469
                    TCP connections to the value entered above minus 40 (TCP/IP
470
                    header size) will be in effect. If you leave this field blank,
471
                    an MTU of 1492 bytes for PPPoE and 1500 bytes for all other
472 5b237745 Scott Ullrich
                    connection types will be assumed.</td>
473
                </tr>
474 e2cd32df Scott Ullrich
                <tr>
475 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
476
                </tr>
477 e2cd32df Scott Ullrich
                <tr>
478 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Static IP configuration</td>
479 5b237745 Scott Ullrich
                </tr>
480 e2cd32df Scott Ullrich
                <tr>
481 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">IP address</td>
482
                  <td class="vtable"> <input name="ipaddr" type="text" class="formfld" id="ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
483 e2cd32df Scott Ullrich
                    /
484 5b237745 Scott Ullrich
                    <select name="subnet" class="formfld" id="subnet">
485 21ab1cde Scott Ullrich
					<?php
486
					for ($i = 32; $i > 0; $i--) {
487
						if($i <> 31) {
488
							echo "<option value=\"{$i}\" ";
489
							if ($i == $pconfig['subnet']) echo "selected";
490
							echo ">" . $i . "</option>";
491
						}
492
					}
493
					?>
494 a23d7248 Scott Ullrich
                    <?php
495 21ab1cde Scott Ullrich
					/*
496 a23d7248 Scott Ullrich
                      if (isset($wancfg['ispointtopoint']))
497
                      	$snmax = 32;
498
                      else
499
                      	$snmax = 31;
500
                      for ($i = $snmax; $i > 0; $i--): ?>
501 21ab1cde Scott Ullrich
					  <?php if(i$ <> 31) ?><option value="<?=$i;?>" <?php if ($i == $pconfig['subnet']) echo "selected"; ?>><?php end if; ?>
502 5b237745 Scott Ullrich
                      <?=$i;?>
503
                      </option>
504
                      <?php endfor; ?>
505 21ab1cde Scott Ullrich
					*/
506
					?>
507 5b237745 Scott Ullrich
                    </select></td>
508 a23d7248 Scott Ullrich
                </tr><?php if (isset($wancfg['ispointtopoint'])): ?>
509 7f5b4824 Scott Ullrich
                <tr>
510 a23d7248 Scott Ullrich
                  <td valign="top" class="vncellreq">Point-to-point IP address </td>
511
                  <td class="vtable">
512
                    <input name="pointtopoint" type="text" class="formfld" id="pointtopoint" size="20" value="<?=htmlspecialchars($pconfig['pointtopoint']);?>">
513
                  </td>
514
                </tr><?php endif; ?>
515 e2cd32df Scott Ullrich
                <tr>
516 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Gateway</td>
517 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="gateway" type="text" class="formfld" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>">
518 5b237745 Scott Ullrich
                  </td>
519
                </tr>
520 e2cd32df Scott Ullrich
                <tr>
521 73c38fa2 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
522
                </tr>
523
                <tr>
524 e2cd32df Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">Bandwidth Management (Traffic Shaping)</td>
525 73c38fa2 Scott Ullrich
                </tr>
526
                <tr>
527
                  <td valign="top" class="vncell">Interface Bandwidth Speed</td>
528 9dfbadd9 Scott Ullrich
                  <td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($wancfg['bandwidth']);?>">
529 73c38fa2 Scott Ullrich
			<select name="bandwidthtype">
530 9dfbadd9 Scott Ullrich
				<option value="<?=htmlspecialchars($wancfg['bandwidthtype']);?>"><?=htmlspecialchars($wancfg['bandwidthtype']);?></option>
531 73c38fa2 Scott Ullrich
				<option value="b">bit/s</option>
532
				<option value="Kb">Kilobit/s</option>
533
				<option value="Mb">Megabit/s</option>
534
				<option value="Gb">Gigabit/s</option>
535 d09c8936 Scott Ullrich
				<option value=""></option>
536 73c38fa2 Scott Ullrich
			</select>
537
			<br> The bandwidth setting will define the speed of the interface for traffic shaping.
538
		  </td>
539
                </tr>
540 e2cd32df Scott Ullrich
                <tr>
541 9ce0cacc Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
542 e2cd32df Scott Ullrich
                </tr>
543
                <tr>
544 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">DHCP client configuration</td>
545 5b237745 Scott Ullrich
                </tr>
546 e2cd32df Scott Ullrich
                <tr>
547 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Hostname</td>
548
                  <td class="vtable"> <input name="dhcphostname" type="text" class="formfld" id="dhcphostname" size="40" value="<?=htmlspecialchars($pconfig['dhcphostname']);?>">
549
                    <br>
550 e2cd32df Scott Ullrich
                    The value in this field is sent as the DHCP client identifier
551
                    and hostname when requesting a DHCP lease. Some ISPs may require
552 5b237745 Scott Ullrich
                    this (for client identification).</td>
553
                </tr>
554 e2cd32df Scott Ullrich
                <tr>
555 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
556
                </tr>
557 e2cd32df Scott Ullrich
                <tr>
558 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPPoE configuration</td>
559 5b237745 Scott Ullrich
                </tr>
560 e2cd32df Scott Ullrich
                <tr>
561 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
562 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="username" type="text" class="formfld" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
563 5b237745 Scott Ullrich
                  </td>
564
                </tr>
565 e2cd32df Scott Ullrich
                <tr>
566 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
567 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="password" type="text" class="formfld" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
568 5b237745 Scott Ullrich
                  </td>
569
                </tr>
570 e2cd32df Scott Ullrich
                <tr>
571 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Service name</td>
572 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="provider" type="text" class="formfld" id="provider" size="20" value="<?=htmlspecialchars($pconfig['provider']);?>">
573
                    <br> <span class="vexpl">Hint: this field can usually be left
574 5b237745 Scott Ullrich
                    empty</span></td>
575
                </tr>
576 e2cd32df Scott Ullrich
                <tr>
577 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
578 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pppoe_dialondemand" type="checkbox" id="pppoe_dialondemand" value="enable" <?php if ($pconfig['pppoe_dialondemand']) echo "checked"; ?> onClick="enable_change(false)" >
579 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
580
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
581
                </tr>
582
                <tr>
583
                  <td valign="top" class="vncell">Idle timeout</td>
584
                  <td class="vtable">
585
                    <input name="pppoe_idletimeout" type="text" class="formfld" id="pppoe_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pppoe_idletimeout']);?>">
586
                    seconds<br>
587
    If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
588
                </tr>
589 e2cd32df Scott Ullrich
                <tr>
590 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
591
                </tr>
592 e2cd32df Scott Ullrich
                <tr>
593 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">PPTP configuration</td>
594 5b237745 Scott Ullrich
                </tr>
595 e2cd32df Scott Ullrich
                <tr>
596 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
597 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_username" type="text" class="formfld" id="pptp_username" size="20" value="<?=htmlspecialchars($pconfig['pptp_username']);?>">
598 5b237745 Scott Ullrich
                  </td>
599
                </tr>
600 e2cd32df Scott Ullrich
                <tr>
601 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
602 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_password" type="text" class="formfld" id="pptp_password" size="20" value="<?=htmlspecialchars($pconfig['pptp_password']);?>">
603 5b237745 Scott Ullrich
                  </td>
604
                </tr>
605 e2cd32df Scott Ullrich
                <tr>
606 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Local IP address</td>
607
                  <td class="vtable"> <input name="pptp_local" type="text" class="formfld" id="pptp_local" size="20" value="<?=htmlspecialchars($pconfig['pptp_local']);?>">
608 e2cd32df Scott Ullrich
                    /
609 5b237745 Scott Ullrich
                    <select name="pptp_subnet" class="formfld" id="pptp_subnet">
610 a23d7248 Scott Ullrich
                      <?php for ($i = 31; $i > 0; $i--): ?>
611 e2cd32df Scott Ullrich
                      <option value="<?=$i;?>" <?php if ($i == $pconfig['pptp_subnet']) echo "selected"; ?>>
612 5b237745 Scott Ullrich
                      <?=$i;?>
613
                      </option>
614
                      <?php endfor; ?>
615
                    </select></td>
616
                </tr>
617 e2cd32df Scott Ullrich
                <tr>
618 5b237745 Scott Ullrich
                  <td width="100" valign="top" class="vncellreq">Remote IP address</td>
619 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="pptp_remote" type="text" class="formfld" id="pptp_remote" size="20" value="<?=htmlspecialchars($pconfig['pptp_remote']);?>">
620 5b237745 Scott Ullrich
                  </td>
621
                </tr>
622 e2cd32df Scott Ullrich
                <tr>
623 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Dial on demand</td>
624 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="pptp_dialondemand" type="checkbox" id="pptp_dialondemand" value="enable" <?php if ($pconfig['pptp_dialondemand']) echo "checked"; ?> onClick="enable_change_pptp(false)" >
625 5b237745 Scott Ullrich
                    <strong>Enable Dial-On-Demand mode</strong><br>
626
		    This option causes the interface to operate in dial-on-demand mode, allowing you to have a <i>virtual full time</i> connection. The interface is configured, but the actual connection of the link is delayed until qualifying outgoing traffic is detected.</td>
627
                </tr>
628
                <tr>
629
                  <td valign="top" class="vncell">Idle timeout</td>
630
                  <td class="vtable">
631
                    <input name="pptp_idletimeout" type="text" class="formfld" id="pptp_idletimeout" size="8" value="<?=htmlspecialchars($pconfig['pptp_idletimeout']);?>">
632
                    seconds<br>
633
    If no qualifying outgoing packets are transmitted for the specified number of seconds, the connection is brought down. An idle timeout of zero disables this feature.</td>
634
                </tr>
635 e2cd32df Scott Ullrich
                <tr>
636 5b237745 Scott Ullrich
                  <td colspan="2" valign="top" height="16"></td>
637
                </tr>
638 e2cd32df Scott Ullrich
                <tr>
639 a23d7248 Scott Ullrich
                  <td colspan="2" valign="top" class="listtopic">BigPond Cable configuration</td>
640 5b237745 Scott Ullrich
                </tr>
641 e2cd32df Scott Ullrich
                <tr>
642 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Username</td>
643 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_username" type="text" class="formfld" id="bigpond_username" size="20" value="<?=htmlspecialchars($pconfig['bigpond_username']);?>">
644 5b237745 Scott Ullrich
                  </td>
645
                </tr>
646 e2cd32df Scott Ullrich
                <tr>
647 5b237745 Scott Ullrich
                  <td valign="top" class="vncellreq">Password</td>
648 e2cd32df Scott Ullrich
                  <td class="vtable"><input name="bigpond_password" type="text" class="formfld" id="bigpond_password" size="20" value="<?=htmlspecialchars($pconfig['bigpond_password']);?>">
649 5b237745 Scott Ullrich
                  </td>
650
                </tr>
651 e2cd32df Scott Ullrich
                <tr>
652 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication server</td>
653
                  <td class="vtable"><input name="bigpond_authserver" type="text" class="formfld" id="bigpond_authserver" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authserver']);?>">
654
                    <br>
655
                  <span class="vexpl">If this field is left empty, the default (&quot;dce-server&quot;) is used. </span></td>
656
                </tr>
657 e2cd32df Scott Ullrich
                <tr>
658 5b237745 Scott Ullrich
                  <td valign="top" class="vncell">Authentication domain</td>
659
                  <td class="vtable"><input name="bigpond_authdomain" type="text" class="formfld" id="bigpond_authdomain" size="20" value="<?=htmlspecialchars($pconfig['bigpond_authdomain']);?>">
660
                    <br>
661
                  <span class="vexpl">If this field is left empty, the domain name assigned via DHCP will be used.<br>
662
                  <br>
663
                  Note: the BigPond client implicitly sets the &quot;Allow DNS server list to be overridden by DHCP/PPP on WAN&quot; on the System: General setup page.            </span></td>
664
                </tr>
665
                <tr>
666
                  <td valign="top" class="vncell">Min. heartbeat interval</td>
667
                  <td class="vtable">
668
                    <input name="bigpond_minheartbeatinterval" type="text" class="formfld" id="bigpond_minheartbeatinterval" size="8" value="<?=htmlspecialchars($pconfig['bigpond_minheartbeatinterval']);?>">
669
                    seconds<br>
670
    Setting this to a sensible value (e.g. 60 seconds) can protect against DoS attacks. </td>
671
                </tr>
672
                <?php /* Wireless interface? */
673 b7f01f59 Bill Marquette
				if (isset($wancfg['wireless']))
674 5b237745 Scott Ullrich
					wireless_config_print();
675
				?>
676 e2cd32df Scott Ullrich
                <tr>
677 5b237745 Scott Ullrich
                  <td height="16" colspan="2" valign="top"></td>
678
                </tr>
679 e2cd32df Scott Ullrich
                <tr>
680 5b237745 Scott Ullrich
                  <td valign="middle">&nbsp;</td>
681 e2cd32df Scott Ullrich
                  <td class="vtable"> <input name="blockpriv" type="checkbox" id="blockpriv" value="yes" <?php if ($pconfig['blockpriv']) echo "checked"; ?>>
682 5b237745 Scott Ullrich
                    <strong>Block private networks</strong><br>
683 e2cd32df Scott Ullrich
                    When set, this option blocks traffic from IP addresses that
684 5b237745 Scott Ullrich
                    are reserved for private<br>
685 e2cd32df Scott Ullrich
                    networks as per RFC 1918 (10/8, 172.16/12, 192.168/16) as
686 5b237745 Scott Ullrich
                    well as loopback addresses<br>
687 e2cd32df Scott Ullrich
                    (127/8). You should generally leave this option turned on,
688 5b237745 Scott Ullrich
                    unless your WAN network<br>
689
                    lies in such a private address space, too.</td>
690
                </tr>
691 ff1955ee Bill Marquette
                <tr>
692
                  <td valign="middle">&nbsp;</td>
693
                  <td class="vtable"> <input name="blockbogons" type="checkbox" id="blockbogons" value="yes" <?php if ($pconfig['blockbogons']) echo "checked"; ?>>
694
                    <strong>Block bogon networks</strong><br>
695
                    When set, this option blocks traffic from IP addresses that
696
                    are reserved (but not RFC 1918) or not yet assigned by IANA.<br>
697
                    Bogons are prefixes that should never appear in the Internet routing table, and obviously should not appear as the source address in any packets you receive.</td>
698 e2cd32df Scott Ullrich
                <tr>
699 5b237745 Scott Ullrich
                  <td width="100" valign="top">&nbsp;</td>
700 e2cd32df Scott Ullrich
                  <td> &nbsp;<br> <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change_pptp(true)&&enable_change(true)">
701 5b237745 Scott Ullrich
                  </td>
702
                </tr>
703
              </table>
704
</form>
705
<script language="JavaScript">
706
<!--
707
type_change();
708
//-->
709
</script>
710
<?php include("fend.inc"); ?>
711
</body>
712
</html>