source: trunk/Modules/NetworkConfigLinux/Generators/DHCP.php

Last change on this file was 873, checked in by chronos, 5 years ago
  • Modified: Improved code format.
File size: 1.3 KB
Line 
1<?php
2
3if (isset($_SERVER['REMOTE_ADDR'])) die();
4/*
5include_once('../../global.php');
6
7// Generate DHCP server configuration
8$File = fopen('/etc/dhcpd.conf', 'w');
9fputs($File, "# DHCP Configuration file\n".
10"authoritative;\n".
11'option domain-name "zdechov.net";'."\n".
12"server-name centrala;\n".
13"ddns-update-style ad-hoc;\n".
14"default-lease-time 86400;\n".
15"max-lease-time 86400;\n".
16"ddns-hostname centrala;\n".
17"option domain-name-servers 192.168.0.1;\n".
18"#option subnet-mask 255.255.0.0;\n\n".
19"# nastaveni WINS serveru\n".
20"option netbios-name-servers 192.168.0.1;\n".
21"option netbios-dd-server 192.168.0.1;\n".
22"option netbios-node-type 8;\n".
23'option netbios-scope "";'."\n".
24"server-identifier 192.168.0.1;\n\n");
25for ($i = 0; $i <= $MaxSubnet; $i++)
26{
27 fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n".
28 " range 192.168.".$i.".128 192.168.".$i.".254;\n".
29 " option broadcast-address 192.168.".$i.".255;\n".
30 " option routers 192.168.".$i.".1;\n");
31 $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP");
32 while ($Row = $DbResult->fetch_array())
33 {
34 $Data = $Row['name'];
35 if (strlen($Data) < 9) $Data .= "\t";
36 fputs($File, " host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n");
37 }
38
39 fputs($File, "}\n\n");
40}
41fclose($File);
42*/
Note: See TracBrowser for help on using the repository browser.