Ignore:
Timestamp:
Mar 24, 2009, 7:52:02 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Poopravené konfigurační skripty ve starém umístění.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • system/generators/dhcp_routerboard.php

    r111 r172  
    11<?php
    2 include_once('/a/www/centrala/global.php');
    32
    4 // Generate DHCP server configuration
    5 /*
    6 $File = fopen('/etc/dhcpd.conf', 'w');
    7 fputs($File, "# DHCP Configuration file\n".
    8 "authoritative;\n".
    9 'option domain-name "zdechov.net";'."\n".
    10 "server-name centrala;\n".
    11 "ddns-update-style ad-hoc;\n".
    12 "default-lease-time 86400;\n".
    13 "max-lease-time 86400;\n".
    14 "ddns-hostname centrala;\n".
    15 "option domain-name-servers 192.168.0.1;\n".
    16 "#option subnet-mask 255.255.0.0;\n\n".
    17 "# nastaveni WINS serveru\n".
    18 "option netbios-name-servers 192.168.0.1;\n".
    19 "option netbios-dd-server 192.168.0.1;\n".
    20 "option netbios-node-type 8;\n".
    21 'option netbios-scope "";'."\n".
    22 "server-identifier 192.168.0.1;\n\n");
    23 */
    24 $Commands = array();
    25 //$MaxSubnet = 1;
    26 $Commands[] = '/ip dhcp-server lease { remove [find]}';
    27 for($i = 0; $i <= 5; $i++)
     3$SessionDisable = true;
     4chdir('/a/www/centrala');
     5include('global.php');
     6
     7$UserName = 'admin-ssh';
     8
     9$DbResult = $Database->query('SELECT * FROM NetworkSubnet');
     10while($Subnet = $DbResult->fetch_assoc())
    2811{
    29 /*
    30   fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n".
    31   "  range 192.168.".$i.".128 192.168.".$i.".254;\n".
    32   "  option broadcast-address 192.168.".$i.".255;\n".
    33   "  option routers 192.168.".$i.".1;\n");
    34 */
    35   $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP");
    36   while($Row = $DbResult->fetch_array())
     12  //print_r($Subnet);
     13  $I = explode('.', $Subnet['AddressRange']);
     14  $I = $I[2];
     15  $Commands = array();
     16  $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}';
     17  $DbResult2 = $Database->query('SELECT * FROM hosts WHERE (IP LIKE "192.168.'.$I.'.%") AND (MAC != "00:00:00:00:00:00") ORDER BY IP');
     18  while($Host = $DbResult2->fetch_assoc())
    3719  {
    38 //    $Data = $Row['name'];
    39 //    if(strlen($Data) < 9) $Data .= "\t";
    40 //    fputs($File, "  host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n");
    41     $Commands[] = '/ip dhcp-server lease add mac-address='.$Row['MAC'].' address='.$Row['IP'].' server=dhcp'.$i.' comment='.$Row['name'];
     20    $Commands[] = '/ip dhcp-server lease add mac-address='.$Host['MAC'].' address='.$Host['IP'].' server=dhcp'.$I.' comment='.$Host['name'];
    4221  }
    43  
    44 //  fputs($File, "}\n\n");
     22  $Commands = implode(';', $Commands);
     23  $Command = '/usr/bin/ssh -l '.$UserName.' -i /root/.ssh/id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"';
     24  echo($Command."\n");
     25  $Output = '';
     26  exec($Command, $Output);
     27  print_r($Output);
     28  echo("\n");
    4529}
    46 //fclose($File);
    47 $Commands = implode(';', $Commands);
    48 $Command = '/usr/bin/ssh -l admin-ssh -i /root/.ssh/id_dsa rt-hajda-0 "'.$Commands.'"';
    49 echo($Command);
    50 exec($Command, $Output);
    51 print_r($Output);
    5230
    5331?>
Note: See TracChangeset for help on using the changeset viewer.