I'm using linux CentOS 6.64 with BIND 10.1.2
I have an additional zone (list.example.com) within the main DNS (example.com)
Bind (named) config file /etc/named.conf is include the zone:
zone "list.example.com" IN {
type master;
file "list-example-com.zone";
allow-query { localhost; };
allow-transfer { 127.0.0.1; };
};
Zone file list-example-com.zone as follows:
$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!
Let's pick one of recoded IPs as an example
The "A DNS lookup" for the IP 44.63.20.10 will be:
44.63.20.10.list.example.com and will return 127.0.0.2 from the DNS
Ok, now what i want to do is, instead of listing 1000s of IP records, i just want to run PHP file in named.conf, zone file or any other to execute some codes and return 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)
?>
I hope it clear for you.
I have my own PHP file, just need to know if it possible to do that? and if yes, then how? Any idea please?
Thanks.
You have to use BIND Full function API, that allows the 'plug-in' to replace BIND's internal database function for nominated zones and from BIND.
You will need to edit the BIND source files and makefile.in and then re-build BIND including your source and header files.
To start with he API, find file db.h which is located in the directory bind-release/lib/dns/include/dns/db.h where bind-release should be replaced with the location and version number where you unpacked the source distribution e.g. /usr/src/bind/10.1.2
Here is a copy http://pastebin.com/yTN5Aq03
With bind this is, as far as I know, not possible.
The solution that I would recommend is using powerDNS.
PowerDNS is more flexibel, and is able to use a database. I'm using it with a MySQL database for example.
Maybe that's directly what you want, maybe it isn't. But with the flexibility of using a database, you can create a PHP script that inserts everything in the database, and checks it, and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With