Project

General

Profile

« Previous | Next » 

Revision 045c9cc9

Added by Scott Ullrich over 15 years ago

Combine PPTP Server subnet and clients. Code imported from m0n0wall. Ticket #139

View differences:

etc/inc/vpn.inc
976 976
				return 1;
977 977
			}
978 978

  
979
			$mpdconf =<<<EOD
979
			$mpdconf = <<<EOD
980 980
pptpd:
981 981

  
982 982
EOD;
983 983

  
984
			for ($i = 0; $i < $pptpdcfg['n_pptp_units']; $i++) {
984
			for ($i = 0; $i < $g['n_pptp_units']; $i++) {
985 985
				$mpdconf .= "	load pt{$i}\n";
986 986
			}
987 987

  
988
			for ($i = 0; $i < $pptpdcfg['n_pptp_units']; $i++) {
988
			for ($i = 0; $i < $g['n_pptp_units']; $i++) {
989 989

  
990 990
				$clientip = long2ip(ip2long($pptpdcfg['remoteip']) + $i);
991
				$ngif = "ng" . ($i+1);
991 992

  
992
				if(isset($pptpdcfg['radius']['radiusissueips']) && isset($pptpdcfg['radius']['server']['enable'])) {
993
					$isssue_ip_type = "set ipcp ranges {$pptpdcfg['localip']}/32 0.0.0.0/0";
994
				} else {
995
					$isssue_ip_type = "set ipcp ranges {$pptpdcfg['localip']}/32 {$clientip}/32";
996
				}
997

  
998
				$mpdconf .=<<<EOD
993
				$mpdconf .= <<<EOD
999 994

  
1000 995
pt{$i}:
1001
	new pt{$i} pt{$i}
1002
	{$isssue_ip_type}
996
	new -i {$ngif} pt{$i} pt{$i}
997
	set ipcp ranges {$pptpdcfg['localip']}/32 {$clientip}/32
1003 998
	load pts
1004 999

  
1005 1000
EOD;
usr/local/www/vpn_pptp.php
100 100
		}
101 101
		
102 102
		if (!$input_errors) {	
103
			$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $_POST['pptp_subnet']);
103
			$_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $g['pptp_subnet']);
104 104
			$subnet_start = ip2long($_POST['remoteip']);
105
			$subnet_end = ip2long($_POST['remoteip']) + $_POST['n_pptp_units'] - 1;
105
			$subnet_end = ip2long($_POST['remoteip']) + $g['n_pptp_units'] - 1;
106 106
						
107 107
			if ((ip2long($_POST['localip']) >= $subnet_start) && 
108 108
			    (ip2long($_POST['localip']) <= $subnet_end)) {
109 109
				$input_errors[] = "The specified server address lies in the remote subnet.";	
110 110
			}
111
			if ($_POST['localip'] == get_interface_ip("lan")) {
111
			if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
112 112
				$input_errors[] = "The specified server address is equal to the LAN interface address.";	
113 113
			}
114 114
		}
......
344 344
                    Specify the starting address for the client IP subnet.<br>
345 345
                </tr>
346 346
                <tr> 
347
                  <td width="22%" valign="top" class="vncellreq">Subnet netmask</td>
348
                  <td width="78%" class="vtable">
349
		    <select id="pptp_subnet" name="pptp_subnet">
350
		    <?php
351
		     for($x=0; $x<33; $x++) {
352
			if($x == $pconfig['pptp_subnet'])
353
				$SELECTED = " SELECTED";
354
			else
355
				$SELECTED = "";
356
			echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";			
357
		     }
358
		    ?>
359
		    </select>
360
		    <br>Hint: 24 is 255.255.255.0
347
                  <td width="22%" valign="top" class="vncellreq">Max. concurrent 
348
                    connections</td>
349
                  <td width="78%" class="vtable"> 
350
                    <?=$g['n_pptp_units'];?>
361 351
                  </td>
362
		</tr>
363 352
                <tr> 
364
                  <td width="22%" valign="top" class="vncellreq">No. PPTP users</td>
365
                  <td width="78%" class="vtable">
366
		    <select id="n_pptp_units" name="n_pptp_units">
367
		    <?php
368
		     for($x=0; $x<255; $x++) {
369
			if($x == $pconfig['n_pptp_units'])
370
				$SELECTED = " SELECTED";
371
			else
372
				$SELECTED = "";
373
			echo "<option value=\"{$x}\"{$SELECTED}>{$x}</option>\n";			
374
		     }
375
		    ?>
376
		    </select>
377
		    <br>Hint: 10 is TEN pptp clients
378
                  </td>
353
                  <td width="22%" valign="top" class="vncellreq">Server address</td>
354
                  <td width="78%" class="vtable"> 
355
                    <?=$mandfldhtml;?><input name="localip" type="text" class="formfld" id="localip" size="20" value="<?=htmlspecialchars($pconfig['localip']);?>"> 
356
                    <br>
357
                    Enter the IP address the PPTP server should use on its side 
358
                    for all clients.</td>
359
                </tr>
360
                <tr> 
361
                  <td width="22%" valign="top" class="vncellreq">Remote address 
362
                    range</td>
363
                  <td width="78%" class="vtable"> 
364
                    <?=$mandfldhtml;?><input name="remoteip" type="text" class="formfld" id="remoteip" size="20" value="<?=htmlspecialchars($pconfig['remoteip']);?>">
365
                    / 
366
                    <?=$g['pptp_subnet'];?>
367
                    <br>
368
                    Specify the starting address for the client IP address subnet.<br>
369
                    The PPTP server will assign 
370
                    <?=$g['n_pptp_units'];?>
371
                    addresses, starting at the address entered above, to clients.</td>
379 372
                </tr>
380 373
                <tr> 
381 374
                  <td width="22%" valign="top" class="vncell">PPTP DNS Servers</td>
382 375
                  <td width="78%" class="vtable"> 
383 376
                    <?=$mandfldhtml;?><input name="pptp_dns1" type="text" class="formfld unknown" id="pptp_dns1" size="20" value="<?=htmlspecialchars($pconfig['pptp_dns1']);?>">
384 377
                    <br>
385
			<input name="pptp_dns2" type="text" class="formfld unknown" id="pptp_dns2" size="20" value="<?=htmlspecialchars($pconfig['pptp_dns2']);?>">
378
					<input name="pptp_dns2" type="text" class="formfld unknown" id="pptp_dns2" size="20" value="<?=htmlspecialchars($pconfig['pptp_dns2']);?>">
386 379
                    <br>
387

  
388 380
                   primary and secondary DNS servers assigned to PPTP clients<br>
389 381
                </tr>
390 382
                <tr> 

Also available in: Unified diff