Changeset 695 for trunk/Modules/NetworkConfigLinux/Generators/DNS.php
- Timestamp:
- Sep 19, 2014, 7:25:33 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r659 r695 17 17 $MinimumTime = 10800; 18 18 $TTL = 86400; 19 $BaseDir = '/var/named/'; 19 $BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named'; 20 if(!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.'); 20 21 $MailServer = 'centrala'; 21 22 … … 53 54 } 54 55 55 // Host list56 // IPv4 host list 56 57 foreach($DNS['Host'] as $Host) 57 58 { … … 60 61 } 61 62 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 62 71 // Alias list 63 72 foreach($DNS['Alias'] as $Alias) … … 102 111 fclose($File); 103 112 } 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 */ 104 153 } 105 154 … … 114 163 'TTL' => $TTL, 115 164 'Description' => 'ZdechovNET community network', 116 'BaseDir' => '/var/named/internal/',165 'BaseDir' => $BaseDir.'/internal/', 117 166 'MailServer' => array('centrala.'.$BaseDomain), 118 167 'NameServer' => array('centrala.'.$BaseDomain, 'mozek.'.$BaseDomain), … … 120 169 'Host' => array(), 121 170 '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'), 123 174 ); 124 175 … … 130 181 $Name = $Interface['DeviceName']; 131 182 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 136 188 $DbResult = $System->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '. 137 189 'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.ExternalIP <> ""'); … … 173 225 'TTL' => $TTL, 174 226 'Description' => 'ZdechovNET community network', 175 'BaseDir' => '/var/named/external/',227 'BaseDir' => $BaseDir.'/external/', 176 228 'MailServer' => array('centrala.'.$BaseDomain), 177 229 'NameServer' => array('gw-hajda.inext.cz', 'ns0.xname.org', 'ns2.afraid.org'), … … 180 232 'Alias' => array(), 181 233 'Network' => array('81.2.194', '193.86.238', '212.111.4', '77.92.221'), 234 'IPv6Network' => array('2001:470:9ab9:1'), 182 235 ); 183 236 … … 188 241 $Name = $Interface['DeviceName']; 189 242 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']); 191 245 } 192 246 … … 211 265 'TTL' => 86400, 212 266 'Description' => 'ZdechovNET community network', 213 'BaseDir' => '/var/named/czfree/',267 'BaseDir' => $BaseDir.'/czfree/', 214 268 'MailServer' => array('centrala.'.$BaseDomain), 215 269 'NameServer' => array('centrala.'.$BaseDomain, 'mozek'.$BaseDomain), … … 217 271 'Host' => array(), 218 272 '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(), 220 276 ); 221 277 … … 249 305 'TTL' => 86400, 250 306 'Description' => 'ZdechovNET community network', 251 'BaseDir' => '/var/named/internal/',307 'BaseDir' => $BaseDir.'/internal/', 252 308 'MailServer' => array('centrala.'.$BaseDomain), 253 309 'NameServer' => array('centrala.'.$BaseDomain, 'mozek.'.$BaseDomain), … … 255 311 'Host' => array(), 256 312 '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(), 258 316 ); 259 317
Note:
See TracChangeset
for help on using the changeset viewer.