在DNS区域绑定10中运行PHP

use*_*703 17 php linux dns bind

我正在使用带有BIND 10.1.2的Linux CentOS 6.64

我在主DNS(example.com)中有一个额外的区域(list.example.com)

绑定(命名)配置文件/etc/named.conf包含区域:

zone "list.example.com" IN {
            type master;
    file "list-example-com.zone";
        allow-query { localhost; };
            allow-transfer { 127.0.0.1; };
    };
Run Code Online (Sandbox Code Playgroud)

区域文件list-example-com.zone如下:

$TTL 86400      ; 1 day
@               IN SOA  ns1.example.com. hostmaster.example.com. (
                        2004032201 ; serial
                        7200       ; refresh (2 hours)
                        5400       ; retry (1.5 hours)
                        1814400    ; expire (3 weeks)
                        86400      ; minimum (1 day)
                        )
                IN NS   ns1.example.com.
;
                IN A    192.168.177.22
;
; -----------------------------------------------------------------
49.30.22.66       IN A    127.0.0.3
44.63.20.10       IN A    127.0.0.2
64.42.10.5        IN A    127.0.0.2
14.3.6.8          IN A    127.0.0.3

// AND OTHER 1000S OF RECORDS LIKE THAT!
Run Code Online (Sandbox Code Playgroud)

我们选择一个重新编码的IP作为示例

IP 44.63.20.10的"A DNS查询"将是:

44.63.20.10.list.example.com并将从DNS返回127.0.0.2

好的,现在我要做的是,而不是列出1000个IP记录,我只想在named.conf,zone文件或任何其他执行某些代码运行PHP文件并返回127.0.0.2 for"A DNS"of IP 44.63.20.10

myfile.php:

<?php

// Just need to get the required IP (44.63.20.10) and the DNS_TYPE of the request (A, TXT,...ect) then:
// Execute some PHP codes to do some stuff (including connect to mysql database..ect)
// If the IP is TRUE, then return: (44.63.20.10     IN DNS_TYPE    X)

?>
Run Code Online (Sandbox Code Playgroud)

我希望你能清楚.

我有自己的PHP文件,只需要知道是否可以这样做?如果是,那怎么样?有什么好主意吗?

谢谢.

Mar*_*man 3

您必须使用 BIND 完整功能 API,该 API 允许“插件”替换指定区域和 BIND 的 BIND 内部数据库功能。

您需要编辑 BIND 源文件和 makefile.in,然后重新构建 BIND,包括源文件和头文件。

要开始使用 API,请找到位于 bind-release/lib/dns/include/dns/db.h 目录中的文件 db.h,其中 bin-release 应替换为解压源代码的位置和版本号发行版例如/usr/src/bind/10.1.2

这是一个副本http://pastebin.com/yTN5Aq03