{"id":1296,"date":"2025-07-30T19:35:46","date_gmt":"2025-07-30T11:35:46","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=1296"},"modified":"2025-07-30T19:35:46","modified_gmt":"2025-07-30T11:35:46","slug":"%e6%90%ad%e5%bb%badns%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e5%9b%9b%e4%b8%aa%e6%ad%a5%e9%aa%a4%e5%8f%8a%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/1296.html","title":{"rendered":"\u642d\u5efaDNS\u670d\u52a1\u5668\u7684\u56db\u4e2a\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879"},"content":{"rendered":"<p><p>\u642d\u5efaDNS\u670d\u52a1\u5668\u662f\u4e00\u9879\u91cd\u8981\u7684\u7f51\u7edc\u7ba1\u7406\u4efb\u52a1\uff0c\u5b83\u5141\u8bb8\u60a8\u63a7\u5236\u548c\u7ba1\u7406\u57df\u540d\u89e3\u6790\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u642d\u5efa\u4e00\u4e2a\u57fa\u672c\u7684DNS\u670d\u52a1\u5668\uff0c\u5e76\u89e3\u51b3\u5e38\u89c1\u7684\u914d\u7f6e\u95ee\u9898\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/7T3be3.jpg\" alt=\"\u642d\u5efaDNS\u670d\u52a1\u5668\u7684\u56db\u4e2a\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\" title=\"\u642d\u5efaDNS\u670d\u52a1\u5668\u7684\u56db\u4e2a\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\"><\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907\u6216\u80cc\u666f\u4ecb\u7ecd<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e00\u53f0\u5177\u6709\u516c\u7f51IP\u5730\u5740\u7684Linux\u670d\u52a1\u5668\u3002<\/li>\n<li>\u7ba1\u7406\u5458\u6743\u9650\u3002<\/li>\n<li>\u9884\u5148\u51c6\u5907\u597d\u7684\u57df\u540d\u548c\u89e3\u6790\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p><h2>\u5b8c\u6210\u4efb\u52a1\u6240\u9700\u7684\u8be6\u7ec6\u3001\u5206\u6b65\u64cd\u4f5c\u6307\u5357<\/h2>\n<\/p>\n<p><h3>1. \u5b89\u88c5DNS\u670d\u52a1\u5668\u8f6f\u4ef6<\/h3>\n<\/p>\n<p><p>\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u90fd\u9884\u88c5\u4e86BIND\uff08Berkeley Internet Name Domain\uff09DNS\u670d\u52a1\u5668\u3002\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo apt-get update<\/p>\r\n<p>sudo apt-get install bind9<\/code><\/pre>\n<\/p>\n<p><h3>2. \u914d\u7f6eDNS\u670d\u52a1\u5668<\/h3>\n<\/p>\n<p><p>\u7f16\u8f91DNS\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo nano \/etc\/bind\/named.conf.local<\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u4ee5\u5b9a\u4e49\u60a8\u7684\u57df\u540d\u548c\u89e3\u6790\u8bb0\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code>zone \"example.com\" {<\/p>\r\n<p>        type master;<\/p>\r\n<p>        file \"\/etc\/bind\/zones\/db.example.com\";<\/p>\r\n<p>};<\/p>\r\n\r\n<p>zone \"localhost\" {<\/p>\r\n<p>        type master;<\/p>\r\n<p>        file \"\/etc\/bind\/zones\/db.localhost\";<\/p>\r\n<p>};<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u521b\u5efa\u533a\u57df\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u4e3a\u60a8\u7684\u57df\u540d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u533a\u57df\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo nano \/etc\/bind\/zones\/db.example.com<\/code><\/pre>\n<\/p>\n<p><p>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u4ee5\u5b9a\u4e49A\u8bb0\u5f55\u548cSOA\u8bb0\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code>$TTL    604800<\/p>\r\n<p>@       IN      SOA     ns1.example.com. admin.example.com. (<\/p>\r\n<p>                        2023010101         ; Serial<\/p>\r\n<p>                        604800            ; Refresh<\/p>\r\n<p>                        86400             ; Retry<\/p>\r\n<p>                        2419200           ; Expire<\/p>\r\n<p>                        604800 )          ; Negative Cache TTL<\/p>\r\n<p>;<\/p>\r\n<p>@       IN      NS      ns1.example.com.<\/p>\r\n<p>ns1     IN      A       192.168.1.1<\/p>\r\n<p>www     IN      A       192.168.1.2<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4. \u542f\u52a8\u548c\u542f\u7528DNS\u670d\u52a1<\/h3>\n<\/p>\n<p><p>\u542f\u52a8DNS\u670d\u52a1\u5e76\u8bbe\u7f6e\u4e3a\u968f\u7cfb\u7edf\u542f\u52a8\u81ea\u52a8\u8fd0\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo systemctl start bind9<\/p>\r\n<p>sudo systemctl enable bind9<\/code><\/pre>\n<\/p>\n<p><h2>\u6d89\u53ca\u7684\u5173\u952e\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u914d\u7f6e\u793a\u4f8b<\/h2>\n<\/p>\n<ul>\n<li>\u5b89\u88c5\u547d\u4ee4\uff1a`sudo apt-get install bind9`<\/li>\n<li>\u914d\u7f6e\u6587\u4ef6\uff1a`\/etc\/bind\/named.conf.local`<\/li>\n<li>\u533a\u57df\u6587\u4ef6\uff1a`\/etc\/bind\/zones\/db.example.com`<\/li>\n<li>\u542f\u52a8\u670d\u52a1\uff1a`sudo systemctl start bind9`<\/li>\n<li>\u542f\u7528\u670d\u52a1\uff1a`sudo systemctl enable bind9`<\/li>\n<\/ul>\n<p><h2>\u5bf9\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u91cd\u8981\u6982\u5ff5\u7684\u6e05\u6670\u89e3\u91ca<\/h2>\n<\/p>\n<p><p>SOA\u8bb0\u5f55\uff1a\u8d1f\u8d23\u8bb0\u5f55\u57df\u540d\u7684\u6743\u5a01\u4fe1\u606f\uff0c\u5305\u62ec\u57df\u540d\u7ba1\u7406\u5458\u90ae\u7bb1\u3001\u5e8f\u5217\u53f7\u3001\u5237\u65b0\u65f6\u95f4\u3001\u91cd\u8bd5\u65f6\u95f4\u548c\u8fc7\u671f\u65f6\u95f4\u3002<\/p>\n<\/p>\n<p><p>A\u8bb0\u5f55\uff1a\u5c06\u57df\u540d\u6620\u5c04\u5230IP\u5730\u5740\uff0c\u4f8b\u5982\u5c06\u201cwww.example.com\u201d\u89e3\u6790\u5230\u201c192.168.1.2\u201d\u3002<\/p>\n<\/p>\n<p><p>NS\u8bb0\u5f55\uff1a\u6307\u5b9a\u8d1f\u8d23\u89e3\u6790\u8be5\u57df\u540d\u7684DNS\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3001\u6ce8\u610f\u4e8b\u9879\u6216\u76f8\u5173\u7684\u5b9e\u7528\u6280\u5de7<\/h2>\n<\/p>\n<ul>\n<li>\u786e\u4fdd\u670d\u52a1\u5668\u65f6\u95f4\u540c\u6b65\uff0c\u907f\u514d\u5e8f\u5217\u53f7\u51b2\u7a81\u3002<\/li>\n<li>\u68c0\u67e5\u9632\u706b\u5899\u8bbe\u7f6e\uff0c\u786e\u4fddDNS\u7aef\u53e3\uff0853\uff09\u5f00\u653e\u3002<\/li>\n<li>\u4f7f\u7528`named-checkconf`\u548c`named-checkzone`\u547d\u4ee4\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u7684\u8bed\u6cd5\u9519\u8bef\u3002<\/li>\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528`$TTL`\u6307\u4ee4\u8bbe\u7f6e\u9ed8\u8ba4TTL\u503c\uff0c\u53ef\u4ee5\u51cf\u5c11\u89e3\u6790\u8fc7\u7a0b\u4e2d\u7684\u91cd\u590d\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<p>&#8220;`<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u642d\u5efaDNS\u670d\u52a1\u5668\u662f\u4e00\u9879\u91cd\u8981\u7684\u7f51\u7edc\u7ba1\u7406\u4efb\u52a1\uff0c\u5b83\u5141\u8bb8\u60a8\u63a7\u5236\u548c\u7ba1\u7406\u57df\u540d\u89e3\u6790\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u5728Linux\u670d\u52a1\u5668\u4e0a\u642d\u5efa\u4e00\u4e2a\u57fa\u672c\u7684DNS\u670d\u52a1\u5668\uff0c\u5e76\u89e3\u51b3\u5e38\u89c1\u7684\u914d\u7f6e\u95ee\u9898\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907\u6216\u80cc\u666f\u4ecb\u7ecd \u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u670d\u52a1\u5668\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a \u4e00\u53f0\u5177\u6709\u516c\u7f51I&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1297,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[178,50,8],"topic":[],"class_list":["post-1296","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-dns","tag-linux","tag-8"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=1296"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1296\/revisions"}],"predecessor-version":[{"id":1299,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/1296\/revisions\/1299"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/1297"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=1296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=1296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=1296"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=1296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}