{"id":2016,"date":"2023-06-01T01:40:54","date_gmt":"2023-05-31T17:40:54","guid":{"rendered":"https:\/\/flandre-scarlet.moe\/blog\/?p=2016"},"modified":"2025-05-25T01:41:24","modified_gmt":"2025-05-24T17:41:24","slug":"%e7%94%a8%e8%99%9a%e6%8b%9f%e6%9c%ba%e6%90%ad%e5%bb%ba-openwrt-%e9%80%8f%e6%98%8e%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/flandre-scarlet.moe\/blog\/2016\/","title":{"rendered":"\u7528\u865a\u62df\u673a\u642d\u5efa OpenWrt \u900f\u660e\u4ee3\u7406"},"content":{"rendered":"<p>\u56e0\u4e3a\u6709\u4e9b\u8f6f\u4ef6\u4e0d\u652f\u6301\u4e3b\u52a8\u8bbe\u7f6e\u4ee3\u7406\uff0c\u6240\u4ee5\u6709\u65f6\u5019\u8fd8\u5f97\u5f00\u4e2a\u900f\u660e\u4ee3\u7406\uff0c\u5728\u5b9e\u9645\u4e70\u8bbe\u5907\u524d\u5148\u7528\u865a\u62df\u673a\u5b89\u88c5 OpenWrt \u5b9e\u9a8c\u4e00\u628a\u3002<br \/>\n\u4e00\u5f00\u59cb\u60f3\u7740\u53bb\u627e\u90a3\u4e9b\u6709\u4e00\u952e\u8bbe\u7f6e\u7684\u5de5\u5177\u6216\u811a\u672c\uff0c\u7ed3\u679c\u6765\u56de\u6298\u817e\u82b1\u4e86\u4e0d\u5c11\u65f6\u95f4\uff0c\u6700\u540e\u8fd8\u662f\u53c2\u8003<a href=\"https:\/\/guide.v2fly.org\/app\/tproxy.html\" rel=\"noopener\" target=\"_blank\">\u8fd9\u91cc<\/a>\u7684\u6559\u7a0b\u641e\u5b9a\u4e86\u3002<\/p>\n<h2>\u51c6\u5907\u955c\u50cf<\/h2>\n<ol>\n<li>\u4e0b\u8f7d<a href=\"https:\/\/downloads.openwrt.org\/releases\/22.03.5\/targets\/x86\/64\/openwrt-22.03.5-x86-64-generic-squashfs-combined.img.gz\" rel=\"noopener\" target=\"_blank\">\u76ee\u524d\u6700\u65b0\u7684 OpenWrt \u955c\u50cf<\/a><\/li>\n<li>\u89e3\u538b\u5f97\u5230 <code>*.img<\/code>\uff0c\u8bb0\u4e3a <code>op.img<\/code><\/li>\n<li>\uff08\u53ef\u9009\uff09\u7528\u8fd9\u4e2a\u955c\u50cf\u5b89\u88c5\u540e\u7684\u9ed8\u8ba4\u53ef\u7528\u7a7a\u95f4\u53ea\u6709 100M\uff0c\u6bd4\u8f83\u6349\u9e21\u3002\u4e3a\u4e86\u65b9\u4fbf\u540e\u7eed\u5b89\u88c5\u5404\u79cd\u8f6f\u4ef6\u5148\u505a\u4e2a\u6269\u5bb9\uff1a\u5230 Linux \u7cfb\u7edf\u4e0b\u6216\u7528 wsl\uff0c\u8fd0\u884c <code>dd if=\/dev\/zero bs=1M count=2048 >> op.img<\/code>\uff0c\u5c06\u955c\u50cf\u6269\u5bb9\u5230 2G<\/li>\n<p><!--more--><\/p>\n<li>\uff08\u53ef\u9009\uff09\u6267\u884c <code>parted op.img<\/code>\uff0c\u518d\u8f93\u5165 <code>print<\/code>\uff0c\u53ef\u4ee5\u770b\u5230\u955c\u50cf\u4e2d\u6709\u4e24\u4e2a\u5206\u533a\uff0c\u7b2c\u4e8c\u4e2a\u8303\u56f4\u662f 17.3M~126M\uff0c\u5171 109M \u5927\u5c0f\u3002<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-1.png\" \/><\/li>\n<li>\uff08\u53ef\u9009\uff09\u6267\u884c <code>resizepart 2 100%<\/code> \u8ba9\u5206\u533a 2 \u5360\u6ee1\u5269\u4f59\u7684\u5168\u90e8\u7a7a\u95f4\uff0c\u518d <code>print<\/code> \u4e00\u6b21\u53ef\u4ee5\u770b\u5230\u5206\u533a 2 \u7684\u5927\u5c0f\u5df2\u7ecf\u66f4\u65b0\uff0c\u6267\u884c <code>quit<\/code> \u9000\u51fa\u3002<\/li>\n<\/ol>\n<h2>\u8f6c\u6362\u683c\u5f0f\u4e3a vhd<\/h2>\n<p>\u4e3a\u4e86\u7ed9 hyper-v \u7528\u8fd8\u9700\u8981\u8f6c\u6362\u955c\u50cf\u683c\u5f0f\uff0c\u4e0b\u4e00\u4e2a <a href=\"https:\/\/www.starwindsoftware.com\/starwind-v2v-converter\" rel=\"noopener\" target=\"_blank\">StarWind V2V Converter<\/a> \u5c06\u6269\u5bb9\u540e\u7684\u955c\u50cf\u8f6c\u4e3a VHD \u683c\u5f0f\uff0c\u8981\u9009 <code>VHD pre-allocated image<\/code>\uff0c\u8fd9\u6837\u8f6c\u51fa\u6765\u7684 vhd \u4e5f\u662f 2.1G \u5927\u5c0f\u3002<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-2.png\" \/><\/p>\n<h2>\u521b\u5efa hyper-v \u865a\u62df\u4ea4\u6362\u673a<\/h2>\n<ol>\n<li>\u5b89\u88c5\u5b8c hyper-v \u540e\u7cfb\u7edf\u4f1a\u81ea\u52a8\u521b\u5efa <code>Default Switch<\/code>\uff0c\u8fd9\u91cc\u8981\u989d\u5916\u521b\u5efa\u4e24\u4e2a\u4ea4\u6362\u673a\uff0c\u5206\u522b\u7528\u4e8e\u5916\u7f51\u548c\u5185\u7f51\u7684\u8fde\u63a5\uff0c\u5bf9\u5e94\u7f51\u5173\u4e0a\u7684 wan \u548c lan\u3002<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-3.png\"\/><\/li>\n<li>\u5916\u7f51\u7684 External \u9009\u4e2d\u7269\u7406\u7f51\u5361\uff0c\u5e76\u53bb\u6389 <code>\u5141\u8bb8\u7ba1\u7406\u64cd\u4f5c\u7cfb\u7edf\u5171\u4eab\u6b64\u7f51\u7edc\u9002\u914d\u5668<\/code> \u52fe\u9009<\/li>\n<li>\u5185\u7f51\u7684 Internal \u76f4\u63a5\u9009 <code>\u5185\u90e8\u7f51\u7edc<\/code> \u5c31\u884c<\/li>\n<\/ol>\n<h2>\u521b\u5efa hyper-v \u865a\u62df\u673a<\/h2>\n<ol>\n<li>\u9009\u7b2c\u4e00\u4ee3<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-4.png\"\/><\/li>\n<li>1G \u5185\u5b58\uff0c\u4e0d\u7528\u52a8\u6001<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-5.png\"\/><\/li>\n<li>\u9009\u4e2d External \u4ea4\u6362\u673a<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-6.png\"\/><\/li>\n<li>\u4f7f\u7528\u521a\u624d\u521b\u5efa\u597d\u7684 vhd \u865a\u62df\u786c\u76d8\uff0c\u4e0b\u4e00\u6b65<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-7.png\"\/><\/li>\n<li>\u786e\u8ba4\u4e0b\u914d\u7f6e\uff0c\u5b8c\u6210<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-8.png\"\/><\/li>\n<li>\u521b\u5efa\u5b8c\u540e\u5148<mark>\u4e0d\u8981<\/mark>\u8fd0\u884c\uff0c\u6253\u5f00\u865a\u62df\u673a\u7684\u8bbe\u7f6e\uff0c\u6dfb\u52a0 Internal \u4ea4\u6362\u673a<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-9.png\"\/><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-10.png\"\/><\/li>\n<li>\u73b0\u5728\u53ef\u4ee5\u542f\u52a8\u865a\u62df\u673a\uff0c\u5e76\u7528 hyper-v \u8fde\u63a5\u4e86<\/li>\n<li>\u770b\u5230\u8fd9\u4e2a\u540e\u53ef\u4ee5\u6309\u56de\u8f66\u6fc0\u6d3b\u63a7\u5236\u53f0<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-11.png\"\/><\/li>\n<li>\u9996\u5148\u7528 passwd \u521b\u5efa root \u5bc6\u7801<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-12.png\"\/><\/li>\n<li>\u7136\u540e\u8f93\u5165 <code>vi \/etc\/config\/network<\/code> \u4fee\u6539\u7f51\u7edc\u63a5\u53e3\u914d\u7f6e<\/li>\n<li>\u521a\u624d\u521b\u5efa\u865a\u62df\u673a\u65f6\u5148\u9009\u62e9\u4e86 External\uff0c\u521b\u5efa\u540e\u518d\u6dfb\u52a0\u7684 Internal \u4ea4\u6362\u673a\uff0c\u6240\u4ee5\u8fd9\u91cc\u7684 eth0 \u5bf9\u5e94\u5916\u7f51 wan\uff0ceth1 \u5bf9\u5e94\u5185\u7f51 lan\uff0c\u6709\u5bf9\u5e94\u987a\u5e8f\u3002lan \u7684\u7f51\u6bb5\u4e0d\u8981\u548c\u73b0\u6709\u7f51\u6bb5\u91cd\u590d\uff0c\u9009\u4e2a\u6ca1\u7528\u8fc7\u7684<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-13.png\"\/><\/li>\n<li>\u4fdd\u5b58\u9000\u51fa\u540e\u7528 <code>reboot<\/code> \u91cd\u542f\u865a\u62df\u673a\uff0c\u4e4b\u540e\u5c31\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u91cc\u7528 <code>192.168.5.1<\/code> \u8bbf\u95ee openwrt \u540e\u53f0\u4e86\uff08\u5bf9\u5e94\u4e0a\u9762\u4fee\u6539\u7684\u7f51\u5173\u5730\u5740\uff09<\/li>\n<\/ol>\n<h2>OpenWrt LuCI<\/h2>\n<p>\u8fd9\u91cc\u7684\u64cd\u4f5c\u7528 <code>opkg update<\/code> \u548c <code>opkg install ***<\/code> \u5728 ssh \u63a7\u5236\u53f0\u64cd\u4f5c\u4e5f\u662f\u4e00\u6837\u7684\u3002<\/p>\n<ol>\n<li>\u5230 Software \u83dc\u5355\uff0c\u70b9\u7eff\u8272\u7684 Update lists\uff0c\u770b\u5230\u4e0b\u9762\u7684\u5f39\u7a97\u8bf4\u660e\u64cd\u4f5c\u6210\u529f\u4e86\u3002\u5982\u679c\u6709\u9519\u8bef\u53d1\u751f\u7a97\u53e3\u91cc\u4f1a\u6709\u4e00\u680f\u663e\u793a\u76f8\u5173\u7684\u9519\u8bef\u4fe1\u606f<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-14.png\"\/><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-15.png\"\/><\/li>\n<li>\u5206\u522b\u5728\u8f93\u5165\u6846\u8f93\u5165 <code>iptables-nft<\/code>\u3001<code>iptables-mod-tproxy<\/code> \u548c <code>iptables-mod-socket<\/code> \u5e76\u5b89\u88c5<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-16.png\"\/><\/li>\n<li>\u641c\u7d22 <code>v2ray<\/code> \u5e76\u5b89\u88c5\u524d\u4e09\u4e2a<img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2023\/06\/openwrt-tp-17.png\"\/><\/li>\n<\/ol>\n<h2>OpenWrt ssh<\/h2>\n<ol>\n<li>\u518d\u7528 ssh \u767b\u5f55 OpenWrt\uff0c\u5c06\u4ee5\u4e0b\u914d\u7f6e\u5185\u5bb9\u5199\u5165\u5230 <code>\/etc\/v2ray\/config.json<\/code> \u91cc\uff0c<code>outbounds\/proxy<\/code> \u8282\u91cc\u8981\u66ff\u6362\u4e0a\u81ea\u5df1\u7684\u670d\u52a1\u5668\u4fe1\u606f\u3002<q>\u5e7f\u544a\u62e6\u622a<\/q>\u90e8\u5206\u6709\u4e2a\u522b\u7f51\u7ad9\u4e5f\u4f1a\u88ab\u62e6\u622a\uff0c\u6240\u4ee5\u6ce8\u6389\u4e86\u3002\u8def\u7531\u89c4\u5219\u7684\u6700\u540e\u518d\u52a0\u4e0a proxy \u7684\u89c4\u5219\uff0c\u8868\u793a\u6240\u6709\u5269\u4f59\u6d41\u91cf\u90fd\u53d1\u5230\u4ee3\u7406\u4e0a\u3002\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n{\r\n  &quot;inbounds&quot;: &#x5B;\r\n    {\r\n      &quot;tag&quot;:&quot;transparent&quot;,\r\n      &quot;port&quot;: 12345,\r\n      &quot;protocol&quot;: &quot;dokodemo-door&quot;,\r\n      &quot;settings&quot;: {\r\n        &quot;network&quot;: &quot;tcp,udp&quot;,\r\n        &quot;followRedirect&quot;: true\r\n      },\r\n      &quot;sniffing&quot;: {\r\n        &quot;enabled&quot;: true,\r\n        &quot;destOverride&quot;: &#x5B;\r\n          &quot;http&quot;,\r\n          &quot;tls&quot;\r\n        ]\r\n      },\r\n      &quot;streamSettings&quot;: {\r\n        &quot;sockopt&quot;: {\r\n          &quot;tproxy&quot;: &quot;tproxy&quot;, \/\/ \u900f\u660e\u4ee3\u7406\u4f7f\u7528 TPROXY \u65b9\u5f0f\r\n          &quot;mark&quot;:255\r\n        }\r\n      }\r\n    },\r\n    {\r\n      &quot;port&quot;: 1080, \r\n      &quot;protocol&quot;: &quot;socks&quot;, \/\/ \u5165\u53e3\u534f\u8bae\u4e3a SOCKS 5\r\n      &quot;sniffing&quot;: {\r\n        &quot;enabled&quot;: true,\r\n        &quot;destOverride&quot;: &#x5B;&quot;http&quot;, &quot;tls&quot;]\r\n      },\r\n      &quot;settings&quot;: {\r\n        &quot;auth&quot;: &quot;noauth&quot;\r\n      }\r\n    }\r\n  ],\r\n  &quot;outbounds&quot;: &#x5B;\r\n    {\r\n      &quot;tag&quot;: &quot;proxy&quot;,\r\n      &quot;protocol&quot;: &quot;vmess&quot;,\r\n      &quot;settings&quot;: {\r\n        &quot;vnext&quot;: &#x5B;\r\n          \/\/ \u628a\u4f60\u7684\u670d\u52a1\u5668\u4fe1\u606f\u8d34\u5230\u8fd9\u91cc\r\n        ]\r\n      },\r\n      &quot;streamSettings&quot;: {\r\n\r\n        \/\/ \u5982\u679c\u6709 http \u4f2a\u88c5\u4e4b\u7c7b\u7684\u4e5f\u6284\u8fc7\u6765\r\n\r\n        &quot;sockopt&quot;: {\r\n          &quot;mark&quot;: 255  \/\/ \u8fd9\u4e9b\u8981\u4fdd\u7559\r\n        }\r\n      },\r\n      &quot;mux&quot;: {\r\n        &quot;enabled&quot;: true\r\n      }\r\n    },\r\n    {\r\n      &quot;tag&quot;: &quot;direct&quot;,\r\n      &quot;protocol&quot;: &quot;freedom&quot;,\r\n      &quot;settings&quot;: {\r\n        &quot;domainStrategy&quot;: &quot;UseIP&quot;\r\n      },\r\n      &quot;streamSettings&quot;: {\r\n        &quot;sockopt&quot;: {\r\n          &quot;mark&quot;: 255\r\n        }\r\n      }      \r\n    },\r\n    {\r\n      &quot;tag&quot;: &quot;block&quot;,\r\n      &quot;protocol&quot;: &quot;blackhole&quot;,\r\n      &quot;settings&quot;: {\r\n        &quot;response&quot;: {\r\n          &quot;type&quot;: &quot;http&quot;\r\n        }\r\n      }\r\n    },\r\n    {\r\n      &quot;tag&quot;: &quot;dns-out&quot;,\r\n      &quot;protocol&quot;: &quot;dns&quot;,\r\n      &quot;streamSettings&quot;: {\r\n        &quot;sockopt&quot;: {\r\n          &quot;mark&quot;: 255\r\n        }\r\n      }  \r\n    }\r\n  ],\r\n  &quot;dns&quot;: {\r\n    &quot;servers&quot;: &#x5B;\r\n      {\r\n        &quot;address&quot;: &quot;223.5.5.5&quot;, \/\/\u4e2d\u56fd\u5927\u9646\u57df\u540d\u4f7f\u7528\u963f\u91cc\u7684 DNS\r\n        &quot;port&quot;: 53,\r\n        &quot;domains&quot;: &#x5B;\r\n          &quot;geosite:cn&quot;,\r\n          &quot;ntp.org&quot;,   \/\/ NTP \u670d\u52a1\u5668\r\n          &quot;$myserver.address&quot; \/\/ \u6b64\u5904\u6539\u4e3a\u4f60 VPS \u7684\u57df\u540d\r\n        ]\r\n      },\r\n      {\r\n        &quot;address&quot;: &quot;114.114.114.114&quot;, \/\/\u4e2d\u56fd\u5927\u9646\u57df\u540d\u4f7f\u7528 114 \u7684 DNS (\u5907\u7528)\r\n        &quot;port&quot;: 53,\r\n        &quot;domains&quot;: &#x5B;\r\n          &quot;geosite:cn&quot;,\r\n          &quot;ntp.org&quot;,   \/\/ NTP \u670d\u52a1\u5668\r\n          &quot;$myserver.address&quot; \/\/ \u6b64\u5904\u6539\u4e3a\u4f60 VPS \u7684\u57df\u540d\r\n        ]\r\n      },\r\n      {\r\n        &quot;address&quot;: &quot;8.8.8.8&quot;, \/\/\u975e\u4e2d\u56fd\u5927\u9646\u57df\u540d\u4f7f\u7528 Google \u7684 DNS\r\n        &quot;port&quot;: 53,\r\n        &quot;domains&quot;: &#x5B;\r\n          &quot;geosite:geolocation-!cn&quot;\r\n        ]\r\n      },\r\n      {\r\n        &quot;address&quot;: &quot;1.1.1.1&quot;, \/\/\u975e\u4e2d\u56fd\u5927\u9646\u57df\u540d\u4f7f\u7528 Cloudflare \u7684 DNS\r\n        &quot;port&quot;: 53,\r\n        &quot;domains&quot;: &#x5B;\r\n          &quot;geosite:geolocation-!cn&quot;\r\n        ]\r\n      }\r\n    ]\r\n  },\r\n  &quot;routing&quot;: {\r\n    &quot;domainStrategy&quot;: &quot;IPOnDemand&quot;,\r\n    &quot;rules&quot;: &#x5B;\r\n      { \/\/ \u52ab\u6301 53 \u7aef\u53e3 UDP \u6d41\u91cf\uff0c\u4f7f\u7528 V2Ray \u7684 DNS\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;inboundTag&quot;: &#x5B;\r\n          &quot;transparent&quot;\r\n        ],\r\n        &quot;port&quot;: 53,\r\n        &quot;network&quot;: &quot;udp&quot;,\r\n        &quot;outboundTag&quot;: &quot;dns-out&quot;\r\n      },\r\n      { \/\/ \u76f4\u8fde 123 \u7aef\u53e3 UDP \u6d41\u91cf\uff08NTP \u534f\u8bae\uff09\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;inboundTag&quot;: &#x5B;\r\n          &quot;transparent&quot;\r\n        ],\r\n        &quot;port&quot;: 123,\r\n        &quot;network&quot;: &quot;udp&quot;,\r\n        &quot;outboundTag&quot;: &quot;direct&quot;\r\n      },\r\n      { \/\/ \u76f4\u8fde\u4e2d\u56fd\u5927\u9646\u4e3b\u6d41\u7f51\u7ad9 ip \u548c \u4fdd\u7559 ip\r\n        &quot;type&quot;: &quot;field&quot;, \r\n        &quot;ip&quot;: &#x5B;\r\n          &quot;geoip:private&quot;,\r\n          &quot;geoip:cn&quot;\r\n        ],\r\n        &quot;outboundTag&quot;: &quot;direct&quot;\r\n      },\r\n      { \/\/ \u76f4\u8fde\u4e2d\u56fd\u5927\u9646\u4e3b\u6d41\u7f51\u7ad9\u57df\u540d\r\n        &quot;type&quot;: &quot;field&quot;, \r\n        &quot;domain&quot;: &#x5B;\r\n          &quot;geosite:cn&quot;\r\n        ],\r\n        &quot;outboundTag&quot;: &quot;direct&quot;\r\n      },\r\n      {\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;ip&quot;: &#x5B;\r\n          \/\/ \u8bbe\u7f6e DNS \u914d\u7f6e\u4e2d\u7684\u56fd\u5185 DNS \u670d\u52a1\u5668\u5730\u5740\u76f4\u8fde\uff0c\u4ee5\u8fbe\u5230 DNS \u5206\u6d41\u76ee\u7684\r\n          &quot;223.5.5.5&quot;,\r\n          &quot;114.114.114.114&quot;\r\n        ],\r\n        &quot;outboundTag&quot;: &quot;direct&quot;\r\n      },\r\n      {\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;ip&quot;: &#x5B;\r\n          \/\/ \u8bbe\u7f6e DNS \u914d\u7f6e\u4e2d\u7684\u56fd\u5916 DNS \u670d\u52a1\u5668\u5730\u5740\u8d70\u4ee3\u7406\uff0c\u4ee5\u8fbe\u5230 DNS \u5206\u6d41\u76ee\u7684\r\n          &quot;8.8.8.8&quot;,\r\n          &quot;1.1.1.1&quot;\r\n        ],\r\n        &quot;outboundTag&quot;: &quot;proxy&quot; \/\/ \u6539\u4e3a\u4f60\u81ea\u5df1\u4ee3\u7406\u7684\u51fa\u7ad9 tag\r\n      },\r\n      \/\/{ \/\/ \u5e7f\u544a\u62e6\u622a\r\n      \/\/  &quot;type&quot;: &quot;field&quot;,\r\n      \/\/  &quot;domain&quot;: &#x5B;\r\n      \/\/   &quot;geosite:category-ads-all&quot;\r\n      \/\/  ],\r\n      \/\/  &quot;outboundTag&quot;: &quot;block&quot;\r\n      \/\/},\r\n      { \/\/ BT \u6d41\u91cf\u76f4\u8fde\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;protocol&quot;:&#x5B;&quot;bittorrent&quot;],\r\n        &quot;outboundTag&quot;: &quot;direct&quot;\r\n      },\r\n      {\r\n        &quot;type&quot;: &quot;field&quot;,\r\n        &quot;outboundTag&quot;: &quot;proxy&quot;,\r\n        &quot;network&quot;: &quot;udp,tcp&quot;\r\n      }\r\n    ]\r\n  }\r\n}<\/pre>\n<\/li>\n<li>geoip.dat \u548c geosite.dat \u53ef\u4ee5\u5230<a href=\"https:\/\/github.com\/Loyalsoldier\/v2ray-rules-dat\" rel=\"noopener\" target=\"_blank\">\u8fd9\u91cc<\/a>\u548c<a href=\"https:\/\/github.com\/v2fly\/domain-list-community\" rel=\"noopener\" target=\"_blank\">\u8fd9\u91cc<\/a>\u4e0b\u8f7d\uff0c\u4e0b\u8f7d\u540e\u53ef\u4ee5\u653e <code>\/usr\/bin<\/code> \u76ee\u5f55\uff0c\u81ea\u52a8\u66f4\u65b0\u53ef\u4ee5\u81ea\u884c\u5904\u7406\u4e0b<\/li>\n<li>\u6267\u884c <code>v2ray test -c \/etc\/v2ray\/config.json<\/code> \u786e\u4fdd\u914d\u7f6e\u6587\u4ef6\u6b63\u786e<\/li>\n<li>\u6267\u884c <code>v2ray run -c \/etc\/v2ray\/config.json<\/code> \u542f\u52a8 v2ray<\/li>\n<li>\u53e6\u8d77\u4e00\u4e2a ssh \u6267\u884c <code>curl -so \/dev\/null -w \"%{http_code}\" google.com -x socks5:\/\/127.0.0.1:1080<\/code> \uff08\u6309\u4e0a\u9762\u7684\u914d\u7f6e\u5c31\u662f\u7528 1080 \u7aef\u53e3\uff09\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u8f93\u51fa <q>301<\/q>\uff1b\u6216\u8005\u628a\u6d4f\u89c8\u5668\u7684\u4ee3\u7406\u5730\u5740\u6539\u6210 <code>192.168.5.1:1080<\/code> \u5c31\u53ef\u4ee5\u79d1\u5b66\u4e0a\u7f51\uff08\u7f51\u5173\u5730\u5740\u6539\u6210\u81ea\u5df1\u8bbe\u7f6e\u7684\uff09<\/li>\n<\/ol>\n<h2>\u900f\u660e\u4ee3\u7406<\/h2>\n<ol>\n<li>\u63a5\u4e0b\u6700\u540e\u4e00\u6b65\u8bbe\u7f6e\u6210\u900f\u660e\u4ee3\u7406\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# \u8bbe\u7f6e\u7b56\u7565\u8def\u7531\r\nip rule add fwmark 1 table 100 \r\nip route add local 0.0.0.0\/0 dev lo table 100\r\n\r\n# \u4ee3\u7406\u5c40\u57df\u7f51\u8bbe\u5907\r\niptables -t mangle -N V2RAY\r\niptables -t mangle -A V2RAY -d 127.0.0.1\/32 -j RETURN\r\niptables -t mangle -A V2RAY -d 224.0.0.0\/4 -j RETURN \r\niptables -t mangle -A V2RAY -d 255.255.255.255\/32 -j RETURN \r\niptables -t mangle -A V2RAY -d 192.168.0.0\/16 -p tcp -j RETURN # \u76f4\u8fde\u5c40\u57df\u7f51\uff0c\u907f\u514d V2Ray \u65e0\u6cd5\u542f\u52a8\u65f6\u65e0\u6cd5\u8fde\u7f51\u5173\u7684 SSH\uff0c\u5982\u679c\u4f60\u914d\u7f6e\u7684\u662f\u5176\u4ed6\u7f51\u6bb5\uff08\u5982 10.x.x.x \u7b49\uff09\uff0c\u5219\u4fee\u6539\u6210\u81ea\u5df1\u7684\r\niptables -t mangle -A V2RAY -d 192.168.0.0\/16 -p udp ! --dport 53 -j RETURN # \u76f4\u8fde\u5c40\u57df\u7f51\uff0c53 \u7aef\u53e3\u9664\u5916\uff08\u56e0\u4e3a\u8981\u4f7f\u7528 V2Ray \u7684 DNS)\r\niptables -t mangle -A V2RAY -j RETURN -m mark --mark 0xff    # \u76f4\u8fde SO_MARK \u4e3a 0xff \u7684\u6d41\u91cf(0xff \u662f 16 \u8fdb\u5236\u6570\uff0c\u6570\u503c\u4e0a\u7b49\u540c\u4e0e\u4e0a\u9762V2Ray \u914d\u7f6e\u7684 255)\uff0c\u6b64\u89c4\u5219\u76ee\u7684\u662f\u89e3\u51b3v2ray\u5360\u7528\u5927\u91cfCPU\uff08https:\/\/github.com\/v2ray\/v2ray-core\/issues\/2621\uff09\r\niptables -t mangle -A V2RAY -p udp -j TPROXY --on-ip 127.0.0.1 --on-port 12345 --tproxy-mark 1 # \u7ed9 UDP \u6253\u6807\u8bb0 1\uff0c\u8f6c\u53d1\u81f3 12345 \u7aef\u53e3\r\niptables -t mangle -A V2RAY -p tcp -j TPROXY --on-ip 127.0.0.1 --on-port 12345 --tproxy-mark 1 # \u7ed9 TCP \u6253\u6807\u8bb0 1\uff0c\u8f6c\u53d1\u81f3 12345 \u7aef\u53e3\r\niptables -t mangle -A PREROUTING -j V2RAY # \u5e94\u7528\u89c4\u5219\r\n\r\n# \u4ee3\u7406\u7f51\u5173\u672c\u673a\r\niptables -t mangle -N V2RAY_MASK \r\niptables -t mangle -A V2RAY_MASK -d 224.0.0.0\/4 -j RETURN \r\niptables -t mangle -A V2RAY_MASK -d 255.255.255.255\/32 -j RETURN \r\niptables -t mangle -A V2RAY_MASK -d 192.168.0.0\/16 -p tcp -j RETURN # \u76f4\u8fde\u5c40\u57df\u7f51\r\niptables -t mangle -A V2RAY_MASK -d 192.168.0.0\/16 -p udp ! --dport 53 -j RETURN # \u76f4\u8fde\u5c40\u57df\u7f51\uff0c53 \u7aef\u53e3\u9664\u5916\uff08\u56e0\u4e3a\u8981\u4f7f\u7528 V2Ray \u7684 DNS\uff09\r\niptables -t mangle -A V2RAY_MASK -j RETURN -m mark --mark 0xff    # \u76f4\u8fde SO_MARK \u4e3a 0xff \u7684\u6d41\u91cf(0xff \u662f 16 \u8fdb\u5236\u6570\uff0c\u6570\u503c\u4e0a\u7b49\u540c\u4e0e\u4e0a\u9762V2Ray \u914d\u7f6e\u7684 255)\uff0c\u6b64\u89c4\u5219\u76ee\u7684\u662f\u907f\u514d\u4ee3\u7406\u672c\u673a(\u7f51\u5173)\u6d41\u91cf\u51fa\u73b0\u56de\u73af\u95ee\u9898\r\niptables -t mangle -A V2RAY_MASK -p udp -j MARK --set-mark 1   # \u7ed9 UDP \u6253\u6807\u8bb0\uff0c\u91cd\u8def\u7531\r\niptables -t mangle -A V2RAY_MASK -p tcp -j MARK --set-mark 1   # \u7ed9 TCP \u6253\u6807\u8bb0\uff0c\u91cd\u8def\u7531\r\niptables -t mangle -A OUTPUT -j V2RAY_MASK # \u5e94\u7528\u89c4\u5219\r\n\r\n# \u65b0\u5efa DIVERT \u89c4\u5219\uff0c\u907f\u514d\u5df2\u6709\u8fde\u63a5\u7684\u5305\u4e8c\u6b21\u901a\u8fc7 TPROXY\uff0c\u7406\u8bba\u4e0a\u6709\u4e00\u5b9a\u7684\u6027\u80fd\u63d0\u5347\r\niptables -t mangle -N DIVERT\r\niptables -t mangle -A DIVERT -j MARK --set-mark 1\r\niptables -t mangle -A DIVERT -j ACCEPT\r\niptables -t mangle -I PREROUTING -p tcp -m socket -j DIVERT\r\n<\/pre>\n<\/li>\n<li>\u9010\u4e2a\u6267\u884c\u5b8c\u4e0a\u9762\u7684\u8fd9\u4e9b\u547d\u4ee4\u540e\u900f\u660e\u4ee3\u7406\u5e94\u8be5\u5df2\u7ecf\u751f\u6548\uff0c\u5173\u6389\u5176\u4ed6\u4ee3\u7406\u8f6f\u4ef6\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4e0a\u7f51\u4e86<\/li>\n<\/ol>\n<h2>\u5f00\u673a\u81ea\u52a8\u8fd0\u884c\u900f\u660e\u4ee3\u7406<\/h2>\n<ol>\n<li>\u9996\u5148\u4fdd\u5b58\u73b0\u6709\u7684 iptables \u89c4\u5219\u5230\u6587\u4ef6<code><br \/>\nmkdir -p \/etc\/iptables && iptables-save > \/etc\/iptables\/rules.v4<\/code><\/li>\n<li>\u7528 <code>vi \/root\/run-proxy<\/code> \u65b0\u5efa\u4e00\u4e2a\u811a\u672c\uff08\u524d\u4e09\u6761\u662f\u6e05\u9664\u900f\u660e\u4ee3\u7406\u89c4\u5219\uff0c\u540e\u4e09\u6761\u662f\u91cd\u5efa\uff09\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/sbin\/ip rule del fwmark 1 table 100\r\n\/sbin\/ip route del local 0.0.0.0\/0 dev lo table 100\r\n\/usr\/sbin\/iptables -t mangle -F\r\n\/sbin\/ip rule add fwmark 1 table 100\r\n\/sbin\/ip route add local 0.0.0.0\/0 dev lo table 100\r\n\/usr\/sbin\/iptables-restore \/etc\/iptables\/rules.v4\r\n<\/pre>\n<\/li>\n<li>\u5230 LuCI \u7684 <code>System - Startup - Local Startup<\/code> \u9875\u9762\uff0c\u5728 <code>exit 0<\/code> \u4e4b\u524d\u63d2\u5165\u4e00\u884c <code>\/bin\/sh \/root\/run-proxy<\/code>\uff0c\u8fd9\u6837\u5f00\u673a\u540e\u5c31\u4f1a\u81ea\u52a8\u914d\u7f6e\u4ee3\u7406\u89c4\u5219<\/li>\n<li>\u6253\u5f00 <code>\/etc\/config\/v2ray<\/code>\uff0c\u628a <code>option enabled '0'<\/code> \u7684 0 \u6539\u6210 1\uff0c\u4f7f v2ray \u5f00\u673a\u81ea\u542f\uff0c\u914d\u5408\u4e0a\u4e00\u6761\u5c31\u5b8c\u6210\u542f\u52a8\u914d\u7f6e\u4e86\uff08\u4e0d\u8fc7\u8fd9\u51e0\u5929\u8bd5\u7528\u4e0b\u6765\u5728 PC \u7761\u7720\u6062\u590d\u540e\u5e38\u6709\u90e8\u5206\u7f51\u7ad9\u4ee3\u7406\u4e0d\u4e86\u7684\u60c5\u51b5\u51fa\u73b0\uff0c\u6bd4\u5982 google \u6253\u4e0d\u5f00\u4f46 youtube \u80fd\u6253\u5f00\uff0c\u6216\u8005\u53cd\u8fc7\u6765\uff0c\u518d\u7ee7\u7eed\u627e\u627e\u539f\u56e0\u770b\uff09<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u6709\u4e9b\u8f6f\u4ef6\u4e0d\u652f\u6301\u4e3b\u52a8\u8bbe\u7f6e\u4ee3\u7406\uff0c\u6240\u4ee5\u6709\u65f6\u5019\u8fd8\u5f97\u5f00\u4e2a\u900f\u660e\u4ee3\u7406\uff0c\u5728\u5b9e\u9645\u4e70\u8bbe\u5907\u524d\u5148\u7528\u865a\u62df\u673a\u5b89\u88c5 OpenWrt \u5b9e\u9a8c&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/flandre-scarlet.moe\/blog\/2016\/\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[218,219,220,221,223,222],"class_list":["post-2016","post","type-post","status-publish","format-standard","hentry","category-programs","tag-hyper-v","tag-openwrt","tag-tproxy","tag-transparent-proxy","tag-223","tag-222"],"_links":{"self":[{"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/posts\/2016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/comments?post=2016"}],"version-history":[{"count":19,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/posts\/2016\/revisions"}],"predecessor-version":[{"id":2055,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/posts\/2016\/revisions\/2055"}],"wp:attachment":[{"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/media?parent=2016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/categories?post=2016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flandre-scarlet.moe\/blog\/wp-json\/wp\/v2\/tags?post=2016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}