install bind-9.11, on cenos7 and enable mysql-5.7, for DLZ, database when compiling, but always report an error when starting. It is good to start with zone file directly. The following is the configuration and error message of named.conf. Please see what went wrong.
options{
directory"/opt/bind-9.11/var/named";
listen-on port 53 { any; };
allow-query-cache { any; };
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
};
logging {
channel query_log {
file "/opt/bind-9.11/var/log/named/query.log" versions 20 size 300m;
severity info;
print-time yes;
print-category yes;
};
channel error_log {
file "/opt/bind-9.11/var/log/named/error.log" versions 3 size 10m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category queries { query_log; };
category default { error_log; };
};
key "rndc-key" {
algorithm hmac-md5;
secret "y8pesUMzXhqdGRgO9cdlfg==";
};
controls {
inet 127.0.0.1 port 953
allow{ 127.0.0.1; } keys {"rndc-key";};
};
-sharpzone "test.info" IN {
-sharp type master;
-sharp file "db.opstar.club";
-sharp allow-update { none; };
-sharp};
dlz "Mysql zone" {
database "mysql
{host=localhost dbname=bind ssl=false port=3306 user=test pass=123.com}
{select zone from dns_records where zone = "$zone$"}
{select ttl, type, mx_priority, case when lower(type)="txt" then concat("\"", data, "\"")
when lower(type) = "soa" then concat_ws(" ", data, resp_person, serial, refresh, retry, expire, minimum)
else data end from dns_records where zone = "$zone$" and host = "$record$"}";
};