clash_for_windows_pkg icon indicating copy to clipboard operation
clash_for_windows_pkg copied to clipboard

[Bug?]: Clash无法发送UDP包到本地sock5代理, 把`127.0.0.1`换成本地IP`192.168.x.x`后问题消失

Open CXwudi opened this issue 2 years ago • 10 comments

请认真检查以下清单中的每一项

  • [X] 已经搜索过,没有发现类似issue
  • [x] 已经搜索过文档,没有发现相关内容
  • [x] 已经尝试使用过最新版,问题依旧存在
  • [x] 使用的是官方版本(未替换及修改过安装目录程序文件)

软件版本

0.19.27 (昨天发现的问题, 今天还没来得及更新)

操作系统

Windows x64

系统版本

Win10 Pro 21h2

问题描述

如标题所述, 用TUN模式连接本地代理后, UDP无法代理 image TCP流量正常 在clash profile里如果把127.0.0.1换成本地IP192.168.x.x就没有问题

复现步骤

  1. 自搭建一个支持UDP的梯子, xray或者trojan-go都可以, 服务端和客户端部署好, 客户端开放一个sock5端口, 比如说1080
  2. clash创建一个这样的profile来连接至本地的proxy客户端
    proxies:
      - name: My-proxy
        type: socks5
        server: 127.0.0.1
        port: <你的端口>
        udp: true
        skip-cert-verify: true
    rules:
      - GEOIP,LAN,DIRECT # ignore localhost and other local network IPs
      - RULE-SET,applications,DIRECT # do not loop the proxy itself
      - MATCH,My-proxy
    rule-providers:
      applications:
        type: http
        behavior: classical
        url: "https://raw.githubusercontent.com/Loyalsoldier/clash-rules/release/applications.txt"
        path: ./ruleset/applications.yaml
        interval: 86400
    
  3. 打开TUN模式, 观察UDP流量

日志文件

logs

