sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

docker版本sing-box的拨号字段"inet4_bind_address"功能不正常

Open crosspacific opened this issue 4 months ago • 0 comments

Operating system

Linux

System version

Ubuntu 22.04

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

No response

Version

docker版本 latest v1.9.7

Description

使用docker-compose安装sing-box,安装配置如下:

services:
  sing-box:
    image: ghcr.io/sagernet/sing-box
    container_name: sing-box
    restart: always
    ports:
      - 12345:12345
    volumes:
      - /etc/sing-box:/etc/sing-box/
    command: -D /var/lib/sing-box -C /etc/sing-box/ run

配置文件如下:

{
  "log": {
    "disabled": false,
    "level": "info",
    "output": "/etc/sing-box/box.log",
    "timestamp": true
  },
  "inbounds": [
    {
      "type": "vless",
      "tag": "vless-in",
      "listen": "::",
      "listen_port": 12345,
      "users": [
        {
          "uuid": "da45b40c-e76e-41f2-b3f9-3fcbef8bb42d",
          "flow": "xtls-rprx-vision"
        }
      ],
      "tls": {
        "enabled": true,
        "server_name": "shopee.sg",
        "reality": {
          "enabled": true,
          "handshake": {
            "server": "shopee.sg",
            "server_port": 443
          },
          "private_key": "Usrgh*********",
          "short_id": [
            "12"
          ]
        }
      }
    }
  ],
  "route": {
    "rules": [
      {
        "rule_set": [
          "geoip-cn",
          "geosite-cn",
          "geosite-category-ads-all"
        ],
        "outbound": "block"
      }
    ],
    "rule_set": [
      {
        "tag": "geoip-cn",
        "type": "remote",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geosite-cn",
        "type": "remote",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geosite-category-ads-all",
        "type": "remote",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.srs",
        "download_detour": "direct"
      }
    ],
    "final": "direct"
  },
  "experimental": {
    "cache_file": {
      "enabled": true,
      "path": "cache.db",
      "cache_id": "myprofile",
      "store_fakeip": true
    }
  },
  "outbounds": [
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "block",
      "tag": "block"
    }
  ]
}

以上配置在docke模式下都可以正常连接。

服务器有多个IPv4,而当出站绑定IP时,就不能连接了。 20241014091208

  "outbounds": [
    {
      "type": "direct",
      "tag": "direct",
      "inet4_bind_address": "10.0.0.225"
    },
    {
      "type": "block",
      "tag": "block"
    }
  ]

日志1: 使用上面的docke-compose文件,docker 容器启动不成功,

+0000 2024-10-14 01:56:43 INFO router: updated default interface eth0, index 148
+0000 2024-10-14 01:56:43 INFO inbound/vless[vless-in]: tcp server started at [::]:12345
+0000 2024-10-14 01:56:43 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:43 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:43 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:44 INFO router: updated default interface eth0, index 150
+0000 2024-10-14 01:56:44 INFO inbound/vless[vless-in]: tcp server started at [::]:12345
+0000 2024-10-14 01:56:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:45 INFO router: updated default interface eth0, index 152
+0000 2024-10-14 01:56:45 INFO inbound/vless[vless-in]: tcp server started at [::]:12345
+0000 2024-10-14 01:56:45 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:45 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:45 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 01:56:47 INFO router: updated default interface eth0, index 154

日志2:使用以下docke-compose文件,docker容器能启动,能连接,但是出站的IP却是IPv6

services:
  sing-box:
    image: ghcr.io/sagernet/sing-box
    container_name: sing-box
    restart: always
    networks:
      mynet:
        ipv4_address: 172.21.0.100
        ipv6_address: fc68:6689::100
    ports:
      - 12345:12345
    volumes:
      - /etc/sing-box:/etc/sing-box/
    command: -D /var/lib/sing-box -C /etc/sing-box/ run
networks:
  mynet:
    external: true
+0000 2024-10-14 02:05:44 INFO router: updated default interface eth0, index 180
+0000 2024-10-14 02:05:44 INFO inbound/vless[vless-in]: tcp server started at [::]:12345
+0000 2024-10-14 02:05:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 02:05:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 02:05:44 INFO outbound/direct[direct]: outbound connection to raw.githubusercontent.com:443
+0000 2024-10-14 02:05:45 INFO router: updated rule-set geosite-category-ads-all
+0000 2024-10-14 02:05:45 INFO router: updated rule-set geoip-cn
+0000 2024-10-14 02:05:45 INFO router: updated rule-set geosite-cn
+0000 2024-10-14 02:05:45 INFO sing-box started (0.400s)
+0000 2024-10-14 02:06:09 INFO [2229602172 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:8066
+0000 2024-10-14 02:06:10 INFO [214559259 0ms] inbound/vless[vless-in]: [0] inbound connection to www.google.com:443
+0000 2024-10-14 02:06:10 INFO [214559259 0ms] outbound/direct[direct]: outbound connection to www.google.com:443
+0000 2024-10-14 02:06:53 INFO [2429109179 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:8081
+0000 2024-10-14 02:06:53 INFO [3958608712 0ms] inbound/vless[vless-in]: [0] inbound connection to mtalk.google.com:5228
+0000 2024-10-14 02:06:53 INFO [3958608712 0ms] outbound/direct[direct]: outbound connection to mtalk.google.com:5228
+0000 2024-10-14 02:06:54 INFO [424627220 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:2590
+0000 2024-10-14 02:06:54 INFO [1307094314 0ms] inbound/vless[vless-in]: [0] inbound connection to www.google.com:443
+0000 2024-10-14 02:06:54 INFO [1307094314 0ms] outbound/direct[direct]: outbound connection to www.google.com:443
+0000 2024-10-14 02:06:56 INFO [1343315709 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:2593
+0000 2024-10-14 02:06:56 INFO [305784505 1ms] inbound/vless[vless-in]: [0] inbound connection to alive.github.com:443
+0000 2024-10-14 02:06:56 INFO [305784505 1ms] outbound/direct[direct]: outbound connection to alive.github.com:443
+0000 2024-10-14 02:06:56 ERROR [1343315709 202ms] inbound/vless[vless-in]: process connection from 125.88.24.243:2593: dial tcp 10.0.0.225:0->140.82.112.25:443: bind: cannot assign requested address
+0000 2024-10-14 02:06:57 INFO [679592172 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:2594
+0000 2024-10-14 02:06:57 INFO [1441513489 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:8083
+0000 2024-10-14 02:06:57 INFO [1771993709 0ms] inbound/vless[vless-in]: inbound connection from 125.88.24.243:8084
+0000 2024-10-14 02:06:57 INFO [346190264 0ms] inbound/vless[vless-in]: [0] inbound connection to self.events.data.microsoft.com:443
+0000 2024-10-14 02:06:57 INFO [346190264 0ms] outbound/direct[direct]: outbound connection to self.events.data.microsoft.com:443
+0000 2024-10-14 02:06:57 ERROR [679592172 209ms] inbound/vless[vless-in]: process connection from 125.88.24.243:2594: dial tcp 10.0.0.225:0->13.89.179.8:443: bind: cannot assign requested address

ip.gs 结果:2603:c024:4502:********:6688:6666:8888

总结:以上配置在不使用docker,直接安装singbox时,可以正常连接,使用docker后,绑定IP的功能失效。

Reproduction

singbox配置文件 config.json

Logs

No response

Supporter

Integrity requirements

  • [X] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • [X] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • [X] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • [X] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.

crosspacific avatar Oct 14 '24 02:10 crosspacific