Ignore:
Timestamp:
Sep 28, 2014, 10:41:47 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Generování reverzních záznamů pro IPv6 DNS.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r695 r698  
    1717$MinimumTime = 10800;
    1818$TTL = 86400;
    19 $BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named';
     19$BaseDir = '/var/named';
     20//$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named';
    2021if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');
    2122$MailServer = 'centrala';
     
    6869      $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n";
    6970  }
    70  
     71
    7172  // Alias list
    7273  foreach($DNS['Alias'] as $Alias)
     
    112113  }
    113114
    114   /*
    115   // Generate reverse DNS IPv6 records
     115  // Generate reverse DNS IPv6 records
    116116  foreach($DNS['IPv6Network'] as $Network)
    117117  {
    118     $Parts = explode('.', $Network);
     118    $Parts = explode('/', $Network);
     119    $NetworkAddress = $Parts[0];
     120    $Prefix = $Parts[1];
    119121    $Output = // '$ORIGIN '.$Parts[2].'.'.$Parts[1].'.'.$Parts[0].'.in-addr.arpa'."\n".
    120122    '$TTL '.$DNS['TTL']."\n".
     
    134136    foreach($DNS['Host'] as $Host)
    135137    if(array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))
    136     if(substr($Host['IPv6'], 0, strlen($Network)) == $Network)
    137138    {
    138         $Remaining = substr($Host['IPv6'], strlen($Network));
    139       $Remaining = explode(':', $Remaining);
    140       foreach($Remaining)
    141       $Remaining = array_reverse($Remaining);
    142            
     139        $Addr = new NetworkAddressIPv6();
     140        $Addr->AddressFromString($Host['IPv6']);
     141        $Octets = $Addr->GetOctets();
     142        $Octets = array_slice($Octets, 0, (128 - $Prefix) / 4);
     143        $Octets = array_reverse($Octets);
     144        $Octets = implode('.', $Octets);
     145
    143146      $Host['Name'] = strtolower($Host['Name']);
    144       $Output .= implode(':', $Remaining)."\tIN\tPTR\t".$Host['Name'].".".$DNS['Domain'].".\n";
     147      $Output .= $Octets."\tIN\tPTR\t".$Host['Name'].".".$DNS['Domain'].".\n";
    145148    }
    146     $Reverse = implode(':', array_reverse(explode(':', $Network)));   
    147     $File = fopen($DNS['BaseDir'].$Reverse.'.ipv6.arpa.zone', 'w+');
     149
     150    $NetAddr = new NetworkAddressIPv6();
     151    $NetAddr->AddressFromString($NetworkAddress);
     152    $Octets = array_reverse($NetAddr->GetOctets());
     153    $Octets = array_reverse(array_slice($Octets, 0, $Prefix / 4));
     154    $FileName = implode('.', $Octets).'.ipv6.arpa.zone';
     155    $File = fopen($DNS['BaseDir'].$FileName, 'w+');
    148156    fputs($File, $Output);
    149     //echo($Output);
    150157    fclose($File);
    151158  }
    152   */
    153159}
    154160
     
    169175  'Host' => array(),
    170176  'Alias' => array(),
    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'),
     177  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', '10.145.68',
     178        '10.145.69', '10.145.70', '10.145.71', '77.92.221', '172.16.0', '172.16.1'),
     179        'IPv6Network' => array('2a00:e580:244::/48'),
    174180);
    175181
     
    232238  'Alias' => array(),
    233239  'Network' => array('81.2.194', '193.86.238', '212.111.4', '77.92.221'),
    234         'IPv6Network' => array('2001:470:9ab9:1'),
     240        'IPv6Network' => array('2a00:e580:244::/48'),
    235241);
    236242
     
    271277  'Host' => array(),
    272278  'Alias' => array(),
    273   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 
     279  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67',
    274280    '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
    275281        'IPv6Network' => array(),
     
    311317  'Host' => array(),
    312318  'Alias' => array(),
    313   'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67', 
     319  'Network' => array('10.145.64', '10.145.65', '10.145.66', '10.145.67',
    314320        '10.145.68', '10.145.69', '10.145.70', '10.145.71'),
    315321        'IPv6Network' => array(),
Note: See TracChangeset for help on using the changeset viewer.