{"id":12521,"date":"2023-07-21T14:18:32","date_gmt":"2023-07-21T06:18:32","guid":{"rendered":"http:\/\/jc.a300.cn/luyouwang\/?p=12521"},"modified":"2023-07-21T14:18:32","modified_gmt":"2023-07-21T06:18:32","slug":"%e8%b7%af%e7%94%b1%e5%99%a8%e5%bc%80%e5%90%afipv6%ef%bc%8cwifi%e8%ae%bf%e9%97%ae%e5%8f%98%e6%85%a2%e7%94%9a%e8%87%b3%e6%89%93%e4%b8%8d%e5%bc%80%e7%bd%91%e9%a1%b5%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/jc.a300.cn/luyouwang\/12521.html","title":{"rendered":"\u8def\u7531\u5668\u5f00\u542fIPv6\uff0cwifi\u8bbf\u95ee\u53d8\u6162\u751a\u81f3\u6253\u4e0d\u5f00\u7f51\u9875\u600e\u4e48\u529e\uff1f"},"content":{"rendered":"

\u6709\u4e9b\u7528\u6237\u9047\u5230\u5149\u732b\u6216\u8005\u8def\u7531\u5668\u5f00\u542fipv6\u540e\uff0c\u53d1\u73b0\u7535\u8111\u624b\u673a\u624b\u673a\u65e0\u7ebf\u8fde\u63a5wifi\u4e0a\u7f51\u6162\uff0c\u6709\u65f6\u5019\u7f51\u9875\u90fd\u6253\u4e0d\u5f00\u4e86\uff0c\u6bd4\u5982\u4eca\u65e5\u5934\u6761\u3001\u4e91\u95ea\u4ed8\u3001\u4eac\u4e1c\u91d1\u878d\u7684\u90e8\u5206\u9875\u9762\u6162\u5f97\u50cf\u4e4c\u9f9f\u722c\uff0c\u4e91\u95ea\u4ed8\u7b7e\u5230\u9875\u9762\u76f4\u63a5\u6253\u4e0d\u5f00\uff0c\u4e0b\u9762\u6765\u8bb2\u8bb2\u89e3\u51b3\u529e\u6cd5\u3002<\/p>\n

\"IPv6\"<\/a>
IPv6<\/figcaption><\/figure>\n

\u53d1\u73b0\u6700\u8fd1\u7ecf\u5e38\u6709\u4eba\u63d0\u5230\u5f00\u542f IPv6 \u8fde\u63a5\u901f\u5ea6\u6162\u7684\u95ee\u9898\u3002\u76ee\u524d\u56fd\u5185\u786e\u5b9e\u5b58\u5728\u652f\u6301 IPv6 \u7684\u670d\u52a1\u5668\u3001CDN \u8282\u70b9\u4e0d\u591f\u591a\uff0cIPv6 \u56fd\u9645\u5e26\u5bbd\u6bd4 IPv4 \u5e26\u5bbd\u5c0f\u7684\u95ee\u9898\uff0c\u4f46\u4e5f\u4e0d\u81f3\u4e8e\u4f1a\u6253\u5f00\u56fd\u5185\u7f51\u7ad9\u90fd\u5361\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u8bf4\u660e\u4f60\u5230\u76ee\u6807\u670d\u52a1\u5668\u7684\u94fe\u8def\u4e0a\u5b58\u5728 PMTU \u9ed1\u6d1e\u3002<\/p>\n

\u5173\u4e8e PMTU \u9ed1\u6d1e<\/strong><\/p>\n

MTU (Maximum transmission unit) \u662f\u4e00\u6761\u94fe\u8def\u4e0a\u53ef\u4ee5\u901a\u8fc7\u7684\u4e09\u5c42\u6570\u636e\u5305\u7684\u6700\u5927\u5c3a\u5bf8\uff08\u5305\u542b IP \u5305\u5934\uff09\u3002\u4ee5\u592a\u7f51\u4e0a\u9ed8\u8ba4\u7684 MTU \u662f 1500 \u5b57\u8282\uff0c\u4f46\u662f\u4f60\u548c\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8def\u5f84\u4e0a\u53ef\u80fd\u5b58\u5728\u5c0f\u4e8e MTU 1500 \u7684\u94fe\u8def\u3002\u8fd9\u6761\u8def\u5f84\u4e0a\u6700\u5c0f\u7684 MTU \u503c\u5c31\u662f\u6574\u6761\u8def\u5f84\u7684 PMTU \u503c\u3002\u8def\u7531\u5668\u5728\u8f6c\u53d1\u5305\u65f6\uff0c\u8d85\u8fc7 MTU \u5927\u5c0f\u7684\u5305\u4f1a\u88ab\u5206\u7247\uff08 Fragmentation \uff09\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a\u5927\u5305\u4f1a\u88ab\u5206\u5207\u4e3a\u591a\u4e2a\u4e0d\u8d85\u8fc7 MTU \u7684\u5c0f\u5305\u8fdb\u884c\u4f20\u8f93\uff0c\u4f20\u8f93\u6548\u7387\u4f1a\u4e0b\u964d\u3002<\/p>\n

\u7ec8\u7aef\u8bbe\u5907\u5728\u53d1\u5305\u65f6\uff0c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e DF \uff08 Don't Fragment \uff09\u6807\u8bb0\u6765\u544a\u8bc9\u8def\u7531\u5668\u4e0d\u8981\u5206\u7247\u3002\u8fd9\u65f6\u4e2d\u95f4\u8def\u7531\u5668\u4f1a\u4e22\u6389\u8d85\u8fc7 MTU \u7684\u5305\uff0c\u56de\u590d\u4e00\u6761 ICMP Fragmentation Needed \u6d88\u606f\u3002\u53d1\u9001\u8005\u6536\u5230\u8fd9\u4e2a\u5305\u540e\uff0c\u4e0b\u6b21\u5c31\u4f1a\u53d1\u5c0f\u4e00\u70b9\u7684\u5305\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53eb\u505a PMTU Discovery \u3002\u73b0\u5b9e\u4e2d\u53ef\u4ee5\u770b\u5230 HTTPS \uff08 TLS \uff09\u7684\u6d41\u91cf\u5927\u90fd\u662f\u5e26 DF \u6807\u8bb0\u7684\u3002<\/p>\n

\u7136\u800c\uff0c\u4e92\u8054\u7f51\u4e0a\u6709\u5927\u91cf\u7684\u4e2d\u95f4\u8bbe\u5907\u4e3a\u4e86\u6240\u8c13\u7684\u201c\u5b89\u5168\u201d\u6216\u8005\u6ca1\u6709\u6b63\u786e\u914d\u7f6e\uff0c\u4e0d\u56de\u5e94 ICMP Fragmentation Needed \u5305\uff0c\u8fd9\u4f7f\u5f97\u8bbf\u95ee\u67d0\u4e9b\u7f51\u7ad9\u65f6\u5982\u679c\u67d0\u4e2a\u5305\u7684\u5927\u5c0f\u8d85\u8fc7\u4e86 PMTU\uff0c\u4f1a\u88ab\u65e0\u58f0\u5730\u4e22\u5f03\uff0c\u76f4\u5230 TCP \u534f\u8bae\u53d1\u73b0\u8d85\u65f6\u4e22\u5305\u8fdb\u884c\u91cd\u4f20\uff0c\u8fd9\u975e\u5e38\u7f13\u6162\u3002\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u8bf4\u4f60\u548c\u76ee\u6807\u670d\u52a1\u5668\u7684\u8def\u5f84\u4e0a\u5b58\u5728 PMTU \u9ed1\u6d1e\u3002<\/p>\n

\u6b64\u5916\uff0cIPv6 \u4e0d\u652f\u6301\u5206\u7247\uff0c\u6362\u53e5\u8bdd\u8bf4\u53ef\u4ee5\u7406\u89e3\u4e3a IPv6 \u4e0b\u6240\u6709\u7684\u5305\u90fd\u662f\u5e26 DF \u6807\u8bb0\u7684\u3002\u4e2d\u95f4\u8def\u7531\u5668\u5728\u9047\u5230\u5305\u5c3a\u5bf8\u5927\u4e8e MTU \u7684\u60c5\u51b5\u65f6\uff0c\u5e94\u8be5\u56de\u5e94 ICMPv6 Packet Too Big \u6d88\u606f\u3002\u540c\u6837\u7684\uff0c\u7531\u4e8e\u79cd\u79cd\u539f\u56e0\uff0c\u67d0\u4e9b\u4e2d\u95f4\u8bbe\u5907\u53ef\u80fd\u4f1a\u76f4\u63a5\u4e22\u5305\u800c\u4e0d\u56de\u5e94 ICMPv6 Packet Too Big \u6d88\u606f\uff0c\u76f4\u5230 TCP \u534f\u8bae\u53d1\u73b0\u8d85\u65f6\u4e22\u5305\u8fdb\u884c\u91cd\u4f20\u3002\u3002\u3002<\/p>\n

\u4e3a\u4ec0\u4e48 IPv4 \u6ca1\u6709\u8fd9\u4e2a\u95ee\u9898\uff1f<\/strong><\/p>\n

\u5176\u5b9e IPv4 \u4e5f\u6709\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4e0d\u53ea\u4e00\u6b21\u89c1\u7f51\u53cb\u8bf4\u81ea\u5df1\u642d\u7684\u8f6f\u8def\u7531\u8bbf\u95ee\u67d0\u4e9b\u7f51\u7ad9\u975e\u5e38\u6162\uff0c\u800c\u6362\u56de\u786c\u8def\u7531\u5c31\u6b63\u5e38\u3002\u8fd9\u662f\u56e0\u4e3a\u591a\u6570\u5bb6\u7528\u8def\u7531\u5668\u9ed8\u8ba4\u5bf9 IPv4 \u4e0b\u7684 TCP \u5f00\u542f\u4e86 MSS (maximum segment size) Clamping \uff08\u4f7f\u7528 OpenWRT \u8f6f\u8def\u7531\u7684\u670b\u53cb\u4eec\u53ef\u4ee5\u5728\u9632\u706b\u5899\u8bbe\u7f6e\u4e2d\u627e\u5230 MSS Clamping \u5f00\u5173\uff09\u3002MSS Clamping \u662f\u9488\u5bf9 PMTU \u9ed1\u6d1e\u7684 Workaround\uff0c\u7b80\u5355\u6765\u8bf4\u5c31\u662f TCP \u63e1\u624b\u65f6\u6709\u4e2a MSS \u5b57\u6bb5\u51b3\u5b9a\u5355\u4e2a TCP \u5305\u7684\u6700\u5927\u5c3a\u5bf8\u3002\u8def\u7531\u5668\u53ef\u4ee5\u901a\u8fc7\u55c5\u63a2 TCP \u63e1\u624b\u5305\uff0c\u628a MSS \u503c\u6539\u5c0f\uff0c\u4f7f\u6700\u7ec8\u7684\u4e09\u5c42 IP \u5305\u7684\u5c3a\u5bf8\uff08 MSS+TCP \u5934\u5927\u5c0f+IP \u5934\u5927\u5c0f\uff09\u4e0d\u8d85\u8fc7\u67d0\u4e2a\u7279\u5b9a\u7684\u503c\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/strong><\/p>\n

\u73b0\u5728\u56fd\u5185 ISP \u4e00\u822c\u90fd\u662f\u901a\u8fc7 PPPoE \u865a\u62df\u62e8\u53f7\u5efa\u7acb WAN \u53e3\u8fde\u63a5\u7684\u3002Ethernet \u7684\u9ed8\u8ba4 MTU \u662f 1500\uff0c\u4f46\u662f PPPoE \u96a7\u9053\u6709 8 \u4e2a bytes \u7684\u5f00\u9500\uff0c\u6240\u4ee5 PPPoE \u865a\u8fde\u63a5\u7684 MTU \u5c31\u662f 1500-8=1492\uff0c\u51cf\u6389 IPv4 \u5305\u5934\uff08 20 \u5b57\u8282\uff09\u548c TCP \u5305\u5934\uff08 20 \u5b57\u8282\uff09\uff0c\u53ef\u4ee5\u5f97\u77e5 IPv4 \u4e0b\u9700\u8981\u628a MSS \u8bbe\u4e3a 1452 \u4ee5\u4e0b\u3002<\/p>\n

IPv6 \u7684\u5305\u5934\u662f 40 \u5b57\u8282\uff0c\u6240\u4ee5 IPv6 \u4e0b\u9700\u8981\u628a MSS \u8bbe\u4e3a 1432 \u4ee5\u4e0b\u3002<\/p>\n

\u8fd9\u65f6\u95ee\u9898\u6765\u4e86\uff0c\u76ee\u524d\u5f88\u591a\u5149\u732b\u3001\u5bb6\u7528\u8def\u7531\u5668\u5bf9 IPv6 \u7684\u4f18\u5316\u5f88\u5dee\uff0c\u4e0d\u652f\u6301\u5bf9 IPv6 \u4e0b\u7684 TCP \u5305\u8fdb\u884c MSS Clamping\uff0c\u8fd9\u5c31\u5bfc\u81f4\u8bbf\u95ee IPv6 \u7f51\u7ad9\u65f6\uff0c\u82e5\u8def\u5f84\u4e2d\u5b58\u5728 PMTU \u9ed1\u6d1e\uff0c\u5219\u6253\u5f00\u5f88\u6162\u3002<\/p>\n

\u6211\u524d\u6bb5\u65f6\u95f4\u5e2e\u670b\u53cb\u914d\u7f6e IPv6 \u65f6\u53d1\u73b0\u4e86\u5f88\u591a\u5149\u732b\u3001\u5bb6\u7528\u8def\u7531\u5668\u7684\u56fa\u4ef6\u95ee\u9898\uff0c\u4f7f\u5f97\u56fd\u5185\u4f7f\u7528 IPv6 \u7684\u4f53\u9a8c\u4e0d\u592a\u7406\u60f3\u3002\u6211\u6253\u7b97\u62bd\u7a7a\u4e13\u95e8\u5f00\u4e00\u4e2a\u5e16\u5b50\u53bb\u8ba8\u8bba\u8fd9\u4e9b\u95ee\u9898\uff0c\u58f0\u8ba8\u90a3\u4e9b\u5783\u573e\u5382\u5bb6\u3002\u76ee\u524d\u6765\u770b\uff0c\u8981\u60f3\u5728\u56fd\u5185\u6bd4\u8f83\u7406\u60f3\u5730\u4f53\u9a8c IPv6\uff0c\u4f60\u9700\u8981\u628a\u5149\u732b\u6539\u4e3a\u6865\u63a5\u6a21\u5f0f\uff0c\u5e76\u4f7f\u7528 OpenWRT \u6216\u8005 VyOS \u8fd9\u7c7b\u5bf9 IPv6 \u652f\u6301\u8f83\u597d\u7684\u8f6f\u8def\u7531\u3002<\/p>\n

\u9644\uff1a\u5728\u57fa\u4e8e Linux \u7684\u8def\u7531\u5668\u542f\u7528MSS Clamping\u7684\u547d\u4ee4\uff1a<\/strong><\/p>\n

\u81ea\u52a8MSS\uff0c\u5047\u8bbePPPOE\u865a\u63a5\u53e3\u662fpppoe0<\/p>\n

iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o pppoe0 -j TCPMSS --clamp-mss-to-pmtu\r\n\r\nip6tables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o pppoe0 -j TCPMSS --clamp-mss-to-pmtu<\/pre>\n

\u624b\u52a8\u6307\u5b9aMSS\uff0c\u5047\u8bbePPPOE\u865a\u63a5\u53e3\u662fpppoe0<\/p>\n

$ iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o pppoe0 -j TCPMSS --set-mss 1452\r\n\r\n$ ip6tables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o pppoe0 -j TCPMSS --set-mss 1432<\/pre>\n

RouterOS\u91cc\u8bbe\u7f6eMSS\u7684\u547d\u4ee4\u3002\u5176\u4e2dpppoe-out1\u662fwan\u53e3\uff0c1420\u662f\u8981MSS\u503c\uff0c\u8bf7\u6839\u636e\u9700\u8981\u4fee\u6539\u3002<\/p>\n

\/ipv6 firewall mangle add chain=forward out-interface=pppoe-out1 protocol=tcp tcp-flags=syn action=change-mss new-mss=1420<\/pre>\n

UBNT Edgerouter \u7cfb\u5217\u7684MSS\u8bbe\u7f6e\u65b9\u6cd5\uff1a<\/p>\n

set firewall options mss-clamp6 interface-type pppoe\r\n\r\nset firewall options mss-clamp6 mss 1420<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6709\u4e9b\u7528\u6237\u9047\u5230\u5149\u732b\u6216\u8005\u8def\u7531\u5668\u5f00\u542fipv6\u540e\uff0c\u53d1\u73b0\u7535\u8111\u624b\u673a\u624b\u673a\u65e0\u7ebf\u8fde\u63a5wifi\u4e0a\u7f51\u6162\uff0c\u6709\u65f6\u5019\u7f51\u9875\u90fd\u6253\u4e0d\u5f00\u4e86\uff0c\u6bd4\u5982\u4eca\u65e5\u5934\u6761\u3001\u4e91\u95ea\u4ed8\u3001\u4eac\u4e1c\u91d1\u878d\u7684\u90e8\u5206\u9875\u9762\u6162\u5f97\u50cf\u4e4c\u9f9f\u722c\uff0c\u4e91\u95ea\u4ed8\u7b7e\u5230\u9875\u9762\u76f4\u63a5\u6253\u4e0d\u2026<\/p>\n","protected":false},"author":13995,"featured_media":7342,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1459],"tags":[5217,5218,5219,5216],"attr":[],"class_list":{"0":"post-12521","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-modem","8":"tag-ipv6","12":"entry"},"views":5511,"_links":{"self":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts\/12521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/users\/13995"}],"replies":[{"embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/comments?post=12521"}],"version-history":[{"count":0,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/posts\/12521\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/media\/7342"}],"wp:attachment":[{"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/media?parent=12521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/categories?post=12521"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/tags?post=12521"},{"taxonomy":"attr","embeddable":true,"href":"http:\/\/jc.a300.cn/luyouwang\/wp-json\/wp\/v2\/attr?post=12521"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}