静看光阴荏苒
不管不顾不问不说也不念

sing-box TUN+REALITY(iOS/Windows客户端配置示例)

最近sing-box又出了一个新的ios客户端:sfi。

sfi目前使用起来还不太方便,配置只能手搓,不过这都小问题,主要是目前想在ios上用reality的话就只有这个客户端支持,小火箭啥的估计没个把月不会更新。。

更多关于sfi的介绍可看这里:https://sing-box.sagernet.org/installation/clients/sfi/

reality服务端的配置可看我之前的这篇文章:https://lala.im/8610.html

有一个需要注意的点是新版本的sing-box现在vless入站也要填写flow了:

"flow": "xtls-rprx-vision"

其他的没有变化,下面是我自己根据文档搓的2份客户端配置文件,一个ios的,一个windows的。

ios:

{
  "log": {
    "level": "info",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "tag": "cloudflare",
        "address": "https://1.1.1.1/dns-query"
      },
      {
        "tag": "dnspod",
        "address": "https://1.12.12.12/dns-query",
        "detour": "direct"
      },
      {
        "tag": "block",
        "address": "rcode://success"
      }
    ],
    "rules": [
      {
        "geosite": "cn",
        "server": "dnspod"
      },
      {
        "geosite": "category-ads-all",
        "server": "block",
        "disable_cache": true
      }
    ]
  },
  "inbounds": [
    {
      "type": "tun",
      "tag": "tun-in",
      "interface_name": "tun0",
      "inet4_address": "172.19.0.1/30",
      "auto_route": true,
      "strict_route": true,
      "stack": "gvisor",
      "sniff": true
    }
  ],
  "outbounds": [
    {
      "type": "vless",
      "tag": "vless-out",
      "server": "1.2.3.4",
      "server_port": 443,
      "uuid": "8497c213-e47c-4df3-beb0-2f3db1605062",
      "flow": "xtls-rprx-vision",
      "network": "tcp",
      "tls": {
        "enabled": true,
        "server_name": "www.docker.com",
        "utls": {
      	  "enabled": true,
      	  "fingerprint": "safari"
         },
        "reality": {
      	  "enabled": true,
      	  "public_key": "o60BMlDgf_k_hAryojHWGrDkqjR8SvcYK5asrOoU1hA",
      	  "short_id": "5d2e3ed92cf8a73b"
        }
      }
    },
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "block",
      "tag": "block"
    },
    {
      "type": "dns",
      "tag": "dns"
    }
  ],
  "route": {
    "rules": [
      {
        "protocol": "dns",
        "outbound": "dns"
      },
      {
        "geosite": "cn",
        "geoip": [
          "cn",
          "private"
        ],
        "outbound": "direct"
      },
      {
        "geosite": "category-ads-all",
        "outbound": "block"
      }
    ]
  }
}

windows:

{
  "log": {
    "level": "info",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "tag": "cloudflare",
        "address": "https://1.1.1.1/dns-query"
      },
      {
        "tag": "dnspod",
        "address": "https://1.12.12.12/dns-query",
        "detour": "direct"
      },
      {
        "tag": "block",
        "address": "rcode://success"
      }
    ],
    "rules": [
      {
        "geosite": "cn",
        "server": "dnspod"
      },
      {
        "geosite": "category-ads-all",
        "server": "block",
        "disable_cache": true
      }
    ]
  },
  "inbounds": [
    {
      "type": "tun",
      "tag": "tun-in",
      "interface_name": "singbox-tun",
      "inet4_address": "172.20.0.1/30",
      "auto_route": true,
      "strict_route": true,
      "stack": "system",
      "sniff": true
    }
  ],
  "outbounds": [
    {
      "type": "vless",
      "tag": "vless-out",
      "server": "1.2.3.4",
      "server_port": 443,
      "uuid": "8497c213-e47c-4df3-beb0-2f3db1605062",
      "flow": "xtls-rprx-vision",
      "network": "tcp",
      "tls": {
        "enabled": true,
        "server_name": "www.docker.com",
        "utls": {
      	  "enabled": true,
      	  "fingerprint": "chrome"
         },
        "reality": {
      	  "enabled": true,
      	  "public_key": "o60BMlDgf_k_hAryojHWGrDkqjR8SvcYK5asrOoU1hA",
      	  "short_id": "5d2e3ed92cf8a73b"
        }
      }
    },
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "block",
      "tag": "block"
    },
    {
      "type": "dns",
      "tag": "dns"
    }
  ],
  "route": {
    "rules": [
      {
        "protocol": "dns",
        "outbound": "dns"
      },
      {
        "geosite": "cn",
        "geoip": [
          "cn",
          "private"
        ],
        "outbound": "direct"
      },
      {
        "geosite": "category-ads-all",
        "outbound": "block"
      }
    ],
    "auto_detect_interface": true
  }
}

2个平台配置的时候都有一些需要注意的点。

ios:sfi不支持system stack,所以配置里面用的是gvisor。

windows:开启strict_route可以防止dns泄漏。另外必须配置auto_detect_interface防止流量环回。

无论是ios还是windows使用tun模式的时候,dns服务器不要把格式配置成system协议的。

ios的配置导入进去就能用了,下面我记录下windows的额外配置。

由于我这个win10里面有很多接口,我看了下有virtualbox、vmware、openvpn、网易uu游戏加速器等很多:

windows默认对这些接口都会自动设置一个优先级,如果这些接口的优先级比你用来上网的那个接口优先级高(一般用来上网的接口叫“以太网”。)那么sing-box就会把优先级最高的那个接口当作默认接口,这样就会导致最后sing-box是不能正常用的。

