dev-master
9999999-dev https://github.com/artroot/kohana-pdns-module#readmeModule helps to work with Power DNS (push/rm zones & records)
MIT
kohana powerdns pdns
Wallogit.com
2017 © Pedro Peláez
Module helps to work with Power DNS (push/rm zones & records)
Work with Power DNS zones(domains) & records, (*1)
composer require artroot/kohana-pdns-module
git clone https://github.com/artroot/kohana-pdns-module
or download, (*2)
wget https://github.com/artroot/kohana-pdns-module/archive/master.zip
Add new module, copy to your bootstrap.php in Kohana::modules array, (*3)
Kohana::modules(array(
...
'pdns' => MODPATH.'pdns', // Work with Power DNS
));
Configure your Database.php, add new group for Power DNS, (*4)
...
'pdns' => array
(
'type' => 'mysqli',
'connection' => array(
'hostname' => 'localhost',
'database' => 'PdnsDbName',
'username' => 'username',
'password' => 'password',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
'profiling' => TRUE,
),
Put the pdns folder into MODPATH, (*5)
$hosts = [
'192.168.1.101' => 'host1',
'192.168.1.102' => 'host2',
'192.168.2.103' => 'host3',
];
$fwdZoneOptions = [
'name' => 'local',
'type' => Model_Domain::MASTER,
];
$revZoneOptions = [
'type' => Model_Domain::MASTER,
];
$recordTypes = [
Model_Record::A,
Model_Record::PTR,
];
PDNS::synchronize($hosts, $fwdZoneOptions, $revZoneOptions, $recordTypes);
Will fill tables:, (*6)
| id | name | type |
|---|---|---|
| 1 | local | MASTER |
| 2 | 1.168.192.in-addr.arpa | MASTER |
| 3 | 2.168.192.in-addr.arpa | MASTER |
| id | domain_id | name | type | content | ttl |
|---|---|---|---|---|---|
| 1 | 1 | local | SOA | ns.local. local 2017064352 10800 3600 604800 86400 | 3600 |
| 2 | 1 | local | NS | ns.local | 3600 |
| 3 | 2 | 1.168.192.in-addr.arpa | SOA | ns.local. 1.168.192.in-addr.arpa 2017064352 10800 3600 604800 86400 | 3600 |
| 4 | 2 | 1.168.192.in-addr.arpa | NS | ns.local | 3600 |
| 5 | 1 | host1 | A | 192.168.1.101 | 3600 |
| 6 | 2 | 101.1.168.192.in-addr.arpa | PTR | host1.local | 3600 |
| 7 | 1 | host2 | A | 192.168.1.102 | 3600 |
| 8 | 2 | 102.1.168.192.in-addr.arpa | PTR | host2.local | 3600 |
| 9 | 3 | 2.168.192.in-addr.arpa | SOA | ns.local. 2.168.192.in-addr.arpa 2017064352 10800 3600 604800 86400 | 3600 |
| 10 | 3 | 2.168.192.in-addr.arpa | NS | ns.local | 3600 |
| 11 | 1 | host3 | A | 192.168.2.103 | 3600 |
| 12 | 3 | 103.2.168.192.in-addr.arpa | PTR | host3.local | 3600 |
Do callback if you need to change one of the records. For Example:, (*7)
$oldHost = [
'192.168.1.102' => 'host2',
];
$newHost = [
'192.168.1.102' => 'host5',
];
PDNS::synchronize($newHost, $fwdZoneOptions, $revZoneOptions, $recordTypes, PDNS::CALL_RM_REC, [
$oldHost
]);
Or use rmRecord() once, (*8)
$hosts = [
'192.168.1.102' => 'host2',
'192.168.1.103' => 'host3',
];
$recordTypes = [
Model_Record::A,
Model_Record::PTR,
];
$zoneName = 'local';
PDNS::rmRecord($hosts, $recordTypes, $zoneName);
Delete all records for hosts list., (*9)
This project is licensed under the MIT License - see the LICENSE file for details, (*10)
Module helps to work with Power DNS (push/rm zones & records)
MIT
kohana powerdns pdns