V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
info521
V2EX  ›  宽带症候群

请问 tailscale 新自建中继 DERP 如何建立部署,是否可以共享给其他人使用

  •  
  •   info521 · 2021-07-26 17:28:51 +08:00 · 7436 次点击
    这是一个创建于 976 天前的主题,其中的信息可能已经有所发展或是发生改变。
    55 条回复    2022-04-20 17:30:29 +08:00
    Sekai
        1
    Sekai  
       2021-07-27 15:32:28 +08:00
    搞好了,先在小鸡上配置好 go 环境。
    然后安装 derper:
    go install tailscale.com/cmd/derper@main
    然后修改自己网页上的 Access Controls,注意替换域名:
    https://www.codepile.net/pile/dNnwGoMA
    最后执行
    derper -c=$HOME/derper.conf -a xxx.xxx.xxx:998 --stun (我这里 443 占用了所以改成了 998 )
    重启各个机器上的 tailscale 服务,在网页的 Machine Details 里就能看到了,会显示 Relay #901 。应该还能用自己的证书,不过我还没时间看。
    info521
        2
    info521  
    OP
       2021-07-27 16:31:23 +08:00
    $HOME 这个写死的吗,还是不同系统不通目录的?
    info521
        3
    info521  
    OP
       2021-07-27 16:32:37 +08:00
    他这个可以共享给别人使用的,只要知道你的域名和端口
    info521
        4
    info521  
    OP
       2021-07-27 16:35:33 +08:00
    $HOME 是缺省目录,是必须 root 目录吗?
    info521
        5
    info521  
    OP
       2021-07-27 16:56:33 +08:00
    derper -c=$HOME/derper.conf -a xxx.xxx.xxx:998 --stun 执行这一步时候,提示命令不存在,
    Sekai
        6
    Sekai  
       2021-07-28 15:46:50 +08:00
    @info521 应该可以共享的,命令不存在就是 derper 没装上吧,其他的我也不怎么懂
    info521
        7
    info521  
    OP
       2021-07-28 16:04:19 +08:00
    @Sekai 找到原因了,环境变量没设置好
    info521
        8
    info521  
    OP
       2021-07-28 16:05:02 +08:00
    derper: command not found
    go version

    sudo vim /etc/profile
    export GOROOT=/usr/lib/go-1.16
    export GOPATH=/root/go
    export GOBIN=$GOPATH/bin
    export PATH=$PATH:$GOROOT/bin
    export PATH=$PATH:$GOPATH/bin

    添加完成按 Esc 键,然后输入:wq 再按回车保存退出,然后执行以下命令,使配置生效。
    source /etc/profile
    ylx
        9
    ylx  
       2021-08-26 10:12:15 +08:00
    @Sekai 改成 998 后 Access Controls 里面的 hostname 是不是也需要加端口
    按 998 配好后用你的示例没反应
    mangohaoming
        10
    mangohaoming  
       2021-08-28 16:28:34 +08:00
    请问解决了吗
    Sekai
        11
    Sekai  
       2021-08-29 21:19:34 +08:00
    @ylx 我没加……它那个很奇怪,有的机器 Relays 里面会显示全部服务器也有自己配置的,有的就只有两个服务器甚至一个没有...
    Sekai
        12
    Sekai  
       2021-08-29 21:28:19 +08:00
    @ylx 还有就是安装 supervisor 之类的守护一下进程
    mangohaoming
        13
    mangohaoming  
       2021-08-30 10:29:09 +08:00
    @Sekai 你好,小白请教两个问题:1. derper.conf 文件示例能否共享一下. 2. Access Controlss 设置改 hostname 与新增 derpermap 节点在 json 根节点这样可以吗?
    Sekai
        14
    Sekai  
       2021-08-30 22:47:40 +08:00
    @mangohaoming derper.conf 自始至终就没动过,我都不知道在哪,看了一下里面是 PrivateKey 。第二个问题没看懂,可能我也是一知半解……
    mangohaoming
        15
    mangohaoming  
       2021-08-31 11:04:04 +08:00
    @Sekai 配置 Access Controlss 只需要填 hostname 吗?
    mangohaoming
        16
    mangohaoming  
       2021-08-31 13:12:16 +08:00
    @Sekai 配置成功了,感谢
    info521
        17
    info521  
    OP
       2021-09-01 10:38:37 +08:00
    @mangohaoming 能否把步骤分享下,我配置了,一直没成功;
    mangohaoming
        18
    mangohaoming  
       2021-09-08 09:51:10 +08:00
    @info521 步骤和 Sekai 说的一样,注意检查防火墙端口有没有开放,derper 进程有没有一直在运行(可以用进程守护工具守护)
    mangohaoming
        19
    mangohaoming  
       2021-09-18 13:20:29 +08:00
    @Sekai 你好,测试发现用其它端口不能正常使用 stun 转发,请问你的正常吗
    Sekai
        20
    Sekai  
       2021-09-19 14:16:34 +08:00
    @mangohaoming 有显示什么错误嘛?
    mangohaoming
        21
    mangohaoming  
       2021-09-19 19:22:12 +08:00
    @Sekai 没有提示错误,设备面板也显示链接上了,就是 p2p 无法打洞的情况下两个客户端就 ping 不通了
    mangohaoming
        22
    mangohaoming  
       2021-09-19 19:44:19 +08:00
    @Sekai 就只有采用默认的 443 端口才一切正常
    Sekai
        23
    Sekai  
       2021-09-21 22:21:08 +08:00
    @mangohaoming 要不把命令改成 derper -c=$HOME/derper.conf -a 0.0.0.0:998 --stun 试试?否则还是防火墙的问题吧,如果用 443 打洞正常的情况下,另外还可以换高位端口。
    mangohaoming
        24
    mangohaoming  
       2021-09-22 08:59:43 +08:00
    @Sekai 测试了也还是不行,相关端口系统防火墙和外围安全组都确认 tcp/udp 都放开了,终端运行命令只有启动提示,443 端口是有客户端接入提示的。
    Sekai
        25
    Sekai  
       2021-09-22 14:08:57 +08:00
    @mangohaoming 那我真没辙了,实在想用只能换系统试试,debian10 centos7 我这都可以,能加多台。
    mangohaoming
        26
    mangohaoming  
       2021-09-22 16:13:45 +08:00
    @Sekai 你的 vps 是哪家的,我的是腾讯云。我换一下系统镜像试试
    Sekai
        27
    Sekai  
       2021-09-23 11:29:56 +08:00
    @mangohaoming 毛子 gc,清凉云应该 dd 之后再用啊
    oddcc
        28
    oddcc  
       2021-09-23 14:51:09 +08:00
    请教一下,部署成功之后,是怎么指定流量走自建的 DERP 的?
    需要把官方的全部禁用吗?
    mangohaoming
        29
    mangohaoming  
       2021-09-23 16:25:03 +08:00
    @oddcc 设置这个参数就行,"OmitDefaultRegions": true,作为 derpMap 的子节点
    mangohaoming
        30
    mangohaoming  
       2021-09-23 16:28:37 +08:00
    @Sekai 意思是腾讯云要换自己上传的镜像去安装后再使用?
    oddcc
        31
    oddcc  
       2021-10-28 17:43:59 +08:00
    确实是这样, 测下来用 443 才能转发成功
    否则只是能在 admin 中看到连上了这个 node, 实际还是 ping 不通
    zyqv2
        32
    zyqv2  
       2021-11-17 09:41:29 +08:00
    可以试试这个 docker 镜像 zouyq/derper,亲测是 ok 的,主要网络最好使用桥接模式,非 443 端口需要配置服务端证书,并在 tailscale 管理控制台那里添加 DERPPort:xxx 指定端口
    cweijan
        33
    cweijan  
       2021-11-21 02:10:34 +08:00
    @oddcc, 我配置成功了, 自定义端口不是在 HostName 后面加, 而是需要增加 DERPPort, 例子
    ```json
    {
    "DERPMap": {
    "OmitDefaultRegions": false,
    "Regions": {
    "900": {
    "RegionID": 900,
    "RegionCode": "1",
    "Nodes": [
    {
    "HostName": "xxxx",
    "DERPPort": 998,
    "Name": "1",
    "RegionID": 900
    }
    ]
    }
    }
    }
    }
    ```
    info521
        34
    info521  
    OP
       2021-11-25 23:32:46 +08:00
    转载:

    https://mangoroom.cn/tools/tailscale-custom-derper-servers.html

    节点为腾讯云广州节点,带宽有限,请勿滥用,如果想支持本节点可双击下方点赞或者请芒果喝一杯奶茶

    // Example/default ACLs for unrestricted connections.
    {
    // Declare static groups of users beyond those in the identity service.
    "Groups": {
    "group:example": [ "[email protected]", "[email protected]" ],
    },
    // Declare convenient hostname aliases to use in place of IP addresses.
    "Hosts": {
    "example-host-1": "100.100.100.100",
    },
    "ACLs": [
    // Match absolutely everything. Comment out this section if you want
    // to define specific ACL restrictions.
    { "Action": "accept", "Users": ["*"], "Ports": ["*:*"] },
    ],
    "derpMap": {
    "Regions": { "900": {
    "RegionID": 900,
    "RegionCode": "mangoderp",
    "Nodes": [{
    "Name": "1",
    "RegionID": 900,
    //本节点由 mangoroom.cn 提供,请勿滥用。详情访问 https://mangoroom.cn/tools/tailscale-custom-derper-servers.html
    "HostName":"tailscalederper.mangoroom.cn",
    }]
    }}
    }
    }
    info521
        35
    info521  
    OP
       2021-11-25 23:33:32 +08:00
    info521
        36
    info521  
    OP
       2021-11-25 23:37:21 +08:00
    1.16 版本开始,可以自定义 DERP 端口

    当前版本是 1.16 。现在有用户使用自定义 DERP 端口

    https://github.com/tailscale/tailscale/issues/1264


    搜索关键词

    DERP
    This is a Tailscale DERP server.

    可找到公开的 DERP 中继服务器;
    info521
        37
    info521  
    OP
       2021-11-26 00:17:41 +08:00
    转载:

    https://blog.laisky.com/p/tailscale/ 四、安装、部署

    关于备案信息,tls,letsencrypt 解释
    info521
        39
    info521  
    OP
       2021-11-26 14:31:56 +08:00
    如何启用 DERP 客户端限制
    https://github.com/tailscale/tailscale/issues/3024

    derper --help
    -verify-clients
    verify clients to this DERP server through a local tailscaled instance.
    xxb
        40
    xxb  
       2021-12-01 02:26:42 +08:00
    我用 docker 自建的 derp ,貌似证书没有自动搞定
    info521
        41
    info521  
    OP
       2021-12-01 15:26:53 +08:00
    是国内吗?国内的域名备案,
    info521
        42
    info521  
    OP
       2021-12-08 11:58:41 +08:00
    服务端开源版本

    协调服务器的开源、自托管实现
    控制服务器用作 Tailscale 网络中节点的 Wireguard 公钥交换点。它还分配客户端的 IP 地址,在每个用户之间创建边界,在用户之间启用共享机器,并公开您节点的通告路由。

    headscale

    https://github.com/juanfont/headscale

    完全自己部署独立整套系统
    info521
        43
    info521  
    OP
       2021-12-25 23:34:42 +08:00
    docker 容器化部署中继 DERP

    https://hub.docker.com/r/zouyq/derper

    默认 443 ,自定义端口
    info521
        44
    info521  
    OP
       2021-12-26 23:53:10 +08:00
    腾讯云容器自建 DERP:
    1 、域名备案,
    2 、域名解析
    3 、域名 SSL 申请 1 年免费,crt key 文件下载
    4 、规划访问端口,例如 8082tcp ,3478udp stun ,防火墙放行;
    5 、docker 安装,命令执行
    docker run -it -d --name derper -p 8082:8082 访问端口映射 -p 3478:3478/udp -v /自定义证书目录 derpssl:/cert zouyq/derper /derper -hostname hostname -stun -a :8082 自定义端口 -certmode manual -certdir /cert

    6 、安装检查
    curl https://hostname.com:8082

    https://hostname.com:8082

    7 、tailscale 控制端设置 derp
    info521
        45
    info521  
    OP
       2021-12-27 00:10:13 +08:00
    转:tailscale 自建 derper 服务器中转,使用自定义端口
    https://blog.csdn.net/opopop880/article/details/122125430
    info521
        46
    info521  
    OP
       2021-12-28 12:42:35 +08:00
    节点分享,直接复制进去就可以,重启下客户端,目前 2 个国内节点
    https://www.yuque.com/docs/share/4ce6a5f6-bf8d-4233-9501-59ae8dfbe65e?# 《 Tailscale DERP 》
    yangchuansheng33
        47
    yangchuansheng33  
       2022-01-08 18:00:52 +08:00
    @Sekai 我这边测试虽然 derper 生效了,但是 ping 不通 peer ,非 443 端口。能不能告知一下的你的详细配置步骤啊
    info521
        48
    info521  
    OP
       2022-01-09 22:17:07 +08:00
    info521
        49
    info521  
    OP
       2022-01-13 17:40:49 +08:00
    taiscale 客户端 容器 docker 安装

    https://github.com/tailscale/tailscale/issues/504 容器安装讨论
    https://github.com/tailscale/tailscale/blob/main/Dockerfile 镜像构建文件
    https://hub.docker.com/r/tailscale/tailscale 镜像直接下载

    # This Dockerfile includes all the tailscale binaries.
    #
    # To build the Dockerfile:
    #
    # $ docker build -t tailscale/tailscale .
    #
    # To run the tailscaled agent:
    #
    # $ docker run -d --name=tailscaled -v /var/lib:/var/lib -v /dev/net/tun:/dev/net/tun --network=host --privileged tailscale/tailscale tailscaled
    #
    # To then log in:
    #
    # $ docker exec tailscaled tailscale up
    #
    # To see status:
    #
    # $ docker exec tailscaled tailscale status
    latteczy
        50
    latteczy  
       2022-03-16 15:23:08 +08:00
    可以不用 HTTPS 吗?
    fuergaosi
        51
    fuergaosi  
       2022-03-26 23:12:23 +08:00
    @info521 测试了一下, 似乎不需要使用 HTTPS 证书, 只要修改域名的解析就可以.
    info521
        52
    info521  
    OP
       2022-03-27 21:31:40 +08:00
    要的,你在试试,他们计划使用自签名,只是不依赖别家 ssl
    info521
        53
    info521  
    OP
       2022-03-27 21:40:20 +08:00
    Sekai
        54
    Sekai  
       2022-04-17 16:36:53 +08:00
    derper -c=/root/derper.conf -hostname=你的域名 -http-port 81 -certmode=manual -certdir=/etc/nginx/ssl -stun
    记录一下
    preach
        55
    preach  
       2022-04-20 17:30:29 +08:00
    已搭建成功,docker
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5413 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 06:47 · PVG 14:47 · LAX 23:47 · JFK 02:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.