要解决的话也很简单,笨办法,把不用的接口都禁用掉,只留下用来上网的“以太网”。一开始我就是这样配置的,但是想了下这也太不方便了。后来仔细研究了下,发现是可以手动设置优先级的,下面说下方法。

首先用管理员身份打开powershell,执行下面的命令查看接口信息:

Get-NetIPInterface

主要看接口InterfaceMetric下面的值,值越低说明优先级越高:

可以看到我用来上网的“以太网”接口的值是100,而virtualbox、vmware等接口的值是25、35,都比“以太网”的值低。现在要做的就是修改这些接口的值,执行如下命令修改:

Set-NetIPInterface -InterfaceIndex 3 -InterfaceMetric 110
Set-NetIPInterface -InterfaceIndex 13 -InterfaceMetric 120
Set-NetIPInterface -InterfaceIndex 4 -InterfaceMetric 130
Set-NetIPInterface -InterfaceIndex 16 -InterfaceMetric 130

再看下,确认修改完成:

参考:

https://sing-box.sagernet.org/configuration/inbound/tun/
https://sing-box.sagernet.org/examples/tun/
https://sing-box.sagernet.org/examples/dns-hijack/
https://www.windowscentral.com/how-change-priority-order-network-adapters-windows-10

赞(9)
未经允许不得转载:荒岛 » sing-box TUN+REALITY(iOS/Windows客户端配置示例)
分享到: 更多 (0)

评论 14

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    大佬神速,已经安排上了。
    不过iOS上的测速只有不到一百兆,同网络环境同vps的其它协议其它客户端500m以上。sfi这边开发人员说没有限速,不知是什么原因

    hellobaby1年前 (2023-03-09) Safari 16.3 Safari 16.3 iPhone iOS 16.3 iPhone iOS 16.3回复
  2. #2

    编译出来为啥只是个文件,没有格式呢?我下载下来,改成exe后缀,也无法执行,报错。

    jell1年前 (2023-03-10) Safari 16.3 Safari 16.3 Mac OS X  10.15.7 Mac OS X 10.15.7回复
  3. #3

    大佬,sing-box支持H2类型了吗

    Cheek1年前 (2023-03-14) Safari 16.3 Safari 16.3 Mac OS X  10.15.7 Mac OS X 10.15.7回复
  4. #4

    iOS
    sing-box
    udp怎么开大佬,上面配置无udp

    1111年前 (2023-04-07) Safari 16.3 Safari 16.3 iPhone iOS 16.3.1 iPhone iOS 16.3.1回复
    • 把outbounds里面的这个配置删掉”network”: “tcp”,默认就启用tcp和udp了。

      LALA1年前 (2023-04-10) Google Chrome 111.0.0.0 Google Chrome 111.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
  5. #5

    大佬, 最后那里试试不要”auto_detect_interface”: true 改成”default_interface”: “Lan” LAN替换成你的上网网口名称 .

    还有一事请教 , 想把TUN的虚拟网卡设成共享给有线网卡, 让电脑充当网关,其他设备设置网关指向电脑IP, 实现UDP上网.
    可是每次一设置共享, 就连网都上不了了, (一开启共享会强制把有线网设置成192.168.137.1, 已手动改回原地址), 有时能上, 但是指向电脑网关的设备也上不了, 不知道是不是出现路由环路 . 之前用SSTAP 可以成功实现, 但是要同时开两个软件,而且是TAP模式, 想着能简单点用SING-BOX 或者V2RAYN来弄, 结果搞了三四天还没折腾出来 :cry:

    chan1年前 (2023-04-08) Google Chrome 111.0.0.0 Google Chrome 111.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
  6. #6

    大佬,新版本sing-box “flow”: “xtls-rprx-vision”,怎么加?
    https://lala.im/8610.html 整个配置可以连接,本文的windows tun或ios都不能连接上,服务器是1.2 beta5 ,ios版本是1.3 beta9。

    wang1年前 (2023-04-28) Google Chrome 112.0.0.0 Google Chrome 112.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 把服务器的sing-box也升级到1.3beta9。”flow”: “xtls-rprx-vision”加在服务器的入站配置里面:https://sing-box.sagernet.org/configuration/inbound/vless/

      LALA1年前 (2023-05-04) Google Chrome 102.0.0.0 Google Chrome 102.0.0.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
  7. #7

    大佬,ios配置不行
    sing-box 1.3 beta11 ios
    (packet-tunnel) error: start service: open geoip database: invalid argument

    wang12个月前 (05-06) Safari 16.3 Safari 16.3 iPhone iOS 16.3.1 iPhone iOS 16.3.1回复
  8. #8

    我是全局走VPN。arch Linux 當路由器PPPOE撥號,關閉NAT,全OSPF static route,沒這麼多屁事。Endpoint VPS加個DMZ iptables rules 輕輕鬆鬆Full cone.不再折騰了

    John11个月前 (06-15) Google Chrome 114.0.0.0 Google Chrome 114.0.0.0 Android 10 Android 10回复
    • 還有一條vxLan via VPN,給其他設備用

      John11个月前 (06-15) Google Chrome 114.0.0.0 Google Chrome 114.0.0.0 Android 10 Android 10回复
  9. #9

    怎么在同一个配置文件中添加多个节点?即可以在Groups中可以显示出来,谢谢

    kady7个月前 (10-03) Google Search App 283.0.567502095 Google Search App 283.0.567502095 iPhone iOS 17.0 iPhone iOS 17.0回复

分享创造快乐

广告合作资源投稿