1 | <?php
|
---|
2 |
|
---|
3 | if (isset($_SERVER['REMOTE_ADDR'])) die();
|
---|
4 | /*
|
---|
5 | include_once('../../global.php');
|
---|
6 |
|
---|
7 | // Generate DHCP server configuration
|
---|
8 | $File = fopen('/etc/dhcpd.conf', 'w');
|
---|
9 | fputs($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");
|
---|
25 | for ($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 | }
|
---|
41 | fclose($File);
|
---|
42 | */
|
---|