time="2022-08-26T17:49:16-04:00" level=info msg="RESTful API listening at: 127.0.0.1:56557"
time="2022-08-26T17:49:16-04:00" level=info msg="Mixed(http+socks) proxy listening at: 127.0.0.1:7890"
time="2022-08-26T17:49:17-04:00" level=info msg="Start initial rule provider applications"
time="2022-08-26T17:59:55-04:00" level=info msg="Start initial rule provider applications"
time="2022-08-26T17:59:59-04:00" level=info msg="Start initial rule provider applications"
time="2022-08-26T17:59:59-04:00" level=info msg="Tun Proxy listening at: Clash(198.18.0.1)"
time="2022-08-26T18:00:03-04:00" level=info msg="[TCP] 198.18.0.1:58055 --> www.msftconnecttest.com:80 using DIRECT"
time="2022-08-26T18:00:04-04:00" level=info msg="[TCP] 198.18.0.1:58058 --> mtalk.google.com:443 using DIRECT"
time="2022-08-26T18:00:05-04:00" level=info msg="[TCP] 198.18.0.1:58062 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:05-04:00" level=info msg="[TCP] 198.18.0.1:58061 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:05-04:00" level=info msg="Mixed(http+socks) proxy listening at: [::]:7890"
time="2022-08-26T18:00:06-04:00" level=info msg="[TCP] 198.18.0.1:58071 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:06-04:00" level=info msg="[TCP] 198.18.0.1:58070 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:06-04:00" level=info msg="[TCP] 198.18.0.1:58072 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:06-04:00" level=info msg="[TCP] 198.18.0.1:58079 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:06-04:00" level=info msg="[TCP] 198.18.0.1:58080 --> outlook.office365.com:443 using DIRECT"
time="2022-08-26T18:00:07-04:00" level=info msg="[TCP] 198.18.0.1:58085 --> outlook.office.com:443 using DIRECT"
time="2022-08-26T18:00:07-04:00" level=info msg="[TCP] 198.18.0.1:58088 --> www.gigabyte.com:80 using DIRECT"
time="2022-08-26T18:00:07-04:00" level=info msg="[TCP] 198.18.0.1:58090 --> go.microsoft.com:80 using DIRECT"
time="2022-08-26T18:00:07-04:00" level=info msg="[UDP] 198.18.0.1:54206 --> pool.ntp.org:123 using DIRECT"
time="2022-08-26T18:00:07-04:00" level=info msg="[TCP] 198.18.0.1:58093 --> dmd.metaservices.microsoft.com:80 using DIRECT"
time="2022-08-26T18:00:13-04:00" level=info msg="[TCP] 198.18.0.1:58099 --> www.bing.com:443 using DIRECT"
time="2022-08-26T18:00:13-04:00" level=info msg="[TCP] 198.18.0.1:58100 --> www.bing.com:443 using DIRECT"
time="2022-08-26T18:00:13-04:00" level=info msg="[TCP] 198.18.0.1:58098 --> www.bing.com:443 using DIRECT"
time="2022-08-26T18:00:14-04:00" level=info msg="[TCP] 198.18.0.1:58107 --> substrate.office.com:443 using DIRECT"
time="2022-08-26T18:00:14-04:00" level=info msg="[TCP] 198.18.0.1:58110 --> api.onedrive.com:443 using DIRECT"
time="2022-08-26T18:00:14-04:00" level=info msg="[TCP] 198.18.0.1:58111 --> api.onedrive.com:443 using DIRECT"
time="2022-08-26T18:00:14-04:00" level=info msg="[TCP] 198.18.0.1:58114 --> bnz07pap001files.storage.live.com:443 using DIRECT"
time="2022-08-26T18:00:14-04:00" level=info msg="[TCP] 198.18.0.1:58115 --> cmailcarletonca-my.sharepoint.com:443 using DIRECT"
time="2022-08-26T18:00:15-04:00" level=info msg="[TCP] 198.18.0.1:58118 --> self.events.data.microsoft.com:443 using DIRECT"
time="2022-08-26T18:00:15-04:00" level=info msg="[TCP] 198.18.0.1:58120 --> s-ring.msedge.net:443 using DIRECT"
time="2022-08-26T18:00:15-04:00" level=info msg="[TCP] 198.18.0.1:58122 --> fp-as.azureedge.net:443 using DIRECT"
time="2022-08-26T18:00:15-04:00" level=info msg="[TCP] 198.18.0.1:58125 --> l-ring.msedge.net:443 using DIRECT"
time="2022-08-26T18:00:15-04:00" level=info msg="[TCP] 198.18.0.1:58127 --> fp.msedge.net:443 using DIRECT"
time="2022-08-26T18:00:17-04:00" level=info msg="[TCP] 198.18.0.1:58129 --> checkappexec.microsoft.com:443 using DIRECT"
time="2022-08-26T18:00:18-04:00" level=info msg="[TCP] 198.18.0.1:58133 --> rum8.perf.linkedin.com:443 using DIRECT"
time="2022-08-26T18:00:19-04:00" level=info msg="[TCP] 198.18.0.1:58136 --> teams-ring.msedge.net:443 using DIRECT"
time="2022-08-26T18:00:19-04:00" level=info msg="[TCP] 198.18.0.1:58139 --> a-ring-fallback.msedge.net:443 using DIRECT"
time="2022-08-26T18:00:23-04:00" level=info msg="[TCP] 198.18.0.1:58144 --> self.events.data.microsoft.com:443 using DIRECT"
time="2022-08-26T18:00:24-04:00" level=info msg="[TCP] 198.18.0.1:58148 --> 142.250.112.109:993 match Match() using Trojan-go"
time="2022-08-26T18:00:24-04:00" level=info msg="[TCP] 198.18.0.1:58150 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:00:28-04:00" level=info msg="[TCP] 198.18.0.1:58153 --> mtalk.google.com:5228 match Match() using Trojan-go"
time="2022-08-26T18:00:29-04:00" level=info msg="[UDP] 198.18.0.1:54834 --> fonts.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[TCP] 198.18.0.1:58156 --> www.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[UDP] 198.18.0.1:64910 --> cdn.jsdelivr.net:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[TCP] 198.18.0.1:58160 --> api2.gettoby.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[TCP] 198.18.0.1:58158 --> www.vocaloard.injpok.tokyo:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[TCP] 198.18.0.1:58167 --> cdn.jsdelivr.net:443 match Match() using Trojan-go"
time="2022-08-26T18:00:30-04:00" level=info msg="[TCP] 198.18.0.1:58164 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:00:31-04:00" level=info msg="[TCP] 198.18.0.1:58169 --> encrypted-tbn0.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:31-04:00" level=info msg="[TCP] 198.18.0.1:58159 --> nd-static.bdstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:33-04:00" level=info msg="[TCP] 198.18.0.1:58172 --> self.events.data.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:33-04:00" level=info msg="[TCP] 198.18.0.1:58177 --> self.events.data.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:33-04:00" level=info msg="[TCP] 198.18.0.1:58174 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:00:35-04:00" level=info msg="[UDP] 198.18.0.1:54478 --> optimizationguide-pa.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:37-04:00" level=info msg="[UDP] 198.18.0.1:62583 --> d.joinhoney.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:37-04:00" level=info msg="[TCP] 198.18.0.1:58181 --> d.joinhoney.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:37-04:00" level=info msg="[UDP] 198.18.0.1:50944 --> safebrowsing.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:37-04:00" level=info msg="[UDP] 198.18.0.1:63016 --> www.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:39-04:00" level=info msg="[TCP] 198.18.0.1:58185 --> optimizationguide-pa.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:39-04:00" level=info msg="[UDP] 198.18.0.1:58274 --> optimizationguide-pa.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:41-04:00" level=info msg="[TCP] 198.18.0.1:58188 --> safebrowsing.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:41-04:00" level=info msg="[UDP] 198.18.0.1:51176 --> safebrowsing.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:41-04:00" level=info msg="[TCP] 198.18.0.1:58191 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:00:42-04:00" level=info msg="[UDP] 198.18.0.1:61299 --> safebrowsing.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:42-04:00" level=info msg="[UDP] 198.18.0.1:53925 --> ogs.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:42-04:00" level=info msg="[UDP] 198.18.0.1:59907 --> d.joinhoney.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:46-04:00" level=info msg="[TCP] 198.18.0.1:58197 --> ogs.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:46-04:00" level=info msg="[UDP] 198.18.0.1:60286 --> www.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:46-04:00" level=info msg="[UDP] 198.18.0.1:60360 --> ssl.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:47-04:00" level=info msg="[UDP] 198.18.0.1:58016 --> clients4.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58205 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58207 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58206 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58208 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58213 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:00:51-04:00" level=info msg="[UDP] 198.18.0.1:57783 --> clients4.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:51-04:00" level=info msg="[TCP] 198.18.0.1:58216 --> clients4.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:00:56-04:00" level=info msg="[TCP] 198.18.0.1:58219 --> www.facebook.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:03-04:00" level=info msg="[TCP] 198.18.0.1:58221 --> api.languagetool.org:443 match Match() using Trojan-go"
time="2022-08-26T18:01:07-04:00" level=info msg="[TCP] 198.18.0.1:58223 --> www.gigabyte.com:80 match Match() using Trojan-go"
time="2022-08-26T18:01:07-04:00" level=info msg="[TCP] 198.18.0.1:58225 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:01:07-04:00" level=info msg="[UDP] 198.18.0.1:62181 --> pool.ntp.org:123 match Match() using Trojan-go"
time="2022-08-26T18:01:13-04:00" level=info msg="[TCP] 198.18.0.1:58229 --> go.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:43-04:00" level=info msg="[TCP] 198.18.0.1:58231 --> ssl.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:43-04:00" level=info msg="[UDP] 198.18.0.1:52256 --> ssl.gstatic.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:43-04:00" level=info msg="[UDP] 198.18.0.1:54376 --> beacons.gcp.gvt2.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:47-04:00" level=info msg="[TCP] 198.18.0.1:58235 --> beacons.gcp.gvt2.com:443 match Match() using Trojan-go"
time="2022-08-26T18:01:47-04:00" level=info msg="[UDP] 198.18.0.1:63612 --> beacons.gcp.gvt2.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:01-04:00" level=info msg="[TCP] 198.18.0.1:58238 --> www.facebook.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:07-04:00" level=info msg="[TCP] 198.18.0.1:58240 --> www.gigabyte.com:80 match Match() using Trojan-go"
time="2022-08-26T18:02:07-04:00" level=info msg="[UDP] 198.18.0.1:60729 --> pool.ntp.org:123 match Match() using Trojan-go"
time="2022-08-26T18:02:09-04:00" level=info msg="[TCP] 198.18.0.1:58243 --> github.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:09-04:00" level=info msg="[TCP] 198.18.0.1:58245 --> github-production-user-asset-6210df.s3.amazonaws.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:09-04:00" level=info msg="[TCP] 198.18.0.1:58247 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:02:11-04:00" level=info msg="[TCP] 198.18.0.1:58250 --> user-images.githubusercontent.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58254 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58253 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58256 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58255 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58257 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:21-04:00" level=info msg="[TCP] 198.18.0.1:58252 --> outlook.office365.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:33-04:00" level=info msg="[TCP] 198.18.0.1:58264 --> activity.windows.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:34-04:00" level=info msg="[UDP] 198.18.0.1:64121 --> clients2.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:34-04:00" level=info msg="[UDP] 198.18.0.1:62042 --> update.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:35-04:00" level=info msg="[TCP] 198.18.0.1:58268 --> update.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:38-04:00" level=info msg="[TCP] 198.18.0.1:58270 --> clients2.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:38-04:00" level=info msg="[UDP] 198.18.0.1:65399 --> clients2.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:40-04:00" level=info msg="[TCP] 198.18.0.1:58273 --> settings-win.data.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:02:52-04:00" level=info msg="[TCP] 198.18.0.1:58275 --> array511.prod.do.dsp.mp.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:03:07-04:00" level=info msg="[TCP] 198.18.0.1:58277 --> www.gigabyte.com:80 match Match() using Trojan-go"
time="2022-08-26T18:03:07-04:00" level=info msg="[TCP] 198.18.0.1:58279 --> d1y29giq8qd6nr.cloudfront.net:443 match RuleSet(applications) using DIRECT"
time="2022-08-26T18:03:07-04:00" level=info msg="[UDP] 198.18.0.1:60019 --> pool.ntp.org:123 match Match() using Trojan-go"
time="2022-08-26T18:03:21-04:00" level=info msg="[TCP] 198.18.0.1:58283 --> go.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:03:26-04:00" level=info msg="[UDP] 198.18.0.1:63816 --> clients4.google.com:443 match Match() using Trojan-go"
time="2022-08-26T18:03:32-04:00" level=info msg="[TCP] 198.18.0.1:58286 --> api.atlassian.com:443 match Match() using Trojan-go"
time="2022-08-26T18:03:49-04:00" level=info msg="[TCP] 198.18.0.1:58288 --> array501.prod.do.dsp.mp.microsoft.com:443 match Match() using Trojan-go"
time="2022-08-26T18:04:00-04:00" level=info msg="[TCP] 198.18.0.1:58290 --> www.facebook.com:443 match Match() using Trojan-go"
time="2022-08-26T18:04:07-04:00" level=info msg="[TCP] 198.18.0.1:58292 --> www.gigabyte.com:80 match Match() using Trojan-go"
time="2022-08-26T18:04:07-04:00" level=info msg="[UDP] 198.18.0.1:59999 --> pool.ntp.org:123 match Match() using Trojan-go"
time="2022-08-26T18:04:17-04:00" level=info msg="[UDP] 198.18.0.1:53975 --> content-autofill.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:04:21-04:00" level=info msg="[TCP] 198.18.0.1:58296 --> content-autofill.googleapis.com:443 match Match() using Trojan-go"
time="2022-08-26T18:04:21-04:00" level=info msg="[UDP] 198.18.0.1:52541 --> content-autofill.googleapis.com:443 match Match() using Trojan-go"

