Files
ShellCrash/README.md
2020-07-22 19:45:33 +08:00

90 lines
5.8 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-for-Miwifi
在小米AX3600/AX1800/AX5等路由器上使用clash做透明代理
=====
PS
--
•新增了redir模式redir模式速度更快但是不支持UDP转发tun模式支持UDP转发但CPU和内存占用相对更高请根据需求选择<br>
•支持ss,v2ray,trojan但不支持ssr也不支持订阅<br>
•需要自行编辑config.yaml以配置服务器<br>
•本内容中的透明代理方式可能适用于大部分同样采用openwrt内核的路由器或者软路由有需求的可以自行斟酌使用<br>
•clash支持通过内置规则去广告有需求的可以参考https://github.com/ACL4SSR/ACL4SSR 使用
使用依赖:
--
•请确认路由器或设备已经开启ssh并获取root权限小米AX系列可参考https://www.right.com.cn/forum/thread-4032490-1-1.html<br>
•SSH连接工具例如puttybitvise等请自行安装使用<br>
•SCP连接工具如winscp内置了putty只安装这一个其实就可以<br>
使用方式:
--
•根据**个人需求**下载 [Tun模式](https://github.com/juewuy/clash_tun-for-Miwifi/tree/master/clash_tun_config)**或者** [Redir模式](https://github.com/juewuy/clash_tun-for-Miwifi/tree/master/clash_redir_config)中的全部4个文件到本地电脑 <br>
•**根据自己需求参考文件内的注释修改config.yaml配置文件并保存`重要!!!`**<br>
•推荐使用notepad++打开yaml文件如果只添加单个服务器可以直接在原示例上修改即可多余的示例服务器不用删除<br>
*·如有必要也可以自行前往下载更新clash核心文件并自行改名 https://github.com/Dreamacro/clash/releases/tag/premium 小米AX3600是armv8ax1800/ax5是armv7其他路由器请自查<br>*
•将下载并修改后的4个文件通过winSCP上传到路由器/etc/clash文件夹clash文件夹请自行创建最终应该是/etc/clash/"4个文件"<br>
•登陆SSH并在SSH中用root用户执行下方的**对应命令**即可使用!<br>
```Shell
#首次启用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/*'……”可无视)
```
```Shell
#停止clash透明网关-Tun模式
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/*'……”可无视,不放心可重启系统)
```
```Shell
#停止clash透明网关-Redir模式
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/*'……”可无视,不放心可重启系统)
service firewall restart #重启防火墙以重置iptables规则
```
```Shell
#停止后再次启用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/*'……”可无视)
```
```Shell
#完全卸载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/*'……”可无视,不放心可重启系统)
rm -rf /etc/clash #删除clash文件夹及文件
rm /etc/init.d/clash #删除clash开机启动文件
```
•启用后可以通过 http://clash.razord.top IP为网关IP端口为9999管理clash内置规则通常无需额外设置即可正常使用且设备重启后会保持自动运行<br>
故障解决:
--
•在浏览器或设备WiFi管理的高级选项中配置http代理IP为路由器IP端口7890如果能连通外网则说明clash服务运行正常不能连通则说明clash运行失败或者配置错误<br>
•如果能正常连接国内网站而无法访问屏蔽网站,请在浏览器中打开 http://clash.razord.top 查看日志大概率是config.yaml文件配置问题<br>
•如果能连通http代理但是无法使用透明代理可能是tun网卡启用失败或者dnsmasq启动失败重启设备通常可以解决或重新执行安装命令<br>
已知问题:
--
•部分软件不会经过clash例如telegram可以通过设置软件内置sock5或http代理解决<br>
•部分系统版本较低安卓6.0以下的安卓设备可能无法正确通过dhcp服务获取dns地址需要手动在WIFI中设置dns为路由器网关地址<br>
•由于使用了clash的fake-ip模式暂不支持ipv6<br>
•tun模式下clash服务可能会和小米路由器内置的tx网游加速器冲突请谨慎同时使用<br>
•全局模式代理无效原因不明同样的配置文件在pc端或者安卓上都可以使用全局模式怀疑是clash核心的bug<br>
•小米路由内置的openwrt默认阉割了对tproxy的支持所以使用redir模式做透明代理时无法转发udp流量<br>
感谢:
--
•https://lancellc.gitbook.io/clash/start-clash/clash-tun-mode<br>
•https://comzyh.gitbook.io/clash/<br>
•https://h-cheung.gitlab.io/post/使用_clash_和路由表实现透明代理/<br>