SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.03k stars 2.38k forks source link

TUN模式转发异常 #836

Closed XboxSoldier closed 1 year ago

XboxSoldier commented 1 year ago

操作系统

Windows

系统版本

Windows 11 Professional Workstation 22H2 Build 22621.2215

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

No response

版本

sing-box version 1.3.0

Environment: go1.20.5 windows/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_clash_api
Revision: 29b1dba2bb70b0f77bbeb764d745c592147785ad
CGO: disabled

描述

TUN模式不能正常转发到出站,导致无法联网。

重现方式

使用以下配置文件,开启TUN模式访问一个reality节点。

// 这不是一个程序生成的配置文件!
{
    "log":
    {
        "disabled": false,
        "level": "info",
        "output": "box.log",
        "timestamp": true
    },
    "dns":
    {
        "servers":
        [
            {
                "tag": "comDNS",
                "address": "https://1.1.1.1/dns-query"
            }
        ],
        "fakeip":
        {
            "enabled": false
        }
    },
    "inbounds":
    [
        {
            "type": "tun",
            "tag": "tun-in",
            "interface_name": "singbox-tun",
            "mtu": 9000,
            "inet4_address": "172.20.0.1/30",
            "inet6_address": "fdfe:dcba:9876::1/126",
            "auto_route": true,
            "strict_route": true,
            "stack": "system",
            "sniff": false
        }
    ],
    "outbounds":
    [
        {
            "type": "vless",
            "tag": "tun-out",
            "server": "(An IPV6 Address)",
            "server_port": 443,
            "uuid": "",
            "flow": "xtls-rprx-vision",
            "network": "tcp",
            "tls": {
                "enabled": true,
                "server_name": "",
                "utls":
                {
                    "enabled": true,
                    "fingerprint": "ios"
                },
                "reality":
                {
                    "enabled": true,
                    "public_key": "",
                    "short_id": ""
                }
            },
            "packet_encoding": "xudp"
        },
        {
            "type": "direct",
            "tag": "direct"
        },
        {
            "type": "block",
            "tag": "block"
        },
        {
            "type": "dns",
            "tag": "dns"
        }
    ],
    "route":
    {
        "rules":
        [
            {
                "protocol":
                [
                    "dns"
                ],
                "outbound": "dns"
            }
        ],
        "auto_detect_interface": true
    }
}

无法连接,日志如下: box.log 尝试修改入站设置,将该部分修改为:

"inbounds":
    [
        // {
        //     "type": "tun",
        //     "tag": "tun-in",
        //     "interface_name": "singbox-tun",
        //     "mtu": 9000,
        //     "inet4_address": "172.20.0.1/30",
        //     "inet6_address": "fdfe:dcba:9876::1/126",
        //     "auto_route": true,
        //     "strict_route": true,
        //     "stack": "system",
        //     "sniff": false
        // }
        {
            "type": "socks",
            "tag": "socks-in",
            "listen": "::",
            "listen_port": 10808
        },
        {
            "type": "http",
            "tag": "http-in",
            "listen": "::",
            "listen_port": 10809,
            "set_system_proxy": false
        }
    ],

将系统代理设置为127.0.0.1:10809,可以正常访问网页。

日志

```console # 使用日志内容覆盖此行 ```
nekohasekai commented 1 year ago

您没有配置 DNS 劫持。