{"id":737,"date":"2026-03-09T00:17:14","date_gmt":"2026-03-08T16:17:14","guid":{"rendered":"https:\/\/blog.xmb505.top\/?p=737"},"modified":"2026-03-09T00:17:23","modified_gmt":"2026-03-08T16:17:23","slug":"%e4%b8%89%e4%b8%80%e5%b7%a5%e5%ad%a6%e9%99%a2%e6%a0%a1%e5%9b%ad%e7%bd%91%e7%a8%b3%e5%ae%9a%e6%9c%af-%e4%ba%8c%e5%b1%82ttl%e9%80%8f%e6%98%8e%e4%bf%ae%e6%94%b9","status":"publish","type":"post","link":"https:\/\/blog.xmb505.top\/index.php\/2026\/03\/09\/%e4%b8%89%e4%b8%80%e5%b7%a5%e5%ad%a6%e9%99%a2%e6%a0%a1%e5%9b%ad%e7%bd%91%e7%a8%b3%e5%ae%9a%e6%9c%af-%e4%ba%8c%e5%b1%82ttl%e9%80%8f%e6%98%8e%e4%bf%ae%e6%94%b9\/","title":{"rendered":"\u4e09\u4e00\u5de5\u5b66\u9662\u6821\u56ed\u7f51\u7a33\u5b9a\u672f\u2014\u2014\u4e8c\u5c42TTL\u900f\u660e\u4fee\u6539"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u60c5\u63d0\u8981<\/h2>\n\n\n\n<p>\u4e09\u4e00\u5de5\u5b66\u966226\u5e74\u4e0a\u5b66\u671f\u91c7\u7528\u4e86\u65b0\u7684\u6821\u56ed\u7f51\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u622a\u81f3\u73b0\u5728\u4f5c\u8005\u4ecd\u7136\u8ba4\u4e3a\u8fd9\u4e2a\u6821\u56ed\u7f51\u7cfb\u7edf\u975e\u5e38\u5783\u573e\u3002\u4e0d\u8fc7\u65e5\u5b50\u8fd8\u662f\u8981\u8fc7\u7684\uff0cNAT\u8fd8\u662f\u8981\u8dd1\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u5f00\u59cb\u7814\u7a76\u5982\u4f55\u5355\u53f7\u591a\u7528\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9002\u7528\u4eba\u7fa4<\/h2>\n\n\n\n<p>\u65e0\u957f\u6587\u672c\u9605\u8bfb\u969c\u788d \/ \u5177\u5907\u4e00\u5b9a\u7f51\u7edc\u77e5\u8bc6 \/ \u5177\u5907\u4e00\u5b9a\u7684 OpenWRT \u77e5\u8bc6 \/ \u5177\u5907\u4e00\u5b9a\u7684 Linux \u77e5\u8bc6<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u9488\u5bf9\u73b0\u8c61<\/h2>\n\n\n\n<p>\u6821\u56ed\u7f51\u62e8\u53f7\u4e0d\u7a33\u5b9a\uff0c\u8fd0\u8425\u5546\u7ecf\u5e38\u8e22\u7ebf\uff0c\u4e00\u5b9a\u7f13\u89e3\uff0c\u4e0d\u4fdd\u8bc1\u5b8c\u5168\u4fee\u590d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p>\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u539f\u7248 OpenWRT \u6765\u5e2e\u52a9\u6211\u4eec\u5b9e\u73b0\u8fd9\u4e2a\u4e2d\u95f4\u4eba\u4fee\u6539\uff0c\u800c\u4e14\u6211\u4eec\u9700\u8981\u4e09\u4e2a\u7f51\u7edc\u63a5\u53e3\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LAN\u53e3\uff08\u7ba1\u7406+\u4e0a\u7f51\u7528\uff09<\/li>\n\n\n\n<li>TTL\u4e0a\u6e38\u53e3\uff08\u8fde\u63a5\u6821\u56ed\u7f51\uff09<\/li>\n\n\n\n<li>TTL\u4e0b\u6e38\u53e3\uff08\u8f93\u51fa\u88ab\u4fee\u6539\u540e\u7684\u6570\u636e\u5305\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u6838\u5fc3\u8def\u5f84\uff1a<strong>\u6865\u63a5 + br_netfilter + iptables legacy TTL target<\/strong>\uff08nftables \u5728\u7eaf\u6865\u63a5\u4e0b\u4fee\u6539 TTL \u7ecf\u5e38\u4e0d\u7a33\u5b9a\uff0ciptables legacy \u66f4\u53ef\u9760\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b8c\u6574\u6b65\u9aa4\uff08\u9002\u7528\u4e8e x86\/64 \u7b49\u901a\u7528\u5e73\u53f0\uff09<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u7f51\u7edc\u914d\u7f6e\uff08\u4fdd\u6301\u7eaf L2 \u6865\u63a5\uff09<\/strong>Bash<code># \/etc\/config\/network \u5173\u952e\u90e8\u5206 config device option name 'br-ttl' option type 'bridge' list ports 'eth0' # \u4e0b\u6e38\uff08\u63a5\u6b21\u7ea7\u8def\u7531\uff09 list ports 'eth2' # \u4e0a\u6e38\uff08\u63a5\u4e3b\u8def\u7531\uff09 config interface 'ttl' option device 'br-ttl' option proto 'none' # \u5fc5\u987b\u662f none\uff0c\u4fdd\u6301\u900f\u660e<\/code>\u91cd\u542f\u7f51\u7edc\uff1aBash<code>\/etc\/init.d\/network restart<\/code><\/li>\n\n\n\n<li><strong>\u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6\u5305<\/strong>Bash<code>opkg update opkg install kmod-br-netfilter iptables-zz-legacy iptables-mod-ipopt kmod-ipt-ipopt<\/code><\/li>\n\n\n\n<li><strong>\u52a0\u8f7d br_netfilter \u5e76\u542f\u7528\u6865\u63a5\u6d41\u91cf\u8fdb\u5165 iptables<\/strong>Bash<code>modprobe br_netfilter # \u6301\u4e45\u5316 echo \"br_netfilter\" > \/etc\/modules.d\/99-br_netfilter # \u5173\u952e sysctl \u8bbe\u7f6e\uff08\u8ba9\u6865\u63a5\u5305\u8fdb\u5165 netfilter\uff09 cat &lt;&lt; EOF >> \/etc\/sysctl.conf net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-arptables = 1 EOF sysctl -p<\/code>\u91cd\u542f\u7f51\u7edc\u786e\u8ba4\u751f\u6548\uff1aBash<code>\/etc\/init.d\/network restart sysctl net.bridge.bridge-nf-call-iptables # \u5fc5\u987b\u8f93\u51fa = 1<\/code><\/li>\n\n\n\n<li><strong>\u5173\u95ed flow offloading\uff08\u5fc5\u987b\uff0c\u5426\u5219\u7ed5\u8fc7 mangle\uff09<\/strong>Bash<code>uci set firewall.@defaults[0].flow_offloading='0' uci set firewall.@defaults[0].flow_offloading_hw='0' uci commit firewall \/etc\/init.d\/firewall restart<\/code><\/li>\n\n\n\n<li><strong>\u6dfb\u52a0 iptables mangle \u89c4\u5219\uff08\u7edf\u4e00\u6539 TTL \u4e3a 64\uff09<\/strong>Bash<code># \u6e05\u7a7a\u65e7\u89c4\u5219\uff08\u53ef\u9009\uff09 iptables -t mangle -F # \u63d2\u5165\u89c4\u5219\uff08-I \u653e\u5728\u94fe\u9876\uff0c\u4f18\u5148\u7ea7\u6700\u9ad8\uff09 iptables -t mangle -I PREROUTING -i br-ttl -j TTL --ttl-set 64 iptables -t mangle -I POSTROUTING -o br-ttl -j TTL --ttl-set 64 # \u6216\u8005\u66f4\u7cbe\u786e\uff08\u53ea\u9488\u5bf9\u8fdb\u51fa eth0\/eth2\uff0c\u907f\u514d\u5f71\u54cd\u7ba1\u7406\u53e3\uff09 iptables -t mangle -I PREROUTING -i eth0 -j TTL --ttl-set 64 iptables -t mangle -I PREROUTING -i eth2 -j TTL --ttl-set 64 iptables -t mangle -I POSTROUTING -o eth0 -j TTL --ttl-set 64 iptables -t mangle -I POSTROUTING -o eth2 -j TTL --ttl-set 64<\/code><\/li>\n\n\n\n<li><strong>\u6301\u4e45\u5316\u89c4\u5219<\/strong> \u628a\u4e0a\u9762\u56db\u6761\uff08\u6216\u4e24\u6761\uff09iptables \u547d\u4ee4\u5199\u5165 \/etc\/firewall.user\uff1aBash<code>vi \/etc\/firewall.user<\/code>\u5185\u5bb9\u793a\u4f8b\uff1atext<code>iptables -t mangle -I PREROUTING -i br-ttl -j TTL --ttl-set 64 iptables -t mangle -I POSTROUTING -o br-ttl -j TTL --ttl-set 64<\/code>\u7136\u540e\uff1aBash<code>\/etc\/init.d\/firewall restart<\/code><\/li>\n\n\n\n<li><strong>\u9a8c\u8bc1<\/strong>Bash<code># \u67e5\u770b\u89c4\u5219\u662f\u5426\u5728\u94fe\u91cc &amp; \u8ba1\u6570\u662f\u5426\u4e0a\u6da8 iptables -t mangle -L -v -n # \u6293\u4e0a\u6e38\u51fa\u53bb\u7684 ICMP request\uff0c\u770b ttl \u662f\u5426\u5df2\u6539\u6210 64 tcpdump -i eth2 -nnvv 'icmp[icmptype] = 8' -c 10<\/code>\u6b63\u5e38\u7ed3\u679c\uff1a\u4e0b\u6e38\u8bbe\u5907\u53d1\u51fa\u7684 echo request \u5728 eth2 \u4e0a\u770b\u5230 ttl = 64\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e38\u89c1\u95ee\u9898\u5feb\u901f\u5904\u7406<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TTL \u6ca1\u53d8\uff1f \u2192 \u786e\u8ba4 net.bridge.bridge-nf-call-iptables = 1 \u2192 \u786e\u8ba4 flow_offloading \u5df2\u5173 \u2192 \u786e\u8ba4\u89c4\u5219\u8ba1\u6570\u5728\u6da8\uff08pkts > 0\uff09<\/li>\n\n\n\n<li>\u60f3\u6539\u6210\u5176\u4ed6\u503c\uff08\u5982 65\u3001128\uff09 \u2192 \u628a &#8211;ttl-set 64 \u6539\u6210\u5bf9\u5e94\u6570\u5b57\u5373\u53ef<\/li>\n\n\n\n<li>IPv6\uff08Hop Limit\uff09 \u2192 \u7528 ip6tables\uff1aBash<code>ip6tables -t mangle -I PREROUTING -i br-ttl -j HL --hl-set 64 ip6tables -t mangle -I POSTROUTING -o br-ttl -j HL --hl-set 64<\/code><\/li>\n\n\n\n<li>\u89c4\u5219\u91cd\u542f\u4e22\u5931\uff1f \u2192 \u786e\u8ba4\u5199\u5728 \/etc\/firewall.user \u91cc<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u5c31\u662f\u76ee\u524d\u5728 OpenWrt 24.10.5 \u4e0a\u6700\u7a33\u5b9a\u3001\u793e\u533a\u9a8c\u8bc1\u6700\u591a\u7684<strong>\u7eaf\u4e8c\u5c42\u900f\u660e\u4fee\u6539 TTL<\/strong> \u65b9\u6848\uff082025\u20132026 \u5e74\u4e3b\u6d41\u505a\u6cd5\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u60c5\u63d0\u8981 \u4e09\u4e00\u5de5\u5b66\u966226\u5e74\u4e0a\u5b66\u671f\u91c7\u7528\u4e86\u65b0\u7684\u6821\u56ed\u7f51\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u622a\u81f3\u73b0\u5728\u4f5c\u8005\u4ecd\u7136\u8ba4\u4e3a\u8fd9\u4e2a\u6821\u56ed\u7f51\u7cfb\u7edf\u975e\u5e38\u5783\u573e\u3002\u4e0d\u8fc7\u65e5\u5b50 [&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-737","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/posts\/737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/comments?post=737"}],"version-history":[{"count":1,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/posts\/737\/revisions"}],"predecessor-version":[{"id":738,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/posts\/737\/revisions\/738"}],"wp:attachment":[{"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/media?parent=737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/categories?post=737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xmb505.top\/index.php\/wp-json\/wp\/v2\/tags?post=737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}