{"id":61128,"date":"2025-04-29T13:37:01","date_gmt":"2025-04-29T05:37:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61128\/"},"modified":"2025-04-29T13:37:01","modified_gmt":"2025-04-29T05:37:01","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-linux-%e4%b8%8a%e6%9f%a5%e7%9c%8b%e5%92%8c%e5%88%b7%e6%96%b0-dns-%e7%bc%93%e5%ad%98-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61128\/","title":{"rendered":"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58"},"content":{"rendered":"<p>\u901a\u8fc7\u5237\u65b0\u672c\u5730 dns \u7f13\u5b58\uff0c\u60a8\u53ef\u4ee5\u89e3\u51b3 http \u9519\u8bef\u5e76\u4fdd\u62a4\u81ea\u5df1\u514d\u53d7 dns \u6b3a\u9a97\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u5728  \u4e0a\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u5f53\u60a8\u4f7f\u7528\u57df\u540d\u8bbf\u95ee\u7f51\u7ad9\u65f6\uff0c\u60a8\u7684\u7cfb\u7edf\u4f1a\u5411 DNS \u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u4ee5\u83b7\u53d6\u8be5\u57df\u7684 IP \u5730\u5740\u3002\u6b64\u57df IP \u5730\u5740\u5bf9\u4fdd\u5b58\u5728 DNS \u7f13\u5b58\u4e2d\u4f9b\u4ee5\u540e\u4f7f\u7528\uff0c\u56e0\u6b64\u60a8\u4e0d\u5fc5\u6bcf\u6b21\u90fd\u5411 DNS \u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u4ee5\u5efa\u7acb\u8fde\u63a5\u3002<\/p>\n<p>\u4f46\u6709\u65f6\uff0c\u672c\u5730 DNS \u7f13\u5b58\u4f1a\u635f\u574f\u5e76\u5bfc\u81f4 HTTP \u9519\u8bef\u3002\u503c\u5f97\u5e86\u5e78\u7684\u662f\uff0c\u5728 Linux \u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5237\u65b0\u548c\u91cd\u5efa DNS \u7f13\u5b58\u975e\u5e38\u5bb9\u6613\u3002\u8fd9\u662f\u5982\u4f55\u505a\u5230\u7684\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802082916263.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe\" \/><\/p>\n<h3><span style=\"letter-spacing: 0.05em\">\u4e3a\u4ec0\u4e48\u8981\u5728 Linux \u4e0a\u5237\u65b0 DNS \u7f13\u5b58\uff1f<\/span><\/h3>\n<p>\u60a8\u53ef\u80fd\u60f3\u8981\u91cd\u5efa\u5b58\u50a8\u5728\u7cfb\u7edf\u4e0a\u7684 DNS \u7f13\u5b58\u7684\u539f\u56e0\u6709\u591a\u79cd\u3002\u5982\u679c\u60a8\u7684DNS\u8bb0\u5f55\u8fc7\u65f6\u4e86\uff0c\u60a8\u53ef\u80fd\u60f3\u8981\u4eceDNS\u670d\u52a1\u5668\u91cd\u65b0\u83b7\u53d6\u5b83\u3002\u53e6\u5916\uff0c\u5982\u679c\u60a8\u62c5\u5fc3\u7cfb\u7edf\u53d7\u5230\u5a01\u80c1\u4e86\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u786e\u4fddDNS\u7f13\u5b58\u672a\u88ab\u7be1\u6539\uff0c\u4e5f\u88ab\u79f0\u4e3aDNS\u6b3a\u9a97\u3002<\/p>\n<p>\u5f53\u60a8\u5237\u65b0 DNS \u7f13\u5b58\u65f6\uff0c\u7cfb\u7edf\u5fc5\u987b\u518d\u6b21 ping DNS \u670d\u52a1\u5668\u5e76\u4ece\u4e2d\u83b7\u53d6\u65b0\u7684\u57df IP \u5730\u5740\u8bb0\u5f55\uff0c\u4ece\u800c\u5728\u6b64\u8fc7\u7a0b\u4e2d\u5220\u9664\u4efb\u4f55\u8fc7\u65f6\u6216\u53d7\u635f\u7684\u6570\u636e\u3002<\/p>\n<h3><span style=\"letter-spacing: 0.05em\">\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u672c\u5730 DNS \u7f13\u5b58<\/span><\/h3>\n<p>\u5728systemd\u4e4b\u524d\uff0c\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u90fd\u6ca1\u6709\u7cfb\u7edf\u8303\u56f4\u7684DNS\u7f13\u5b58\uff0c\u9664\u975e\u50cfdnsmasq\u6216nscd\u8fd9\u6837\u7684\u7a0b\u5e8f\u662f\u624b\u52a8\u8bbe\u7f6e\u7684\u3002systemd \u9644\u5e26 systemd-solved\uff0c\u8fd9\u662f\u4e00\u9879\u5c06\u57df\u540d\u89e3\u6790\u4e3a IP \u5730\u5740\u5e76\u7f13\u5b58 DNS \u6761\u76ee\u7684\u670d\u52a1\u3002<\/p>\n<p>\u4ee5\u4e0b\u5404\u8282\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u67e5\u770b\u7531 systemd \u89e3\u6790\u3001nscd \u548c dnsmasq \u751f\u6210\u7684 DNS \u7f13\u5b58\u5185\u5bb9\uff0c\u4ee5\u4fbf\u60a8\u5728\u51b3\u5b9a\u5237\u65b0\u7f13\u5b58\u6570\u636e\u4e4b\u524d\u4e86\u89e3\u7f13\u5b58\u7684\u6570\u636e\u3002<\/p>\n<h4><span style=\"letter-spacing: 0.05em\">\u67e5\u770b\u7cfb\u7edf\u89e3\u6790\u7684 DNS \u7f13\u5b58<\/span><\/h4>\n<p>\u8981\u67e5\u770b systemd \u89e3\u6790\u7684\u7f13\u5b58\u8bb0\u5f55\uff0c\u60a8\u9700\u8981\u5148\u6682\u65f6\u7ec8\u6b62\u670d\u52a1\uff0c\u7136\u540e\u5c06\u5176\u65e5\u5fd7\u5bfc\u51fa\u5230\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u9996\u5148\u53d1\u9001 SIGUSR1 \u4fe1\u53f7\u4ee5\u7ec8\u6b62 systemd \u89e3\u6790\u7684\u670d\u52a1\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo killall -USR1 systemd-resolved[sudo] linuxmi \u7684\u5bc6\u7801\uff1a <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f7f\u7528&nbsp;journalctl \u547d\u4ee4\u548c\u6807\u51c6\u8f93\u51fa\u8fd0\u7b97\u7b26\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230\u6587\u672c\u6587\u4ef6\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo journalctl -u systemd-resolved &amp;gt; ~\/cache.txtlinuxmi@linuxmi ~\/www.linuxmi.com<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802082936063.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe1\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe1\" \/><\/p>\n<p>\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Vim \u7b49\u6587\u672c\u7f16\u8f91\u5668\u67e5\u770b\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802082931485.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe2\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe2\" \/><\/p>\n<p>\u5728\u6587\u4ef6\u4e2d\uff0c\u641c\u7d22\u201cCACHE\uff1a\u201d\uff0c\u65b9\u6cd5\u662f\u6309&nbsp;Escape\uff0c\u952e\u5165\u201c\/CACHE\uff1a\u201d\uff0c\u7136\u540e\u6309&nbsp;Enter&nbsp;\u952e\u3002\u5728\u201cCACHE\uff1a\u201d\u4e0b\u65b9\u5217\u51fa\u7684\u6240\u6709 DNS \u8bb0\u5f55\u90fd\u5305\u542b\u5728\u672c\u5730 DNS \u7f13\u5b58\u4e2d\u3002\u82e5\u60a8\u5728\u4f7f\u7528 Vim\uff0c\u8bf7\u6309\u4e0b n \u952e\u4ee5\u8df3\u8f6c\u81f3\u4e0b\u4e00\u7ec4 DNS \u6761\u76ee\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083055382.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe3\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe3\" \/><\/p>\n<h4><span style=\"letter-spacing: 0.05em\">\u67e5\u770b nscd \u7684\u672c\u5730 DNS \u7f13\u5b58<\/span><\/h4>\n<p>\u8981\u67e5\u770b nscd \u751f\u6210\u7684\u672c\u5730\u7f13\u5b58\uff0c\u60a8\u9700\u8981\u4f7f\u7528 string \u547d\u4ee4\u8bfb\u53d6 nscd \u4e3b\u673a\u6570\u636e\u5e93\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u5728\u57fa\u4e8e Debian \u548c Ubuntu \u7684\u53d1\u884c\u7248\u4e0a\uff0c\u6b64\u6587\u4ef6\u4f4d\u4e8e \/var\/cache\/nscd\/hosts\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u67e5\u770b\u6587\u4ef6\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo strings \/var\/cache\/nscd\/hosts | uniq<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083082614.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe4\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe4\" \/><\/p>\n<p>\u8981\u67e5\u770b\u6709\u5173 nscd DNS \u9ad8\u901f\u7f13\u5b58\u7684\u4e00\u822c\u7edf\u8ba1\u4fe1\u606f\uff0c\u8bf7\u4f7f\u7528&nbsp;-g&nbsp;\u6807\u5fd7\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo nscd -g<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083057878.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe5\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe5\" \/><\/p>\n<h4>\u663e\u793a\u7531 dnsmasq \u751f\u6210\u7684 DNS \u7f13\u5b58<\/h4>\n<p>\u83b7\u53d6\u786e\u5207\u7684\u8bb0\u5f55\u5e76\u4e0d\u5bb9\u6613\uff0c\u56e0\u4e3a dnsmasq \u5728\u5185\u5b58\u4e2d\u5b58\u50a8 DNS \u7f13\u5b58\u3002\u60a8\u53ef\u4ee5\u53d1\u9001\u7ec8\u6b62\u4fe1\u53f7\u7ed9 dnsmasq \u5e76\u8bb0\u5f55\u5176\u8f93\u51fa\uff0c\u4ee5\u83b7\u53d6\u5904\u7406\u7684 DNS \u67e5\u8be2\u6570\u91cf\u3002<\/p>\n<p>\u4e3a\u6b64\uff0c\u9996\u5148\uff0c\u4f7f\u7528&nbsp;systemctl \u547d\u4ee4\u786e\u4fdd&nbsp;dnsmasq \u5df2\u542f\u52a8\u5e76\u6b63\u5728\u8fd0\u884c\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo systemctl status dnsmasq<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083035900.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe6\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe6\" \/><\/p>\n<p>\u5982\u679c\u72b6\u6001\u663e\u793a\u201c\u6d3b\u52a8 Active\u201d\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u7ec8\u6b62\u8be5\u670d\u52a1\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo pkill -USR1 dnsmasq<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083055097.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe7\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe7\" \/><\/p>\n<p>\u4f7f\u7528 journalctl \u547d\u4ee4\uff0c\u63d0\u53d6 dnsmasq \u65e5\u5fd7\u5e76\u5c06\u5b83\u4eec\u4fdd\u5b58\u5230\u6587\u672c\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo journalctl -u dnsmasq &amp;gt; ~\/cache.txt<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6700\u540e\uff0c\u4f7f\u7528\u6587\u4ef6\u67e5\u770b\u5b9e\u7528\u7a0b\u5e8f\uff08\u5982 cat \u6216\u66f4\u5c11\uff09\u67e5\u770b\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<span style=\"letter-spacing: 0.05em\"><\/span><\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % cat ~\/cache.txt<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083143340.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe8\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe8\" \/><\/p>\n<h3><span style=\"letter-spacing: 0.05em\">\u5982\u4f55\u5728 Linux \u4e0a\u5237\u65b0 DNS \u7f13\u5b58<\/span><\/h3>\n<p>\u5237\u65b0 DNS \u7f13\u5b58\u610f\u5473\u7740\u4ece\u8ba1\u7b97\u673a\u4e2d\u5220\u9664\u7f13\u5b58\u7684 DNS \u8bb0\u5f55\u3002\u8fd9\u5c06\u8feb\u4f7f\u5b83\u5411DNS\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\uff0c\u4ee5\u83b7\u53d6\u65b0\u7684DNS\u6761\u76ee\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5728 Linux \u4e0a\u5237\u65b0 DNS \u7f13\u5b58\u7684\u65b9\u6cd5\uff1a<\/p>\n<h4><span style=\"letter-spacing: 0.05em\">\u4f7f\u7528 systemd \u89e3\u6790<\/span><\/h4>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 resolvectl \u547d\u4ee4\u5237\u65b0 systemd \u89e3\u6790\u5b58\u50a8\u7684 DNS \u7f13\u5b58\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo resolvectl flush-caches<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083186402.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe9\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe9\" \/><\/p>\n<p>\u5982\u679c\u60a8\u8fd0\u884c\u7684\u662f Ubuntu 17.04 \u6216 18.04\uff0c\u8bf7\u4f7f\u7528 systemd \u89e3\u6790\u7684\u547d\u4ee4\u5237\u65b0\u7f13\u5b58\uff1a<\/p>\n<pre>sudo systemd-resolved --flush-caches<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> <span style=\"letter-spacing: 0.05em\">\u5728 Linux \u4e0a\u5237\u65b0 nscd DNS \u7f13\u5b58<\/span><br \/> <\/h4>\n<p>\u5220\u9664 nscd \u7684 DNS \u7f13\u5b58\u7684\u6700\u4fbf\u6377\u65b9\u6cd5\u662f\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6267\u884c\u6b64\u64cd\u4f5c\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo \/etc\/init.d\/nscd restart<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083110148.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe10\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe10\" \/><\/p>\n<p>\u5982\u679c\u8fd9\u4e0d\u8d77\u4f5c\u7528\uff0c\u9996\u5148\uff0c\u68c0\u67e5\u5b58\u50a8\u5728PC\u4e0a\u7684\u672c\u5730\u7f13\u5b58\u662f\u5426\u6301\u4e45\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528&nbsp;-g&nbsp;\u6807\u5fd7\u8fdb\u884c\u9a8c\u8bc1\uff1a<\/p>\n<pre>sudo nscd -g<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u662f\u8fd9\u79cd\u60c5\u51b5\uff0c\u8bf7\u4f7f\u7528\u5e26\u6709 nscd \u547d\u4ee4\u7684&nbsp;\u2013i \u6807\u5fd7\u6765\u6e05\u9664\u8bb0\u5f55\uff08i&nbsp;\u4ee3\u8868&nbsp;invalidate\uff09\uff1a<\/p>\n<pre>linuxmi@linuxmi ~\/www.linuxmi.com % sudo nscd -i hosts<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h4> <span style=\"letter-spacing: 0.05em\">\u5220\u9664 dnsmasq DNS \u7f13\u5b58<\/span><br \/> <\/h4>\n<p>\u5237\u65b0 dnsmasq \u751f\u6210\u7684 DNS \u7f13\u5b58\u5f88\u7b80\u5355\u3002\u7531\u4e8e\u7f13\u5b58\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u56e0\u6b64\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u4f1a\u5220\u9664\u6240\u6709\u5b58\u50a8\u7684\u6761\u76ee\u3002<\/p>\n<p>\u8981\u91cd\u65b0\u542f\u52a8 dnsmasq\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b systemctl \u547d\u4ee4\uff1a<\/p>\n<pre>sudo systemctl restart dnsmasq<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6216\u8005\uff0c\u53d1\u51fa\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>service dnsmasq restart<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u51fa\u73b0\u63d0\u793a\uff0c\u8bf7\u8f93\u5165\u7ba1\u7406\u5458\u5bc6\u7801\u3002\u73b0\u5728\u8981\u91cd\u65b0\u542f\u52a8 dnsmasq\uff0c\u6240\u6709\u7f13\u5b58\u4e2d\u5b58\u5728\u7684 DNS \u6761\u76ee\u5c06\u88ab\u6e05\u9664\u3002<\/p>\n<p>\u5efa\u8bae\u5237\u65b0 DNS \u7f13\u5b58\u540e\uff0c\u68c0\u67e5\u672c\u5730\u7f13\u5b58\u6761\u76ee\u4ee5\u786e\u8ba4\u6570\u636e\u5df2\u7ecf\u6210\u529f\u5220\u9664\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 Linux \u547d\u4ee4\u4e4b\u4e00\u7684 dig \u6765\u8fdb\u884c\u7f51\u7edc\u6545\u969c\u6392\u9664\uff0c\u5e76\u67e5\u770b\u8f93\u51fa\u4e2d\u7684\u201c\u67e5\u8be2\u65f6\u95f4\u201d\u503c\u3002\u5047\u5982\u8d85\u8fc7 0 \u6beb\u79d2\uff0c\u5219\u8bf4\u660e\u7f13\u5b58\u5df2\u7ecf\u6210\u529f\u6e05\u9664\uff08\u82e5\u4e3a 0 \u6beb\u79d2\uff0c\u5219\u8868\u793a\u57df\u8bb0\u5f55\u4ecd\u5b58\u5728\u4e8e\u7f13\u5b58\u4e2d\uff09\u3002<\/p>\n<pre>dig google.com<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<h3><span style=\"letter-spacing: 0.05em\">\u6e05\u9664\u8c37\u6b4c\u6d4f\u89c8\u5668\u7684DNS\u7f13\u5b58<\/span><\/h3>\n<p>\u60a8\u7ecf\u5e38\u4f7f\u7528\u7684 Web \u6d4f\u89c8\u5668\u4e5f\u4f1a\u7f13\u5b58 DNS \u8bb0\u5f55\u3002\u8f93\u5165 URL \u65f6\uff0c\u7cfb\u7edf\u4f1a\u5728\u672c\u5730\u6d4f\u89c8\u5668\u7f13\u5b58\u4e2d\u641c\u7d22\u7f13\u5b58\u6761\u76ee\u3002\u5982\u679c\u672a\u627e\u5230\uff0c\u5b83\u5c06\u68c0\u67e5\u672c\u5730\u7cfb\u7edf\u7f13\u5b58\u4e2d\u7684\u8bb0\u5f55\u3002\u6e05\u9664 Web \u6d4f\u89c8\u5668\u7684 DNS \u7f13\u5b58\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u4f18\u5148\u4e8e\u7cfb\u7edf\u8303\u56f4\u7684\u7f13\u5b58\u3002<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a\uff0c\u8ba9\u6211\u4eec\u5237\u65b0\u8c37\u6b4c\u6d4f\u89c8\u5668\u4e2d\u7684DNS\u7f13\u5b58\u3002\u5728\u5176\u4ed6\u6d4f\u89c8\u5668\u4e0a\u4e5f\u6709\u4e00\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u505a\u5230\u8fd9\u4e00\u70b9\uff0c\u6240\u4ee5\u6700\u597d Google \u4e00\u4e0b\u5982\u4f55\u4f7f\u7528\u4f60\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u505a\u5230\u8fd9\u4e00\u70b9\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728URL\u680f\u4e2d\u952e\u5165\u201cchrome:\/\/net-internals\/#dns\u201d\u5e76\u6309Enter\u952e\uff1a<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/168802083193542.png\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe11\" alt=\"\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u63d2\u56fe11\" \/><\/p>\n<p>\u70b9\u51fb\u201c\u6e05\u9664\u4e3b\u673a\u7f13\u5b58\u201d\u6309\u94ae\u6765\u6e05\u9664\u8c37\u6b4c\u6d4f\u89c8\u5668\u4e2d\u5b58\u50a8\u7684DNS\u6761\u76ee\u3002<\/p>\n<h3><span style=\"letter-spacing: 0.05em\">Linux\u662f\u5b66\u4e60\u7f51\u7edc\u7684\u6700\u4f73\u64cd\u4f5c\u7cfb\u7edf<\/span><\/h3>\n<p>Linux \u4e4d\u4e00\u770b\u53ef\u80fd\u770b\u8d77\u6765\u5f88\u590d\u6742\uff0c\u4f46\u5982\u679c\u4f60\u82b1\u4e00\u4e9b\u65f6\u95f4\u6765\u5b66\u4e60\u5b83\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff0c\u4f60\u5f88\u5feb\u5c31\u4f1a\u610f\u8bc6\u5230\u5b83\u5f88\u68d2\uff0c\u751a\u81f3\u53ef\u80fd\u6bd4 Windows \u6216 macOS \u66f4\u597d\u3002<\/p>\n<p>\u5927\u591a\u6570\u5728\u7ebf\u670d\u52a1\u5668\u90fd\u8fd0\u884c Linux\uff0c\u5982\u679c\u60a8\u60f3\u5b66\u4e60\u7f51\u7edc\u6216\u60f3\u77e5\u9053\u8ba1\u7b97\u673a\u901a\u5e38\u5982\u4f55\u5de5\u4f5c\uff0c\u8fd9\u4e5f\u662f Linux \u7406\u60f3\u9009\u62e9\u7684\u539f\u56e0\u4e4b\u4e00\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u548c\u5237\u65b0 DNS \u7f13\u5b58\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u5237\u65b0\u672c\u5730 dns \u7f13\u5b58\uff0c\u60a8\u53ef\u4ee5\u89e3\u51b3 http \u9519\u8bef\u5e76\u4fdd\u62a4\u81ea\u5df1\u514d\u53d7 dns \u6b3a\u9a97\u7684\u5f71\u54cd\u3002\u4ee5\u4e0b\u662f\u5728 \u4e0a\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u65b9\u6cd5\u3002 \u5f53\u60a8\u4f7f\u7528\u57df\u540d\u8bbf\u95ee\u7f51\u7ad9\u65f6\uff0c\u60a8\u7684\u7cfb\u7edf\u4f1a\u5411 DNS \u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u4ee5\u83b7\u53d6\u8be5\u57df\u7684 IP \u5730\u5740\u3002\u6b64\u57df IP \u5730\u5740\u5bf9\u4fdd\u5b58\u5728 DNS \u7f13\u5b58\u4e2d\u4f9b\u4ee5\u540e\u4f7f\u7528\uff0c\u56e0\u6b64\u60a8\u4e0d\u5fc5\u6bcf\u6b21\u90fd\u5411 DNS \u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u4ee5\u5efa\u7acb\u8fde\u63a5\u3002 \u4f46\u6709\u65f6\uff0c\u672c\u5730 DNS \u7f13\u5b58\u4f1a\u635f\u574f\u5e76\u5bfc\u81f4 HTTP \u9519\u8bef\u3002\u503c\u5f97\u5e86\u5e78\u7684\u662f\uff0c\u5728 Linux \u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5237\u65b0\u548c\u91cd\u5efa DNS \u7f13\u5b58\u975e\u5e38\u5bb9\u6613\u3002\u8fd9\u662f\u5982\u4f55\u505a\u5230\u7684\u3002 \u4e3a\u4ec0\u4e48\u8981\u5728 Linux \u4e0a\u5237\u65b0 DNS \u7f13\u5b58\uff1f \u60a8\u53ef\u80fd\u60f3\u8981\u91cd\u5efa\u5b58\u50a8\u5728\u7cfb\u7edf\u4e0a\u7684 DNS \u7f13\u5b58\u7684\u539f\u56e0\u6709\u591a\u79cd\u3002\u5982\u679c\u60a8\u7684DNS\u8bb0\u5f55\u8fc7\u65f6\u4e86\uff0c\u60a8\u53ef\u80fd\u60f3\u8981\u4eceDNS\u670d\u52a1\u5668\u91cd\u65b0\u83b7\u53d6\u5b83\u3002\u53e6\u5916\uff0c\u5982\u679c\u60a8\u62c5\u5fc3\u7cfb\u7edf\u53d7\u5230\u5a01\u80c1\u4e86\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u786e\u4fddDNS\u7f13\u5b58\u672a\u88ab\u7be1\u6539\uff0c\u4e5f\u88ab\u79f0\u4e3aDNS\u6b3a\u9a97\u3002 \u5f53\u60a8\u5237\u65b0 DNS \u7f13\u5b58\u65f6\uff0c\u7cfb\u7edf\u5fc5\u987b\u518d\u6b21 ping DNS \u670d\u52a1\u5668\u5e76\u4ece\u4e2d\u83b7\u53d6\u65b0\u7684\u57df IP \u5730\u5740\u8bb0\u5f55\uff0c\u4ece\u800c\u5728\u6b64\u8fc7\u7a0b\u4e2d\u5220\u9664\u4efb\u4f55\u8fc7\u65f6\u6216\u53d7\u635f\u7684\u6570\u636e\u3002 \u5982\u4f55\u5728 Linux \u4e0a\u67e5\u770b\u672c\u5730 DNS \u7f13\u5b58 \u5728systemd\u4e4b\u524d\uff0c\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u90fd\u6ca1\u6709\u7cfb\u7edf\u8303\u56f4\u7684DNS\u7f13\u5b58\uff0c\u9664\u975e\u50cfdnsmasq\u6216nscd\u8fd9\u6837\u7684\u7a0b\u5e8f\u662f\u624b\u52a8\u8bbe\u7f6e\u7684\u3002systemd \u9644\u5e26 systemd-solved\uff0c\u8fd9\u662f\u4e00\u9879\u5c06\u57df\u540d\u89e3\u6790\u4e3a IP \u5730\u5740\u5e76\u7f13\u5b58 DNS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-61128","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=61128"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61128\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}