本文最后更新于17 天前,其中的信息可能已经过时,如有错误请发送邮件到Hasususu@163.com
插件设置→开发者选项的底部添加如下命令
ipset -! flush china_ip_route
ipset -! restore </etc/openclash/china_ip_route.ipset 2>/dev/null
# 避免来自中国的流量经过代理,需要走代理的都保留了 Fake IP
iptables -t nat -D openclash -p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 -j REDIRECT --to-ports 7892
# 避免宿主机自身的出口流量全部走代理
iptables -t nat -D openclash_output -p tcp -m owner ! --uid-owner 65534 -j REDIRECT --to-ports 7892
# 避免来自中国的 UDP 流量经过代理
iptables -t mangle -D openclash -p udp -j TPROXY --tproxy-mark 0x162/0xffffffff --on-port 7895
# 除 Fake IP 外,非中国 IP 的流量也重定向到代理
iptables -t nat -A openclash -p tcp -m set ! --match-set china_ip_route dst -j REDIRECT --to-ports 7892
# 重定向非中国的 UDP 流量到代理
iptables -t mangle -A openclash -p udp -m set ! --match-set china_ip_route dst -j TPROXY --tproxy-mark 0x162/0xffffffff --on-port 7895
# 对于宿主机自身的 TCP 流量除了 Fake IP 外,对于非中国 IP 的流量且非 OpenClash 的出口流量也重定向到代理
iptables -t nat -A openclash_output -p tcp -m set ! --match-set china_ip_route dst -m owner ! --uid-owner 65534 -j REDIRECT --to-ports 7892
exit 0