• 请不要在回答技术问题时复制粘贴 AI 生成的内容
happydoge
V2EX  ›  程序员

sing-box tun 问题求教

  •  
  •   happydoge · May 20, 2024 · 3365 views
    This topic created in 743 days ago, the information mentioned may be changed or developed.

    sing-box 目前使用 systemd 管理的,且开启了 tun 模式, 参数如下

        {
          "type": "tun",
          "tag": "tun-in",
          "inet4_address": "198.18.0.1/16",
          "auto_route": true,
          "strict_route": false,
          "endpoint_independent_nat": false,
          "stack": "mixed",
          "sniff": true
        }
    

    同时当前机器还跑了 docker ,使用了桥接网络

    
    services:
      nginx:
      	# 示例
        image: nginx
        ports:
          - "80:80"
    
    networks:
      default:
        driver: bridge
        ipam:
          config:
            - subnet: 192.168.16.0/24
    

    这种情况下,没法直接 curl natip:80(当前服务器内网 ip curl 是正常的)

    需要在 tun 配置里 exclude_interface 相关 docker 网卡或者路由,才能通过公网 natip 访问

    但是配置这样的参数后,容器内又没办法访问 github 等外网了。

    有没有办法共存呢🤔,既可以访问外网又可以公网 nat 访问(另外 docker host 模式没问题,桥接有问题)

    3 replies    2024-08-15 01:10:14 +08:00
    sky96111
        1
    sky96111  
       May 20, 2024
    happydoge
        2
    happydoge  
    OP
       May 20, 2024
    @sky96111 我也搜到了,但是我的机器没 ipv6🤔
    addenvex
        3
    addenvex  
       Aug 15, 2024
    @sky96111 @happydoge 还是有点不一样的,这个 issue 使用的 host 模式,楼主使用的 bridge 模式,我目前也遇到想到的问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5410 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:22 · PVG 17:22 · LAX 02:22 · JFK 05:22
    ♥ Do have faith in what you're doing.