vernesong / OpenClash

A Clash Client For OpenWrt
MIT License
16.93k stars 3.11k forks source link

openclash 在旁路由上无法科学上网,但是在win上使用clashforwindows就可以 #2064

Closed Charlemagnescl closed 2 years ago

Charlemagnescl commented 2 years ago

有配置adguardhome,不知道是否有影响。 openclash放在旁路由上,看起来运行正常,但是无法科学上网( 旁路由上也ping不通外网),但是国内可以正常访问。 win上也安装了clash,开启之后可以科学上网。

各种配置建议也欢迎提出,本人刚刚接触这一块,不甚了解。

调试日志如下:

OpenClash 调试日志

生成时间: 2022-02-17 11:18:50
插件版本: v0.38.6-beta

#===================== 系统信息 =====================#
主机型号: Intel(R) Core(TM) i5-8600 CPU @ 3.10GHz : 1 Core 1 Thread
固件版本: OpenWrt GDQ IPv4 with 2.5G 6.1[2020]
LuCI版本: git-20.141.34051-f750b5f-1
内核版本: 4.19.122
处理器架构: x86_64

#此项在使用Tun模式时应为ACCEPT
防火墙转发: ACCEPT

#此项有值时建议到网络-接口-lan的设置中禁用IPV6的DHCP
IPV6-DHCP: 

#此项结果应仅有配置文件的DNS监听地址
Dnsmasq转发设置: 127.0.0.1#7874

#===================== 依赖检查 =====================#
dnsmasq-full: 已安装
coreutils: 已安装
coreutils-nohup: 已安装
bash: 已安装
curl: 已安装
jsonfilter: 已安装
ca-certificates: 已安装
ipset: 已安装
ip-full: 已安装
iptables-mod-tproxy: 已安装
kmod-tun(TUN模式): 已安装
luci-compat(Luci-19.07): 未安装

#===================== 内核检查 =====================#
运行状态: 运行中
已选择的架构: linux-amd64

#下方无法显示内核版本号时请确认您的内核版本是否正确或者有无权限
Tun内核版本: 
Tun内核文件: 不存在
Tun内核运行权限: 否

Game内核版本: 
Game内核文件: 不存在
Game内核运行权限: 否

Dev内核版本: v1.9.0-7-gb1a639f
Dev内核文件: 存在
Dev内核运行权限: 正常

#===================== 插件设置 =====================#
当前配置文件: /etc/openclash/config/cnix.yaml
运行模式: fake-ip
默认代理模式: Rule
UDP流量转发: 启用
DNS劫持: 启用
自定义DNS: 停用
IPV6-DNS解析: 停用
禁用Dnsmasq缓存: 停用
自定义规则: 停用
仅允许内网: 停用
仅代理命中规则流量: 停用

#启动异常时建议关闭此项后重试
保留配置: 停用
第三方规则: 停用

#===================== 配置文件 =====================#
#!MANAGED-CONFIG ***隐藏***

#---------------------------------------------------#
## 上次更新于:2022-02-16 03:10:52
#---------------------------------------------------#

port: 7890
socks-port: 7891
redir-port: 7892
allow-lan: true
bind-address: "*"
mode: Rule
log-level: silent
external-controller: 0.0.0.0:9090
secret: "123456"
external-ui: "/usr/share/openclash/dashboard"
dns:
  enable: true
  ipv6: false
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  listen: 127.0.0.1:7874
  fake-ip-filter:
