asd999cxcx
V2EX  ›  问与答

在阿里云自建 derp 服务器后,设备连接不稳定,只有两个设备同时 ping 的时候才能连通

  •  
  •   asd999cxcx · Jun 11, 2024 · 2589 views
    This topic created in 879 days ago, the information mentioned may be changed or developed.
    首先前提条件:家里和公司的电脑都能正常上网,且自建的 derp 服务器两台都可以通过 tailscale netcheck 看到,链接一是家里的电脑,连接二是公司的电脑,https://t.tutu.to/img/vfuZR ,https://t.tutu.to/img/vfe7e,ping 的情况如下链接 1 是家里 ping 公司,连接 2 是公司 ping 家里: https://t.tutu.to/img/vfOFm,https://t.tutu.to/img/vfokK ,前面几次没 ping 通是我单方面 ping 公司,后面几次 Ping 通了是我同时再用公司 ping 家里, 请问这种情况怎么解决?
    13 replies  •  2024-06-18 01:12:09 +08:00
    shxxy
    shxxy
    Jun 12, 2024 via Android
    1
    netcheck 只会检查 stun 服务的状态,不会检查中转是不是真的可用

    从图 4 来看应该是打洞成功了,不需要 derp 了
    你得再看看图三机器的 tailscale 日志才能确定为什么 timeout 了
    PolarBears
    PolarBears
    Jun 12, 2024
    2
    tailscale debug derp <region>命令看一下,另外 DERP 的服务器端口是默认 443 的话可以改一下,我腾讯云自建且有备案的情况下 443 端口也不稳定,但不稳定的状况和你表现的不同
    asd999cxcx
    asd999cxcx
    OP
    Jun 12, 2024
    3
    @qwq11 因为我在控制台的 AC 里面把他其他的节点都去掉了,就只保留了自建的 derp ,图三图四就是有时候家里 ping 公司 timeout (这个时候他在自动重试)然后再从公司 Ping 家里就 ping 通了,接着家里 ping 公司在重试的 ping 就没有 timeout ,但是如果隔一段时间不使用(或者说 RDP 过去),他又会回到最开始 timeout 的状态,tailscale 日志我晚点回去看看
    asd999cxcx
    asd999cxcx
    OP
    Jun 12, 2024
    4
    @PolarBears 这个命令是在哪台机器使用? DERP 服务器端口我是做了个映射,阿里云的外网 443 端口通过 nginx 映射到服务器本地 81 ,服务器本地 81 映射 docker 容器的 12345
    shxxy
    shxxy
    Jun 12, 2024
    5
    @asd999cxcx #3 移除其他节点也不应该有这么多 timeout ,除非 derp 连不上。我这里第一次 ping 时间会长一点,但是不会出现 timeout

    $ tailscale ping catty
    pong from catty (100.93.122.105) via DERP(cdu) in 1.007s
    pong from catty (100.93.122.105) via DERP(cdu) in 81ms

    看你这么长的反向代理链,你可以访问下 https://DERP_HOST:443 看能不能显示网页,正确的话应该是会显示 This is a Tailscale DERP server. SSL 证书也可能是个问题
    PolarBears
    PolarBears
    Jun 12, 2024
    6
    @asd999cxcx #4 两个客户端上用,建议不要用外网 443 端口换个端口试试? SSL 证书方面就使用手动模式,然后用 acme.sh 来获取证书来用,我不是用容器部署的,这是我运行 derp 服务器的命令:
    sudo ./derper -c "derp.conf" -hostname "derp.example.com" -http-port "-1" -a ":55500" -stun-port "3478" -certmode "manual" -certdir "/home/example/.acme.sh/derp.example.com_ecc"
    asd999cxcx
    asd999cxcx
    OP
    Jun 13, 2024
    7
    @qwq11 我通过 https://ip 访问是可以访问的,页面现实的是 This is a Tailscale DERP server. 但是域名就不行,SSL 证书我是按照腾讯云下载证书给的例子写的 https://t.tutu.to/img/vMiDA ,这个应该是没问题.我通过 tailscale-service 日志里面打印的类似这样的信息: https://t.tutu.to/img/vMYJh
    asd999cxcx
    asd999cxcx
    OP
    Jun 13, 2024
    8
    @PolarBears 我执行 tailscale debug derp region 得到下面结果 https://t.tutu.to/img/vuv5q
    shxxy
    shxxy
    Jun 13, 2024
    9
    @asd999cxcx #7 derper 会校验 SSL 证书和实际访问的 host 能不能对上,不管是自签的证书还是可信任的证书只要能对上就能用。域名不能访问的话,那猜测就是证书的问题了(对不上的话 derper 会直接 drop connection ,我猜日志里 connection was forcibly closed 就是这个原因)。建议你直接暴露 deprer 的端口,不走 nginx 的反代。贴个我的配置

    $ cat /etc/systemd/system/tailscale-derp.service
    [Unit]
    Description=Tailscale derp service
    After=network.target
    Wants=network-online.target

    [Service]
    EnvironmentFile=/home/sheey/derp/.env
    ExecStart=/home/sheey/go/bin/derper \
    -c /home/sheey/derp/derper.conf \
    -a :34567 -http-port -1 \
    -hostname ${DERP_HOSTNAME} \
    --certmode manual \
    -certdir /home/sheey/.cache/tailscale/derper-certs \
    --verify-clients
    Restart=always
    User=root

    [Install]
    WantedBy=multi-user.target


    "derpMap": {
    // "OmitDefaultRegions": true,
    "Regions": {
    "900": {
    "RegionID": 900,
    "RegionCode": "cdu",
    "RegionName": "Chengdu",
    "Nodes":[
    {
    "Name":" 900a",
    "RegionID": 900,
    "DERPPort": 34567,
    "STUNPort": 3478,
    "HostName": "", // $DERP_HOSTNAME
    "IPv4": "",
    // "InsecureForTests": true
    }
    ]
    }
    }
    }
    asd999cxcx
    asd999cxcx
    OP
    Jun 17, 2024
    10
    @qwq11 我最近尝试了下域名不能访问,是因为备案的原因,今天已经备案完了,域名可以访问,但是依旧不能 ping 通,tailscale 日志显示: https://t.tutu.to/img/vV5oq
    shxxy
    shxxy
    Jun 17, 2024
    11
    @asd999cxcx #10 不太明白你咋搞的,tg 上说吧 aHR0cHM6Ly90Lm1lL3RlbXBfb3Jzb25faGVycmVyYQ==
    asd999cxcx
    asd999cxcx
    OP
    Jun 18, 2024
    12
    @qwq11 加了,但是它提示我说只能给共同好友发消息
    asd999cxcx
    asd999cxcx
    OP
    Jun 18, 2024
    13
    @qwq11 OK,可以发消息了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1623 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:46 · PVG 20:46 · LAX 04:46 · JFK 07:46
    ♥ Do have faith in what you're doing.