{"id":12,"date":"2026-01-07T08:05:15","date_gmt":"2026-01-07T08:05:15","guid":{"rendered":"https:\/\/ceshi.303333.xyz\/?p=12"},"modified":"2026-01-07T08:05:15","modified_gmt":"2026-01-07T08:05:15","slug":"debian-%e5%8f%8c%e6%a0%88%e7%bd%91%e7%bb%9c%e6%97%b6%e5%bc%80%e5%90%af-ipv4-%e4%bc%98%e5%85%88","status":"publish","type":"post","link":"https:\/\/www.yun.com.mp\/?p=12","title":{"rendered":"Debian \u53cc\u6808\u7f51\u7edc\u65f6\u5f00\u542f IPv4 \u4f18\u5148"},"content":{"rendered":"\n<p>\u672c\u6587\u539f\u7406\u9002\u7528\u4e8e\u5927\u591a\u6570 Linux \u7cfb\u7edf\uff0c\u5176\u4ed6\u7cfb\u7edf\u5c1a\u672a\u6d4b\u8bd5\uff0c\u8bf7\u8bfb\u8005\u81ea\u884c\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"bei-jing-jie-shao\">\u80cc\u666f\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u53cc\u534f\u8bae\u6808\u6280\u672f\u5c31\u662f\u6307\u5728\u4e00\u53f0\u8bbe\u5907\u4e0a\u540c\u65f6\u542f\u7528 IPv4 \u534f\u8bae\u6808\u548c IPv6 \u534f\u8bae\u6808\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528 IPv4 \u548c IPv6 \u7684\u7f51\u7edc\u3002<\/p>\n\n\n\n<p>\u73b0\u4ee3\u64cd\u4f5c\u7cfb\u7edf\u548c\u6d4f\u89c8\u5668\u901a\u5e38\u4f1a\u4f18\u5148\u4f7f\u7528 IPv6\uff0c\u53ea\u6709\u5f53 IPv6 \u65e0\u6cd5\u8bbf\u95ee\u65f6\uff0c\u624d\u4f1a\u56de\u9000\u5230 IPv4\u3002\u4f46\u5728\u67d0\u4e9b\u7279\u5b9a\u7684\u5e94\u7528\u6216\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u66f4\u5e0c\u671b\u7cfb\u7edf\u4f18\u5148\u4f7f\u7528 IPv4\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"xiu-gai-etc-gai-conf\">\u4fee\u6539 \/etc\/gai.conf<\/h2>\n\n\n\n<p>\u5728 Debian \u7b49 Linux \u7cfb\u7edf\u4e0b\uff0c\u6709\u4e00\u4e2a&nbsp;<code>\/etc\/gai.conf<\/code>&nbsp;\u6587\u4ef6\uff0c\u7528\u4e8e\u7cfb\u7edf\u7684&nbsp;<code>getaddrinfo<\/code>&nbsp;\u8c03\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4f1a\u4f7f\u7528 IPv6 \u4f18\u5148\uff0c\u5982\u679c\u60a8\u5b89\u88c5\u4e86&nbsp;<code>curl<\/code>&nbsp;\u5e76\u4e14\u672c\u5730\u652f\u6301 IPv6\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528&nbsp;<code>curl ip.sb<\/code>&nbsp;\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # curl ip.sb\n2001:db8::2\n<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u4e0e&nbsp;<code>curl ip.sb -6<\/code>&nbsp;\u7b49\u6548\u3002<\/p>\n\n\n\n<p>\u4ece Debian 13 \u5f00\u59cb\uff0ccurl (8.14.1) \u9ed8\u8ba4\u5f3a\u5236\u4f7f\u7528 IPv6\u3002\u56e0\u6b64\uff0c\u5982\u679c\u5e0c\u671b\u6d4b\u8bd5\u672c\u5730\u51fa\u53e3\u516c\u7f51 IP\uff0c\u53ef\u4ee5\u6539\u7528&nbsp;<code>wget<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # wget -qO- http:\/\/ip.sb\n2001:db8::2\n<\/code><\/pre>\n\n\n\n<p>\u6548\u679c\u7b49\u540c\u4e8e&nbsp;<code>wget -qO- http:\/\/ip.sb -6<\/code><\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u4e0d\u60f3\u4f7f\u7528 IPv6 \u4f18\u5148\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u627e\u5230\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#precedence ::ffff:0:0\/96  100\n<\/code><\/pre>\n\n\n\n<p>\u53d6\u6d88\u6ce8\u91ca\uff0c\u4fee\u6539\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>precedence ::ffff:0:0\/96  100\n<\/code><\/pre>\n\n\n\n<p>\u4e00\u884c\u547d\u4ee4\u4fee\u6539\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/#precedence ::ffff:0:0\\\/96  100\/precedence ::ffff:0:0\\\/96  100\/' \/etc\/gai.conf\n<\/code><\/pre>\n\n\n\n<p>\u6b64\u65f6\u518d\u6b21\u6267\u884c&nbsp;<code>curl ip.sb<\/code>&nbsp;\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # curl ip.sb\n192.0.2.2\n<\/code><\/pre>\n\n\n\n<p>\u6548\u679c\u7b49\u540c\u4e8e&nbsp;<code>curl ip.sb -4<\/code><\/p>\n\n\n\n<p>\u4ece Debian 13 \u5f00\u59cb\u7684 curl (8.14.1) \u4f1a\u5f3a\u5236 IPv6 \u4f18\u5148\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528&nbsp;<code>wget<\/code>&nbsp;\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # wget -qO- http:\/\/ip.sb\n192.0.2.2\n<\/code><\/pre>\n\n\n\n<p>\u6548\u679c\u7b49\u540c\u4e8e&nbsp;<code>wget -qO- http:\/\/ip.sb -4<\/code><\/p>\n\n\n\n<p>\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u53c8\u9700\u8981\u5f3a\u5236\u542f\u7528 IPv6 \u4f18\u5148\uff08\u662f\u7684\uff0c\u6709\u4e9b\u7cfb\u7edf\u548c\u7528\u6237\u7684\u9700\u6c42\u786e\u5b9e\u6709\u70b9\u5947\u602a\ud83d\ude05\uff09\uff0c\u56e0\u4e3a\u76ee\u524d IANA \u5206\u914d\u7684\u516c\u7f51 IPv6 \u8fd8\u672a\u8fdb\u884c\u5230&nbsp;<code>3000:0000::\/4<\/code>\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u8981\u628a\u8fd9\u6bb5\u4e4b\u524d\u7684 IPv6 \u52a0\u5230\u4f18\u5148\u7ea7\u5217\u8868\u5373\u53ef\uff0c\u52a0\u5165\u8fd9\u4e24\u884c&nbsp;<code>label<\/code>&nbsp;\u7684\u4f18\u5148\u7ea7\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>label 2002::\/16    1\nlabel 2001:0::\/32   1\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"jin-yong-ipv6\">\u7981\u7528 IPv6<\/h2>\n\n\n\n<p>\u6709\u4e00\u4e9b\u6781\u7aef\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u7981\u6b62\u7cfb\u7edf\u7684 IPv6 \u529f\u80fd\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u6dfb\u52a0\u6216\u4fee\u6539&nbsp;<code>\/etc\/sysctl.d\/local.conf<\/code>&nbsp;\u6587\u4ef6\uff0c\u9996\u5148\u627e\u5230\u4f60\u7684\u7f51\u5361\u540d\u79f0\uff0c\u8fd9\u91cc\u4ee5&nbsp;<code>eth0<\/code>&nbsp;\u4e3a\u4f8b\uff0c\u7136\u540e\u52a0\u5165\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.ipv6.conf.all.autoconf = 0\nnet.ipv6.conf.default.autoconf = 0\nnet.ipv6.conf.all.accept_ra = 0\nnet.ipv6.conf.default.accept_ra = 0\nnet.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\nnet.ipv6.conf.lo.disable_ipv6 = 1\nnet.ipv6.conf.eth0.disable_ipv6 = 1\n<\/code><\/pre>\n\n\n\n<p>\u82e5\u9700\u5bf9\u5176\u4ed6\u7f51\u5361\u7981\u7528 IPv6\uff0c\u53ea\u9700\u5c06&nbsp;<code>eth0<\/code>&nbsp;\u66ff\u6362\u4e3a\u5bf9\u5e94\u7f51\u5361\u540d\u79f0\u5373\u53ef\u3002<\/p>\n\n\n\n<p>\u4e00\u53e5\u8bdd\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &gt;&gt; \/etc\/sysctl.d\/local.conf &lt;&lt; EOF\nnet.ipv6.conf.all.autoconf = 0\nnet.ipv6.conf.default.autoconf = 0\nnet.ipv6.conf.all.accept_ra = 0\nnet.ipv6.conf.default.accept_ra = 0\nnet.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\nnet.ipv6.conf.lo.disable_ipv6 = 1\nnet.ipv6.conf.eth0.disable_ipv6 = 1\nEOF\n<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a<code>cat<\/code>&nbsp;\u547d\u4ee4\u4e2d\u7684&nbsp;<code>&gt;&gt;<\/code>&nbsp;\u8868\u793a\u8ffd\u52a0\u5185\u5bb9\uff1b\u82e5\u4f7f\u7528&nbsp;<code>&gt;<\/code>\uff0c\u5219\u4f1a\u8986\u76d6\u539f\u6709\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u6267\u884c&nbsp;<code>sysctl --system<\/code>&nbsp;\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u3002\u6b64\u65f6\u67e5\u770b&nbsp;<code>ip a<\/code>\uff0c\u5373\u53ef\u53d1\u73b0 IPv6 \u5df2\u88ab\u7981\u7528\u3002<\/p>\n\n\n\n<p>\u4e0b\u56fe\u4e3a\u4fee\u6539\u524d\u540e\u7684\u5bf9\u6bd4\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p>\u4f7f\u7528\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u65e0\u8bba\u662f\u672c\u5730\u8fd8\u662f\u516c\u7f51\u7f51\u5361\u90fd\u6709&nbsp;<code>inet6<\/code>\uff0c\u5373\u90fd\u6709 IPv6 \u5730\u5740\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/s.u.sb\/uploads\/2022\/02\/10\/oyKXC1YLbu2Mi6j.png\" alt=\"image.png\"\/><\/figure>\n\n\n\n<p>\u4f7f\u7528\u540e\uff0c\u65e0\u8bba\u672c\u5730\u8fd8\u662f\u516c\u7f51\u7f51\u5361\u5747\u65e0 IPv6 \u5730\u5740\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/s.u.sb\/uploads\/2022\/02\/10\/qi2nwjWeLfQXJH4.png\" alt=\"image.png\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"qi-ta-xi-tong-he-ruan-jian\">\u5176\u4ed6\u7cfb\u7edf\u548c\u8f6f\u4ef6<\/h2>\n\n\n\n<p>Windows \u7cfb\u7edf\u53ef\u53c2\u8003<a href=\"https:\/\/superuser.com\/questions\/436574\/ipv4-vs-ipv6-priority-in-windows-7\">\u8fd9\u7bc7\u56de\u7b54<\/a><\/p>\n\n\n\n<p>Firefox \u4e0b\u6253\u5f00&nbsp;<code>about:config<\/code>&nbsp;\u7136\u540e\u628a&nbsp;<code>network.dns.disableIPv6<\/code>&nbsp;\u6539\u6210&nbsp;<code>true<\/code>&nbsp;\u5373\u53ef\u7981\u6b62 Firefox \u8bf7\u6c42 IPv6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u539f\u7406\u9002\u7528\u4e8e\u5927\u591a\u6570 Linux \u7cfb\u7edf\uff0c\u5176\u4ed6\u7cfb\u7edf\u5c1a\u672a\u6d4b\u8bd5\uff0c\u8bf7\u8bfb\u8005\u81ea\u884c\u9a8c\u8bc1\u3002 \u80cc\u666f\u4ecb\u7ecd \u53cc\u534f\u8bae\u6808\u6280\u672f\u5c31\u662f\u6307\u5728\u4e00\u53f0\u8bbe\u5907\u4e0a\u540c\u65f6\u542f\u7528 IPv4 \u534f\u8bae\u6808\u548c IPv6 \u534f\u8bae\u6808\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u540c\u65f6\u4f7f\u7528 IPv4 \u548c IPv6 \u7684\u7f51\u7edc\u3002 \u73b0\u4ee3\u64cd\u4f5c\u7cfb\u7edf\u548c\u6d4f\u89c8\u5668\u901a\u5e38\u4f1a\u4f18\u5148\u4f7f\u7528 IPv6\uff0c\u53ea\u6709\u5f53 IPv6 \u65e0\u6cd5\u8bbf\u95ee\u65f6\uff0c\u624d\u4f1a\u56de\u9000\u5230 IPv4\u3002\u4f46\u5728\u67d0\u4e9b\u7279\u5b9a\u7684\u5e94\u7528\u6216\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u66f4\u5e0c\u671b\u7cfb\u7edf\u4f18\u5148\u4f7f\u7528 IPv4\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u8c03\u6574\u3002 \u4fee\u6539 \/etc\/gai.conf \u5728 Debian \u7b49 Linux \u7cfb\u7edf\u4e0b\uff0c\u6709\u4e00\u4e2a&nbsp;\/etc\/gai.conf&nbsp;\u6587\u4ef6\uff0c\u7528\u4e8e\u7cfb\u7edf\u7684&nbsp;getaddrinfo&nbsp;\u8c03\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4f1a\u4f7f\u7528 IPv6 \u4f18\u5148\uff0c\u5982\u679c\u60a8\u5b89\u88c5\u4e86&nbsp;curl&nbsp;\u5e76\u4e14\u672c\u5730\u652f\u6301 IPv6\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528&nbsp;curl ip.sb&nbsp;\u6d4b\u8bd5\uff1a \u7ed3\u679c\u4e0e&nbsp;curl ip.sb -6&nbsp;\u7b49\u6548\u3002 \u4ece Debian 13 \u5f00\u59cb\uff0ccurl (8.14.1) \u9ed8\u8ba4\u5f3a\u5236\u4f7f\u7528 IPv6\u3002\u56e0\u6b64\uff0c\u5982\u679c\u5e0c\u671b\u6d4b\u8bd5\u672c\u5730\u51fa\u53e3\u516c\u7f51 IP\uff0c\u53ef\u4ee5\u6539\u7528&nbsp;wget\uff1a \u6548\u679c\u7b49\u540c\u4e8e&nbsp;wget -qO- http:\/\/ip.sb -6 \u5982\u679c\u4f60\u4e0d\u60f3\u4f7f\u7528 IPv6 \u4f18\u5148\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u627e\u5230\uff1a \u53d6\u6d88\u6ce8\u91ca\uff0c\u4fee\u6539\u4e3a\uff1a \u4e00\u884c\u547d\u4ee4\u4fee\u6539\uff1a \u6b64\u65f6\u518d\u6b21\u6267\u884c&nbsp;curl ip.sb&nbsp;\u6d4b\u8bd5\uff1a \u6548\u679c\u7b49\u540c\u4e8e&nbsp;curl ip.sb -4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":1,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":13,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions\/13"}],"wp:attachment":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}