##Custom fake-ip-filter##
  - '*.lan'
  - 'time.windows.com'
  - 'time.nist.gov'
  - 'time.apple.com'
  - 'time.asia.apple.com'
  - '*.ntp.org.cn'
  - '*.openwrt.pool.ntp.org'
  - 'time1.cloud.tencent.com'
  - 'time.ustc.edu.cn'
  - 'pool.ntp.org'
  - 'ntp.ubuntu.com'
  - 'ntp.aliyun.com'
  - 'ntp1.aliyun.com'
  - 'ntp2.aliyun.com'
  - 'ntp3.aliyun.com'
  - 'ntp4.aliyun.com'
  - 'ntp5.aliyun.com'
  - 'ntp6.aliyun.com'
  - 'ntp7.aliyun.com'
  - 'time1.aliyun.com'
  - 'time2.aliyun.com'
  - 'time3.aliyun.com'
  - 'time4.aliyun.com'
  - 'time5.aliyun.com'
  - 'time6.aliyun.com'
  - 'time7.aliyun.com'
  - '*.time.edu.cn'
  - 'time1.apple.com'
  - 'time2.apple.com'
  - 'time3.apple.com'
  - 'time4.apple.com'
  - 'time5.apple.com'
  - 'time6.apple.com'
  - 'time7.apple.com'
  - 'time1.google.com'
  - 'time2.google.com'
  - 'time3.google.com'
  - 'time4.google.com'
  - 'music.163.com'
  - '*.music.163.com'
  - '*.126.net'
  - 'musicapi.taihe.com'
  - 'music.taihe.com'
  - 'songsearch.kugou.com'
  - 'trackercdn.kugou.com'
  - '*.kuwo.cn'
  - 'api-jooxtt.sanook.com'
  - 'api.joox.com'
  - 'joox.com'
  - 'y.qq.com'
  - '*.y.qq.com'
  - 'streamoc.music.tc.qq.com'
  - 'mobileoc.music.tc.qq.com'
  - 'isure.stream.qqmusic.qq.com'
  - 'dl.stream.qqmusic.qq.com'
  - 'aqqmusic.tc.qq.com'
  - 'amobile.music.tc.qq.com'
  - '*.xiami.com'
  - '*.music.migu.cn'
  - 'music.migu.cn'
  - '*.msftconnecttest.com'
  - '*.msftncsi.com'
  - 'localhost.ptlogin2.qq.com'
  - '*.*.*.srv.nintendo.net'
  - '*.*.stun.playstation.net'
  - 'xbox.*.*.microsoft.com'
  - '*.*.xboxlive.com'
##Custom fake-ip-filter END##
  nameserver:
  - 114.114.114.114
  fallback:
  - tls://8.8.8.8:853
  fallback-filter:
    geoip: true
    ipcidr:
      - 240.0.0.0/4

#===================== 防火墙设置 =====================#

#NAT chain

Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         
1    REDIRECT   tcp  --  0.0.0.0/0            8.8.4.4              redir ports 7892
2    REDIRECT   tcp  --  0.0.0.0/0            8.8.8.8              redir ports 7892
3    REDIRECT   udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:53 redir ports 53
4    REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:53 redir ports 53
5    DOCKER     all  --  0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL
6    prerouting_rule  all  --  0.0.0.0/0            0.0.0.0/0            /* !fw3: Custom prerouting rule chain */
7    zone_lan_prerouting  all  --  0.0.0.0/0            0.0.0.0/0            /* !fw3 */
8    zone_wan_prerouting  all  --  0.0.0.0/0            0.0.0.0/0            /* !fw3 */
9    zone_vpn_prerouting  all  --  0.0.0.0/0            0.0.0.0/0            /* !fw3 */
10   REDIRECT   udp  --  0.0.0.0/0            172.17.0.1           udp dpt:53 redir ports 53
11   REDIRECT   udp  --  0.0.0.0/0            10.232.1.10          udp dpt:53 redir ports 53
12   REDIRECT   udp  --  0.0.0.0/0            10.147.18.42         udp dpt:53 redir ports 53
13   openclash  tcp  --  0.0.0.0/0            0.0.0.0/0           
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    DOCKER     all  --  0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL
2    openclash_output  tcp  --  0.0.0.0/0            0.0.0.0/0           

#Mangle chain

Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         
1    openclash  udp  --  0.0.0.0/0            0.0.0.0/0           
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    RRDIPT_OUTPUT  all  --  0.0.0.0/0            0.0.0.0/0           

