Changeset 695


Ignore:
Timestamp:
Sep 19, 2014, 7:25:33 AM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Nedokončená podpora pro generování IPv6 záznamů pro DNS server.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/NetworkAddress.php

    r548 r695  
    1919  function AddressToString()
    2020  {
    21    return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
     21    return(implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));
    2222  }
    2323 
     
    5757  }
    5858}
     59
     60class NetworkAddressIPv6
     61{
     62        var $Address;
     63        var $Prefix;
     64       
     65        function __construct()
     66        {
     67                $this->Address = 0;
     68                $this->Prefix = 0;
     69        }
     70       
     71  function AddressToString()
     72  {
     73        return(inet_ntop($this->Address));
     74  }
     75 
     76  function AddressFromString($Value)
     77  {
     78        $this->Address = inet_pton($Value);
     79  }
     80       
     81}
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r659 r695  
    1717$MinimumTime = 10800;
    1818$TTL = 86400;
    19 $BaseDir = '/var/named/';
     19$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named';
     20if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
    2021$MailServer = 'centrala';
    2122
     
    5354  }
    5455
    55   // Host list
     56  // IPv4 host list
    5657  foreach($DNS['Host'] as $Host)
    5758  {
     
    6061  }
    6162
     63  // IPv6 host list
     64  foreach($DNS['Host'] as $Host)
     65  {
     66    if(strlen($Host['Name']) < 8) $Host['Name'] .= "\t";
     67    if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     68      $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n";
     69  }
     70 
    6271  // Alias list
    6372  foreach($DNS['Alias'] as $Alias)
     
    102111    fclose($File);
    103112  }
     113
     114  /*
     115  // Generate reverse DNS IPv6 records
     116  foreach($DNS['IPv6Network'] as $Network)
     117  {
     118    $Parts = explode('.', $Network);
     119    $Output = // '$ORIGIN '.$Parts[2].'.'.$Parts[1].'.'.$Parts[0].'.in-addr.arpa'."\n".
     120    '$TTL '.$DNS['TTL']."\n".
     121    "@\tIN\tSOA\t".$DNS['NameServer'][0].".\troot.".$DNS['Domain'].".  (\n".
     122    "\t\t\t\t".$DNS['Serial']."\t; serial\n".
     123    "\t\t\t\t".$DNS['Refresh']."\t; refresh\n".
     124    "\t\t\t\t".$DNS['Retry']."\t; retry\n".
     125    "\t\t\t\t".$DNS['Expire']."\t; expire\n".
     126    "\t\t\t\t".$DNS['Minimum']."\t; minimum\n".
     127    "\t\t\t\t)\n";
     128    foreach($DNS['ReverseNameServer'] as $NameServer)
     129    {
     130      if(substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])
     131        $Output .= "@\tIN\tNS\t".$NameServer.".\n";
     132      else $Output .= "\tIN\tNS\t".$NameServer.".\n";
     133    }
     134    foreach($DNS['Host'] as $Host)
     135    if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
     136    if(substr($Host['IPv6'], 0, strlen($Network)) == $Network)
     137    {
     138        $Remaining = substr($Host['IPv6'], strlen($Network));
     139      $Remaining = explode(':', $Remaining);
     140      foreach($Remaining)
     141      $Remaining = array_reverse($Remaining);
     142           
     143      $Host['Name'] = strtolower($Host['Name']);
     144      $Output .= implode(':', $Remaining)."\tIN\tPTR\t".$Host['Name'].".".$DNS['Domain'].".\n";
     145    }
     146    $Reverse = implode(':', array_reverse(explode(':', $Network)));   
     147    $File = fopen($DNS['BaseDir'].$Reverse.'.ipv6.arpa.zone', 'w+');
     148    fputs($File, $Output);
     149    //echo($Output);
     150    fclose($File);
     151  }
     152  */
    104153}
    105154
     
    114163  'TTL' => $TTL,
    115164  'Description' => 'ZdechovNET community network',
    116   'BaseDir' => '/var/named/internal/',
     165  'BaseDir' => $BaseDir.'/internal/',
    117166  'MailServer' => array('centrala.'.$BaseDomain),
    118167  'NameServer' => array('centrala.'.$BaseDomain, 'mozek.'.$BaseDomain),
     
    120169  'Host' => array(),
    121170  'Alias' => array(),
    122   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'),
     171  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68',
     172                '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'),
     173        'IPv6Network' => array('2001:470:9ab9:1'),
    123174);
    124175
     
    130181  $Name = $Interface['DeviceName'];
    131182  if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    132   $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']);
    133 }
    134 
    135 // External records in internal server
     183  $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'],
     184    'IPv6' => $Interface['IPv6']);
     185}
     186
     187// External IPv4 records in internal server
    136188$DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '.
    137189  'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP <> ""');
     
    173225  'TTL' => $TTL,
    174226  'Description' => 'ZdechovNET community network',
    175   'BaseDir' => '/var/named/external/',
     227  'BaseDir' => $BaseDir.'/external/',
    176228  'MailServer' => array('centrala.'.$BaseDomain),
    177229  'NameServer' => array('gw-hajda.inext.cz', 'ns0.xname.org', 'ns2.afraid.org'),
     
    180232  'Alias' => array(),
    181233  'Network' => array('81.2.194', '193.86.238', '212.111.4', '77.92.221'),
     234        'IPv6Network' => array('2001:470:9ab9:1'),
    182235);
    183236
     
    188241  $Name = $Interface['DeviceName'];
    189242  if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    190   $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP']);
     243  $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'],
     244    'IPv6' => $Interface['IPv6']);
    191245}
    192246
     
    211265  'TTL' => 86400,
    212266  'Description' => 'ZdechovNET community network',
    213   'BaseDir' => '/var/named/czfree/',
     267  'BaseDir' => $BaseDir.'/czfree/',
    214268  'MailServer' => array('centrala.'.$BaseDomain),
    215269  'NameServer' => array('centrala.'.$BaseDomain, 'mozek'.$BaseDomain),
     
    217271  'Host' => array(),
    218272  'Alias' => array(),
    219   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
     273  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67',
     274    '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
     275        'IPv6Network' => array(),
    220276);
    221277
     
    249305  'TTL' => 86400,
    250306  'Description' => 'ZdechovNET community network',
    251   'BaseDir' => '/var/named/internal/',
     307  'BaseDir' => $BaseDir.'/internal/',
    252308  'MailServer' => array('centrala.'.$BaseDomain),
    253309  'NameServer' => array('centrala.'.$BaseDomain, 'mozek.'.$BaseDomain),
     
    255311  'Host' => array(),
    256312  'Alias' => array(),
    257   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
     313  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67',
     314        '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
     315        'IPv6Network' => array(),
    258316);
    259317
Note: See TracChangeset for help on using the changeset viewer.