{"id":74,"date":"2026-01-22T05:21:35","date_gmt":"2026-01-22T05:21:35","guid":{"rendered":"https:\/\/blog.gpst.net.cn:4008\/?p=74"},"modified":"2026-01-28T06:24:16","modified_gmt":"2026-01-28T06:24:16","slug":"bindmysql%e6%90%ad%e5%bb%badns","status":"publish","type":"post","link":"https:\/\/opshub.com.cn\/?p=74","title":{"rendered":"bind+mysql\u642d\u5efadns"},"content":{"rendered":"\n<p>1\u3001\u524d\u63d0\uff1a\u7f16\u8bd1\u5b89\u88c5\u597dmysql5.6<\/p>\n\n\n\n<p>bind9\u5b89\u88c5\u5305\uff1a<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-bf79e5eb-4dcd-45df-b807-41fd0b7f2194\" href=\"https:\/\/blog.opshub.com.cn\/wp-content\/uploads\/2026\/01\/bind-9.9.2-P1.tar.gz\">bind-9.9.2-P1.tar<\/a><a href=\"https:\/\/blog.opshub.com.cn\/wp-content\/uploads\/2026\/01\/bind-9.9.2-P1.tar.gz\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-bf79e5eb-4dcd-45df-b807-41fd0b7f2194\">Download<\/a><\/div>\n\n\n\n<p>2\u3001\u7f16\u8bd1\u524d\u7684configure\uff1a<\/p>\n\n\n\n<p><code>.\/configure --prefix=\/usr\/local\/bind9 --with-dlz-mysql=\/usr\/local\/mysql5 --enable-epoll --disable-openssl-version-check --disable-ipv6 --enable-largefile --disable-threads<\/code><\/p>\n\n\n\n<p>3\u3001\u7f16\u8bd1\u4e0e\u5b89\u88c5\uff1a<\/p>\n\n\n\n<p><code>make -j${cores} &amp;&amp; make install<\/code><\/p>\n\n\n\n<p>4\u3001named.conf\u7684\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>options {\n        directory \"\/var\/named\/data\";\n        pid-file \"\/var\/run\/named.pid\";\n        allow-query { any; };\n        allow-query-cache { none; };\n        allow-transfer { none; };\n        allow-update { none; };\n        allow-recursion { none; };\n        recursion no;\n        version \"unknown-version\";\n};\ninclude \"\/var\/named\/data\/cn.zone\"; <em>cn.zone\u662f\u4e2d\u56fd\u5730\u533aIP\u7f51\u6bb5\u8868\uff1b<\/em>\ninclude \"\/var\/named\/data\/zone.conf\";<\/code><\/pre>\n\n\n\n<p>5\u3001cn.zone\u7684\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>acl \"CN\" {\n1.0.1.0\/24;\n1.0.2.0\/23;\n1.0.8.0\/21;\n1.0.32.0\/19;\n\u2026.(\u7701\u7565)\n};<\/code><\/pre>\n\n\n\n<p>6\u3001zone.conf\u7684\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>view \"CN\"       {\nmatch-clients { CN; };\ndlz \"Mysql zone\" {\ndatabase \"mysql\n {host=127.0.0.1 dbname=dnsdb ssl=false port=20430 user=bind_thebizark pass=RNSYf3ehdtCbk.uc5ffmdOietnlc}\n{select zone from dns_records where zone = '\\$zone$' and view = 'DF' limit 1}\n{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 as mydata from dns_records where (zone = '\\$zone$' and host = '\\$record$' and view = 'CN' and not (type = 'SOA' or type = 'NS')) or (zone = '\\$zone$' and host = '\\$record$' and view = 'DF' and not (type = 'SOA' or type = 'NS') and not exists (select id from dns_records where zone = '\\$zone$' and host = '\\$record$' and view = 'CN' and not (type = 'SOA' or type = 'NS')))}\n{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 as mydata from dns_records where zone = '\\$zone$' and (type = 'SOA' or type='NS') and view='DF'};\n};\n};\n \nview \"ANY\"       {\nmatch-clients { ANY; };\ndlz \"Mysql zone\" {\ndatabase \"mysql\n {host=127.0.0.1 dbname=dnsdb ssl=false port=20430 user=bind_thebizark pass=RNSYf3ehdtCbk.uc5ffmdOietnlc}\n{select zone from dns_records where zone = '\\$zone$' and view = 'DF' limit 1}\n{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 as mydata from dns_records where (zone = '\\$zone$' and host = '\\$record$' and view = 'ANY' and not (type = 'SOA' or type = 'NS')) or (zone = '\\$zone$' and host = '\\$record$' and view = 'DF' and not (type = 'SOA' or type = 'NS') and not exists (select id from dns_records where zone = '\\$zone$' and host = '\\$record$' and view = 'ANY' and not (type = 'SOA' or type = 'NS')))}\n{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 as mydata from dns_records where zone = '\\$zone$' and (type = 'SOA' or type='NS') and view='DF'};\n};\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u524d\u63d0\uff1a\u7f16\u8bd1\u5b89\u88c5\u597dmysql5.6 bind9\u5b89\u88c5\u5305\uff1a 2\u3001\u7f16\u8bd1\u524d\u7684configure\uff1a .\/configure &#8211;prefix=\/usr\/local\/bind9 &#8211;with-dlz-mysql=\/usr\/local\/mysql5 &#8211;enable-epoll &#8211;disable-openssl-version-check &#8211;disable-ipv6 &#8211;enable-largefile &#8211;disable-threads 3\u3001\u7f16\u8bd1\u4e0e\u5b89\u88c5\uff1a make -j${cores} &amp;&amp; make install 4\u3001named.conf\u7684\u914d\u7f6e\uff1a 5\u3001cn.zone\u7684\u5185\u5bb9\uff1a 6\u3001zone.conf\u7684\u5185\u5bb9\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-9"],"_links":{"self":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74"}],"version-history":[{"count":2,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":588,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/74\/revisions\/588"}],"wp:attachment":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}