#===================== 路由表状态 =====================#
#route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.232.1.1      0.0.0.0         UG    0      0        0 eth0
10.147.18.0     0.0.0.0         255.255.255.0   U     0      0        0 ztrfydleri
10.232.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     10.147.18.159   255.255.255.0   UG    0      0        0 ztrfydleri
#ip route list
default via 10.232.1.1 dev eth0 proto static 
10.147.18.0/24 dev ztrfydleri proto kernel scope link src 10.147.18.42 
10.232.1.0/24 dev eth0 proto kernel scope link src 10.232.1.10 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 via 10.147.18.159 dev ztrfydleri 
#ip rule show
0:  from all lookup local 
32765:  from all fwmark 0x162 lookup 354 
32766:  from all lookup main 
32767:  from all lookup default 

#===================== 端口占用状态 =====================#
tcp        0      0 :::7890                 :::*                    LISTEN      7506/clash
tcp        0      0 :::7891                 :::*                    LISTEN      7506/clash
tcp        0      0 :::7892                 :::*                    LISTEN      7506/clash
tcp        0      0 :::9090                 :::*                    LISTEN      7506/clash
udp        0      0 127.0.0.1:7874          0.0.0.0:*                           7506/clash
udp        0      0 :::7891                 :::*                                7506/clash
udp        0      0 :::7892                 :::*                                7506/clash

#===================== 测试本机DNS查询 =====================#
Server:     127.0.0.1
Address:    127.0.0.1#53

Name:      www.baidu.com
www.baidu.com   canonical name = www.a.shifen.com
Name:      www.a.shifen.com
www.a.shifen.com    canonical name = www.wshifen.com
Name:      www.wshifen.com
Address 1: 103.235.46.39
www.baidu.com   canonical name = www.a.shifen.com
www.a.shifen.com    canonical name = www.wshifen.com

#===================== resolv.conf.auto =====================#
# Interface IPV6
nameserver fe80::1%eth0
# Interface lan
nameserver 10.232.1.1

#===================== 测试本机网络连接 =====================#
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 277
Content-Type: text/html
Date: Thu, 17 Feb 2022 03:18:51 GMT
Etag: "575e1f6f-115"
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Pragma: no-cache
Server: bfe/1.0.8.18

#===================== 测试本机网络下载 =====================#
HTTP/1.1 200 Connection established

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 80
Cache-Control: max-age=300
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
Content-Type: text/plain; charset=utf-8
ETag: "3328243d8f1fb3169128dad81c6d1fd2a760927ffe06628758cff1449a1028fd"
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-GitHub-Request-Id: FF9E:7230:E60A0:25B22E:620D6988
Accept-Ranges: bytes
Date: Thu, 17 Feb 2022 03:18:51 GMT
Via: 1.1 varnish
X-Served-By: cache-qpg1247-QPG
X-Cache: HIT
X-Cache-Hits: 2
X-Timer: S1645067932.619518,VS0,VE0
Vary: Authorization,Accept-Encoding,Origin
Access-Control-Allow-Origin: *
X-Fastly-Request-ID: a5de12a8cf14f841c01505e62070e1a0d94d2971
Expires: Thu, 17 Feb 2022 03:23:51 GMT
Source-Age: 108

