nishuoshenme
V2EX  ›  Windows

Windows Sandbox 无法联网

  •  
  •   nishuoshenme · May 8, 2022 · 5892 views
    This topic created in 1466 days ago, the information mentioned may be changed or developed.
    使用 Clash for Windows 的时候打开 Windows Sandbox 会使其无法连网,关闭 cfw 又可以了,有什么办法可以在开着 cfw 的情况下让 Windows Sandbox 正常连网吗?
    9 replies    2026-02-06 17:39:55 +08:00
    Thymolblue
        1
    Thymolblue  
       May 8, 2022 via Android
    下个 fiddler 允许应用通过就行了
    windows 老问题了
    ncepuzs
        2
    ncepuzs  
       May 8, 2022
    如果是楼上所说的问题,那直接在 Clash for Windows 通用设置 UWP Loopback 中操作就行
    Tumblr
        3
    Tumblr  
       May 8, 2022   ❤️ 1
    其实不需要什么乌七八糟的工具,Windows 本来就有提供 CheckNetIsolation.exe ,添加到例外里就 OK 了。
    我没用过 CfW ,不知道有什么工具,不过如果有自带的,参考 @ncepuzs #2 的建议可能操作会方便一些。

    另外,@Thymolblue #1 这不是个问题( problem ),这是 by design 的。😅为了安全考虑,不给走本地回环的代理。
    Thymolblue
        4
    Thymolblue  
       May 8, 2022 via Android
    @Tumblr
    @ncepuzs
    学到了 thx
    EricXuu
        5
    EricXuu  
       May 9, 2022
    sandbox 会继承宿主机的代理设置,cfw 不要开系统代理。
    SpecterShell
        6
    SpecterShell  
       May 9, 2022
    Windows 沙盒 使用宿主机的系统代理设置,但 IP 地址又和宿主机不一样。
    Clash for Windows 开启系统代理会将沙盒内外的代理地址都设置为 127.0.0.1 ,宿主机会将其识别为宿主机本地地址,而沙盒会将其识别为沙盒本地地址,不断尝试连接沙盒内不存在的端口,自然无法联网了。
    想要让 Windows 沙盒走代理,要不就在 CFW 或系统设置中将代理地址设置为网关地址,要不就关闭 CFW 的系统代理,使用 TUN 或 TAP 。
    nishuoshenme
        7
    nishuoshenme  
    OP
       May 10, 2022
    @SpecterShell #6 学到了,感谢
    firefoxwang
        8
    firefoxwang  
       Apr 23, 2024
    刚搜了一圈,就是把 windows 系统代理设置中修改为 clash 提供的 http 代理地址( clash for windows 选择 Allow LAN ),ip 是本机的内网地址,比如 192.1.68.1.x 啥的。这样就能让 windows 沙盒走 cfw 的代理了。
    Need4more
        9
    Need4more  
       Feb 6
    1. 添加启动脚本:setproxy.bat

    @echo off
    setlocal enabledelayedexpansion

    for /f "tokens=2 delims=:" %%i in ('cmd /c "ipconfig | findstr /i /c:"默认网关" /c:"Default Gateway" | findstr /r "[0-9]\.[0-9]""') do (
    set GATEWAY_IP=%%i
    )

    set "GATEWAY_IP=%GATEWAY_IP: =%"

    :proxy_set
    if not defined GATEWAY_IP (
    echo 错误:未找到有效的网关 IP 地址
    pause
    exit /b 1
    )

    netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=7890 connectaddress=%GATEWAY_IP% connectport=7890 protocol=tcp
    echo 端口转发成功 TCP !GATEWAY_IP!:7890 -^> 127.0.0.1:7890

    echo 正在设置代理为 127.0.0.1:7890
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "127.0.0.1:7890" /f >nul
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f >nul

    echo 代理设置成功!
    echo 代理地址: 127.0.0.1:7890


    2. wsb 文件配置:
    <LogonCommand>
    <Command>C:\temp\setup.bat</Command>
    </LogonCommand>
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5561 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 07:35 · PVG 15:35 · LAX 00:35 · JFK 03:35
    ♥ Do have faith in what you're doing.