修改dns实现方式,大幅度优化使用流程
This commit is contained in:
55
README.md
55
README.md
@@ -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连接工具,例如putty,bitvise等,请自行安装使用<br>
|
||||
•SCP连接工具,如winscp(内置了putty,只安装这一个其实就可以)<br>
|
||||
|
||||
@@ -23,67 +23,54 @@ PS:
|
||||
*·如有必要,也可以自行前往下载更新clash核心文件并自行改名 https://github.com/Dreamacro/clash/releases/tag/premium (小米AX3600是armv8,ax1800/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开机启动
|
||||
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规则
|
||||
```
|
||||
**启用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>
|
||||
|
||||
|
||||
@@ -14,7 +14,15 @@ start_service() {
|
||||
procd_set_param command /etc/clash/clash -d /etc/clash
|
||||
procd_close_instance
|
||||
#修改iptables规则使流量进入clash
|
||||
iptables -t nat -N clash
|
||||
iptables -t nat -N clash
|
||||
iptables -t nat -A clash -p tcp -j REDIRECT --to-ports 7892
|
||||
iptables -t nat -A PREROUTING -p tcp -j clash
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
stop_service() {
|
||||
#重置iptables规则
|
||||
iptables -t nat -D PREROUTING -p tcp -j clash
|
||||
iptables -t nat -F clash
|
||||
iptables -t nat -X clash
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
@@ -18,13 +18,13 @@ external-controller: 0.0.0.0:9999
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
listen: 0.0.0.0:53 #监听端口,0.0.0.0则拦截所有
|
||||
listen: 0.0.0.0:1053 #监听端口,0.0.0.0则拦截所有
|
||||
fake-ip-range: 198.18.0.1/16 #fake-ip模式下子网段,尽量不要改动
|
||||
enhanced-mode: fake-ip #或者redir-host(可能有bug),尽量不要改动
|
||||
nameserver: #国内DNS,可配置多条
|
||||
- tls://dns.rubyfish.cn:853
|
||||
#- 114.114.114.114
|
||||
- 127.0.0.1:5335 #内置的dnsmasq
|
||||
- 127.0.0.1:53 #内置的dnsmasq
|
||||
fallback: #国外DNS,可配置多条
|
||||
- tcp://1.1.1.1
|
||||
- tls://dns.google:853
|
||||
@@ -87,7 +87,7 @@ proxy-groups:
|
||||
- "v2ray"
|
||||
- "Trojan"
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 999
|
||||
interval: 100
|
||||
|
||||
# 代理节点选择
|
||||
- name: "PROXY"
|
||||
|
||||
@@ -6,11 +6,17 @@ USE_PROCD=1
|
||||
START=99
|
||||
|
||||
start_service() {
|
||||
#创建clash后台进程
|
||||
procd_open_instance
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
procd_set_param command /etc/clash/clash -d /etc/clash
|
||||
procd_close_instance
|
||||
#修改iptables规则使流量进入clash
|
||||
iptables -I FORWARD -o utun -j ACCEPT
|
||||
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
stop_service() {
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ external-controller: 0.0.0.0:9999
|
||||
|
||||
dns:
|
||||
enable: true
|
||||
listen: 0.0.0.0:53 #监听端口,0.0.0.0则拦截所有
|
||||
listen: 0.0.0.0:1053 #监听端口,0.0.0.0则拦截所有
|
||||
fake-ip-range: 198.18.0.1/16 #fake-ip模式下子网段,尽量不要改动
|
||||
enhanced-mode: fake-ip #尽量不要改动
|
||||
nameserver: #国内DNS,可配置多条
|
||||
- tls://dns.rubyfish.cn:853
|
||||
- 127.0.0.1:5335 #本地dnsmasq服务器
|
||||
- 127.0.0.1:53 #本地dnsmasq服务器
|
||||
fallback: #国外DNS,可配置多条
|
||||
- tcp://1.1.1.1
|
||||
- tls://dns.google:853
|
||||
@@ -86,7 +86,7 @@ proxy-groups: #代理服务器组
|
||||
- "v2ray"
|
||||
- "Trojan"
|
||||
url: 'http://www.gstatic.com/generate_204'
|
||||
interval: 999
|
||||
interval: 100
|
||||
|
||||
# 代理节点选择
|
||||
- name: "PROXY"
|
||||
|
||||
Reference in New Issue
Block a user