#===================== 最近运行日志 =====================#
2022-02-17 00:14:32 OpenClash Reload After Firewall Restart
2022-02-17 00:14:41 OpenClash Reload After Firewall Restart
2022-02-17 00:14:52 OpenClash Reload After Firewall Restart
2022-02-17 00:15:07 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 00:15:18 OpenClash Reload After Firewall Restart
2022-02-17 00:15:42 OpenClash Reload After Firewall Restart
2022-02-17 00:16:07 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 00:17:20 OpenClash Reload After Firewall Restart
2022-02-17 00:18:08 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 00:18:52 OpenClash Reload After Firewall Restart
2022-02-17 00:19:02 OpenClash Reload After Firewall Restart
2022-02-17 00:19:08 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 00:19:57 OpenClash Reload After Firewall Restart
2022-02-17 00:19:59 OpenClash Reload After Firewall Restart
2022-02-17 00:20:08 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 00:20:08 OpenClash Reload After Firewall Restart
2022-02-17 00:20:29 OpenClash Reload After Firewall Restart
2022-02-17 00:20:53 OpenClash Reload After Firewall Restart
2022-02-17 00:21:08 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 10:19:31 OpenClash Reload After Firewall Restart
2022-02-17 10:20:00 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 10:20:08 OpenClash Reload After Firewall Restart
2022-02-17 10:21:00 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 10:28:54 OpenClash Reload After Firewall Restart
2022-02-17 10:29:01 Watchdog: Reset Firewall For Enabling Redirect.
2022-02-17 10:35:41 OpenClash Start Successful
2022-02-17 10:37:35 OpenClash Start Successful
2022-02-17 10:40:42 OpenClash Start Successful
2022-02-17 10:45:12 OpenClash Start Successful
2022-02-17 11:01:40 OpenClash Start Successful

可能有用的信息?:

clash 运行状态: image

接口设置或状态: image

ADGH相关配置: image image

旁路由网络连通情况: image

vernesong commented 2 years ago

版本太旧

Charlemagnescl commented 2 years ago

好的,非常感谢您的回答,但是我使用固件里openclash的“自动更新”功能,直接导致openclash消失了(luci界面)。 而在尝试直接使用您的release提供的最新ipk报错如下:

