artroot / kohana-pdns-module
模块帮助处理Power DNS(推送/rm区域与记录)
dev-master
2017-06-28 22:24 UTC
This package is not auto-updated.
Last update: 2024-09-24 18:01:28 UTC
README
与Power DNS区域(域名)和记录一起工作
安装
使用composer
composer require artroot/kohana-pdns-module
使用git
git clone https://github.com/artroot/kohana-pdns-module
或下载
wget https://github.com/artroot/kohana-pdns-module/archive/master.zip
常规设置
添加新模块,将其复制到Kohana::modules数组中的bootstrap.php文件
Kohana::modules(array( ... 'pdns' => MODPATH.'pdns', // Work with Power DNS ));
配置Database.php,为Power DNS添加新组
... 'pdns' => array ( 'type' => 'mysqli', 'connection' => array( 'hostname' => 'localhost', 'database' => 'PdnsDbName', 'username' => 'username', 'password' => 'password', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, 'profiling' => TRUE, ),
将pdns文件夹放入MODPATH
代码
同步方法
$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);
将填充表
域名表
记录表
如果需要更改记录之一,请进行回调。例如
$oldHost = [ '192.168.1.102' => 'host2', ]; $newHost = [ '192.168.1.102' => 'host5', ]; PDNS::synchronize($newHost, $fwdZoneOptions, $revZoneOptions, $recordTypes, PDNS::CALL_RM_REC, [ $oldHost ]);
或使用rmRecord()一次
RmRecord方法
$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);
删除主机列表中所有记录。
许可证
本项目采用MIT许可证,有关详细信息,请参阅LICENSE文件。