其他补充

没有mixin, TUN配置使用的是默认配置改了几个DNS, system proxy没开, parser没动, 没有diff

我知道有UWP应用无法本地回环的问题, 用那个Loopback Exemption Tool可以解决, 但window exe应用UDP无法本地回环这还是第一次见. 也不知道到底是clash的问题还是win10的问题, 所以标题写成 [bug?]

CXwudi avatar Aug 26 '22 22:08 CXwudi

Meple也出现过类似的问题, 但毕竟那是个UWP应用所以说不清楚, 那个问题提到说即使解除了UWP本地回环问题后连接 socket 操作依旧被拒绝, 不知道跟本issue是否有相似之处

CXwudi avatar Aug 26 '22 22:08 CXwudi

+1 有类似情况,本地程序单独设置HTTP代理,代理地址如果设为127.0.0.1无法正常工作,部分请求会无法收到回复,提示目标不存在。改设为本地网卡的静态IP 192.168.x.x后正常。

QS0x01 avatar Aug 27 '22 13:08 QS0x01

我题目里说的就是TUN模式不能用127.0.0.1

CXwudi avatar Sep 03 '22 07:09 CXwudi

我的情况是开不开tun模式都不能正常连接127.0.0.1的socks5的udp。

kckm avatar Sep 27 '22 16:09 kckm