root@OpenWrt:/tmp/upload# opkg install luci-app-openclash_0.44.25-beta_all.ipk
Installing luci-app-openclash (0.44.25-beta) to root...
Multiple packages (libpthread and libpthread) providing same name marked HOLD or PREFER. Using latest.
Multiple packages (librt and librt) providing same name marked HOLD or PREFER. Using latest.
Installing libgmp10 (6.2.1-1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/x86_64/base/libgmp10_6.2.1-1_x86_64.ipk
Collected errors:
 * check_data_file_clashes: Package libgmp10 wants to install file /usr/lib/libgmp.so.10
        But that file is already provided by package  * libgmp
 * opkg_install_cmd: Cannot install package luci-app-openclash.

是否我的固件属于将openclash编译在内的那种? 对于这种固件的openclash更新,您有什么建议吗?

leeharuhiofcn commented 2 years ago

AdGuard home配openclash 的设置看到各种都有。不都一定适合(可用)。 我可用的设置如下,不一定适用于其他环境。如果对你有用就更好了。

@openwrt

网络 → DHCP/DNS → DNS转发 (port为openClash的端口)

127.0.0.1#7874

接口 → LAN口→ 使用自定义的DNS服务器 留空

@Clash

@AdGuard Home

Charlemagnescl commented 2 years ago

AdGuard home配openclash 的设置看到各种都有。不都一定适合(可用)。 我可用的设置如下,不一定适用于其他环境。如果对你有用就更好了。

@openwrt

网络 → DHCP/DNS → DNS转发 (port为openClash的端口)

127.0.0.1#7874

接口 → LAN口→ 使用自定义的DNS服务器 留空

@clash

  • 本地DNS劫持 启用 ✔
  • 自定义上游DNS服务器 启用 ✔
  • 服务器填写127.0.0.1,端口为ADGuard Home 的监听端口,通讯协议有4个(UDP,TCP,TLS,HTTPS)

@adguard Home

  • 重定向模式选择
  • 上游DNS设置为,上游运营商DNS(@全局设置,基础设置)

非常感谢您提供的配置,目前 adgh 已经在正常运行了,但是这种配置下 adgh 只能看到 127.0.0.1 的请求,无法分辨具体的客户端,是否是因为 clash 的 dns 劫持的原因呢? 另外,我目前遇到的更大的问题是, clash 可以正常运行,也能上 youtube 的网页,但是无法看视频( 一直处于转圈圈状态 ),也无法上谷歌。😢 不知道您是否有相关的意见和建议

leeharuhiofcn commented 2 years ago

非常感谢您提供的配置,目前 adgh 已经在正常运行了,但是这种配置下 adgh 只能看到 127.0.0.1 的请求,无法分辨具体的客户端,是否是因为 clash 的 dns 劫持的原因呢? 另外,我目前遇到的更大的问题是, clash 可以正常运行,也能上 youtube 的网页,但是无法看视频( 一直处于转圈圈状态 ),也无法上谷歌。😢 不知道您是否有相关的意见和建议

是的。ADGH只能看到127.0.0.1,其他通过旁路由的客户端是看不到的。 这个设定的主要目的是,Clash劫持掉所有的DNS(分流已在本阶段完成?具体是不是我没研究过),并让ADGH处理DNS的事务,,所以出来的只有1个客户端的。 无法看视频,可能需要等一等,需要检查一下adguard home默认的黑名单(建议取消打勾,优先保证上网需求在逐步添加广告策略)

其他设定也是有的,比如ADGH和Clash反过来的设定:

注意!!在任何操作前,非常建议备份openwrt,有些设置改来改去你会忘记改了什么,导致后面采用的建议不起效果。

@openwrt

关闭 dnsmasq(等于取消 网络 → DHCP/DNS 里的 DNS 重定向)

@openclash

关闭 本地DNS劫持 和 自定义上游DNS服务器 可设定上游(如ISP or 任何公共DNS)

@adguard home

用非 53 端口,重定向模式【重定向53端口到 AdGuardHome】 唯一上游设置为 127.0.0.1:7874 (openclash的端口)

设定方法很多,不一定有效,有些可能要等一下才有效果,试错时间是要有的。如果能帮到你就最好了。

pv0402 commented 2 years ago

非常感谢您提供的配置,目前 adgh 已经在正常运行了,但是这种配置下 adgh 只能看到 127.0.0.1 的请求,无法分辨具体的客户端,是否是因为 clash 的 dns 劫持的原因呢? 另外,我目前遇到的更大的问题是, clash 可以正常运行,也能上 youtube 的网页,但是无法看视频( 一直处于转圈圈状态 ),也无法上谷歌。😢 不知道您是否有相关的意见和建议

是的。ADGH只能看到127.0.0.1,其他通过旁路由的客户端是看不到的。

这个设定的主要目的是,Clash劫持掉所有的DNS(分流已在本阶段完成?具体是不是我没研究过),并让ADGH处理DNS的事务,,所以出来的只有1个客户端的。

无法看视频,可能需要等一等,需要检查一下adguard home默认的黑名单(建议取消打勾,优先保证上网需求在逐步添加广告策略)

其他设定也是有的,比如ADGH和Clash反过来的设定:

注意!!在任何操作前,非常建议备份openwrt,有些设置改来改去你会忘记改了什么,导致后面采用的建议不起效果。

@openwrt

关闭 dnsmasq(等于取消 网络 → DHCP/DNS 里的 DNS 重定向)

@openclash

关闭 本地DNS劫持 和 自定义上游DNS服务器

可设定上游(如ISP or 任何公共DNS)

@adguard home

用非 53 端口,重定向模式【重定向53端口到 AdGuardHome】

唯一上游设置为 127.0.0.1:7874 (openclash的端口)

设定方法很多,不一定有效,有些可能要等一下才有效果,试错时间是要有的。如果能帮到你就最好了。

分享下我的配置: Lan口dns服务器设置为空 dnsmasq改为非53端口 adguard改端口为53,重定向选无-自定义上游服务器为clash端口(7874)-clash关闭dns劫持,自定义上游服务器为运营商dns 我自己旁路由可用,效果不知道如何,没有对比过

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days