优化DNS实现逻辑

This commit is contained in:
juewuy
2020-07-23 12:34:58 +08:00
committed by GitHub
parent 4ee3be65a6
commit 6138d05539

View File

@@ -11,7 +11,7 @@ PS
使用依赖:
--
•请确认路由器或设备已经开启ssh并获取root权限小米AX系列可参考https://www.right.com.cn/forum/thread-4032490-1-1.html<br>
•请确认路由器或设备已经开启SSH并获取root权限小米AX系列可参考https://www.right.com.cn/forum/thread-4032490-1-1.html 开启<br>
•SSH连接工具例如puttybitvise等请自行安装使用<br>
•SCP连接工具如winscp内置了putty只安装这一个其实就可以<br>
@@ -23,65 +23,54 @@ PS
*·如有必要也可以自行前往下载更新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>
**首次安装clash**
```Shell
#首次启用clash
mv /etc/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
chmod 777 /etc/clash/clash #授予权限
chmod 777 /etc/init.d/clash #授予权限
sed -i "8iport=5335" /etc/dnsmasq.conf #修改dnsmasq监听端口为5335
service dnsmasq restart #重启dnsmasq服务报错“cp: can't stat '/etc/dnsmasq.d/*'……”可无视)
service clash enable #启用clash开机启动
service clash start #启动clash服务
```
**停止clash**
```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开机启动
sed -i '/port=5335/d' /etc/dnsmasq.conf #重置dnsmasq监听端口为默认值port:53)
reboot #重启设备
```
**启用clash**
```Shell
#停止后再次启用clash透明网关
sed -i "8iport=5335" /etc/dnsmasq.conf #修改dnsmasq监听端口为5335
service dnsmasq restart #重启dnsmasq服务报错“cp: can't stat '/etc/dnsmasq.d/*'……”可无视)
service clash enable #启用clash开机启动
service clash start #启动clash服务
```
```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/*'……”可无视,不放心可重启系统)
**设置clash开机启动**
```Shell
service clash enable #启用clash开机启动
```
**禁止clash开机启动**
```Shell
service clash disable #禁止clash开机启动
```
**卸载clash相关文件**
```Shell
rm -rf /etc/clash #删除clash文件夹及文件
rm /etc/init.d/clash #删除clash开机启动文件
```
•启用后可以通过 http://clash.razord.top IP为网关IP端口为9999管理clash内置规则,通常无需额外设置即可正常使用,且设备重启后会保持自动运行<br>
•启用后可以通过 http://clash.razord.top IP为网关IP端口为9999管理clash内置规则<br>
故障解决:
--
•在浏览器或设备WiFi管理的高级选项中配置http代理IP为路由器IP端口7890如果能连通外网则说明clash服务运行正常不能连通则说明clash运行失败或者配置错误<br>
•如果能正常连接国内网站而无法访问屏蔽网站,请在浏览器中打开 http://clash.razord.top 并使用测速功能,之后手动指定服务器即可;如果所有服务器都不可用即代表配置文件有问题<br>
•如果能连通http代理但是无法使用透明代理可能是tun网卡启用失败或者dnsmasq启动失败重启设备通常可以解决,或重新执行安装命令<br>
•如果能连通http代理可在浏览器中设置http代理端口为7890但是无法使用透明代理可能是tun网卡启用失败或者dnsmasq启动失败重启设备通常可以解决<br>
已知问题:
--
•部分软件不会经过clash例如telegram可以通过设置软件内置sock5或http代理解决<br>
•部分系统版本较低安卓6.0以下的安卓设备可能无法正确通过dhcp服务获取dns地址需要手动在WIFI中设置dns为路由器网关地址<br>
•由于使用了clash的fake-ip模式暂不支持ipv6<br>
tun模式下clash服务可能会和小米路由器内置的tx网游加速器冲突请谨慎同时使用<br>
Tun模式下clash服务可能会和小米路由器内置的tx网游加速器冲突请谨慎同时使用<br>
•Tun模式下部分软件不会经过clash例如telegram可以通过设置软件内置sock5或http代理解决<br>
•Redir模式无法转发udp流量外服游戏可能会受影响此功能是由于官方系统阉割了Tproxy导致故无法修复<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>
•https://h-cheung.gitlab.io/post/使用_clash_和路由表实现透明代理<br>
•https://www.right.com.cn/forum/thread-4042741-1-1.html<br>