Files
ShellCrash/README.md
2020-07-08 19:41:38 +08:00

57 lines
3.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# clash_tun-for-Miwifi
在小米AX3600/AX1800/AX5等路由器上使用clash_tun模式做透明代理
PS
小米路由内置的openwrt默认阉割了对tproxy的支持所以使用redir模式做透明代理时无法转发udp流量只能采用tun模式转发udp流量
tun模式对udp的转发支持非常好而且延迟非常低小米官方内置的tx网游加速器其实就是使用的tun模式
支持ss,v2ray,trojan但不支持ssr也不支持订阅
clash对tun模式的官方文档内容不是很完善折腾了好几天也没搞懂怎么使用真实ip模式进行透明代理故只能采用较为简单但速度更快的fake-ip模式
fake-ip模式在数据向dns查询时默认会返回例如198.18.0.x这样的虚拟ip地址故部分必须验证真实ip地址的网站或app可能会受影响
系统默认的dnsmasq非常霸道会强行劫持所有53端口流量所以必须修改dnsmasq的默认端口以让流量经过clash内置dns服务
fake-ip+tun模式的透明代理方式可能适用于大部分采用openwrt内核的路由器或者软路由有需求的可以自行斟酌使用
下载clash.zip并解压
根据自己需求参考备注修改config.yaml配置文件重要
也可以自行下载或更新clash-tun模式核心文件并重命名 https://github.com/Dreamacro/clash/releases/tag/premium 小米AX系列都是armv7架构其他路由器请自查
将clash文件夹以及内部4个文件通过winSCP上传到路由器/etc文件夹下
在ssh中用root用户执行下列相应命令即可
启用后可以通过 http://clash.razord.top 管理clash内置规则
默认http代理接口7890sock5接口7891
启动后无需其他设置即可连接代理服务器
#首次启用clash
mv /etc/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
chmod 777 /etc/clash/clash #授予权限
chmod 777 /etc/init.d/clash #授予权限
service clash enable #启用clash开机启动
service clash start #启动clash服务
sed -i "8iport=5335" /etc/dnsmasq.conf #修改dnsmasq监听端口为5335
service dnsmasq restart #重启dnsmasq服务报错“cp: can't stat '/etc/dnsmasq.d/*'……”可无视)
#启用clash透明网关
service clash enable #启用clash开机启动
service clash start #启动clash服务
sed -i 's|port=53|port=5335|' /etc/dnsmasq.conf #修改dnsmasq监听端口
service dnsmasq restart #重启dnsmasq服务报错“cp: can't stat '/etc/dnsmasq.d/*'……”可无视)
#停止clash透明网关
service clash disable #禁用clash开机启动
service clash stop #停止clash服务
sed -i '/port=5335/d' /etc/dnsmasq.conf #重置dnsmasq监听端口为默认值port:53)
service dnsmasq restart #重启dnsmasq服务报错“cp: can't stat '/etc/dnsmasq.d/*'……”可无视,不放心可重启系统)
#卸载clash相关文件卸载前请先配合“停止clash透明网关”使用
rm -rf /etc/clash #删除clash文件夹及文件
rm /etc/init.d/clash #删除clash开机启动文件
已知问题:
a部分软件不会经过clash例如telegram可以通过设置软件内置sock5或http代理解决
btun模式的CPU耗用较高速度不是很理想而且会影响全局流量所有tcp和udp流量都会经过tun虚拟网卡和clashax1800实测带宽在60M左右不过p2p流量通常不会进入tun故速度不受影响
c使用了clash的fake-ip模式部分网站可能会出现验证错误待确认
d由于变相禁用的dnsmasq的dns解析服务miwifi.com或www.miwifi.com 无法打开路由器管理界面只能使用192.168.31.1进入app不受影响
e可能会和小米路由器内置的网游加速器冲突请谨慎同时使用
f不支持订阅由于clash本身不支持对v2raysstrojan等协议的订阅所以订阅只能通过更新config.yaml来进行有条件的可以自行写脚本
g不支持ssrclash官方不支持ssr而支持ssr的clashr又不支持tunso……