Tailscale docker自建derp服务器 自定义端口

本文详细介绍了如何在服务器上设置固定IP、安装SSL证书、使用Certbot获取LetsEncrypt证书,以及通过Docker部署和配置Derp服务,同时涉及Tailscale的Accesscontrols设置。
摘要由CSDN通过智能技术生成

一、安装需求

1. 需要一台固定ip服务器和域名,把域名解析到服务器,然后安装tailscale

2. 在服务器生成SSL证书,证书获取:Let's Encrypt 公益证书 Certbot Instructions | Certbot

    2.1 安装snapd,安装certbot需要

sudo apt update
sudo apt install snapd

  2.2安装certbot

sudo snap install --classic certbot

   2.3获取证书,下面方法只针对下面命令有效:域名需要能访问,比如你的域名是example.com,那么它会在域名的根目录生成一个文件,然后能访问,访问地址类似于:http://www.example.com/.well-known/acme-challenge/rSBeoZjsO3JkCGP2IrGZ9T3POjQDml95Uzl2KjBjkuY

sudo certbot certonly --webroot

   回车后填入域名,填入域名根目录

    完成后显示类似下面的页面,在目录中fullchain.pem就是crt,privkey.pem就是key:

  

3.安装docker服务(小白最好弄个宝塔服务器面板,一键全能部署及管理,方便)

二、安装derp

国内服务商有防火墙的记得开放端口3478,8443,3478需要开放udp协议:

docker run -d \
--name derp \
--restart=always \
-p 0.0.0.0:3478:3478/udp \
-p 0.0.0.0:8443:8443 \
-v /etc/letsencrypt/live/derper.example.com/fullchain.pem:/app/certs/example.com.crt \
-v /etc/letsencrypt/live/derper.example.com/privkey.pem:/app/certs/example.com.key \
-v /var/run/tailscale/tailscaled.sock:/var/run/tailscale/tailscaled.sock \
-e DERP_DOMAIN=derper.example.com \
-e DERP_ADDR=:8443 \
-e DERP_CERT_MODE=manual \
-e DERP_VERIFY_CLIENTS=true \
fredliang/derper:latest

然后去tailscale Access controls 修改配置,增加下面一项即可:

代码:

// Example/default ACLs for unrestricted connections.
{
	// Declare static groups of users. Use autogroups for all users or users with a specific role.
	// "groups": {
	//  	"group:example": ["alice@example.com", "bob@example.com"],
	// },

	// Define the tags which can be applied to devices and by which users.
	// "tagOwners": {
	//  	"tag:example": ["autogroup:admin"],
	// },

	// Define access control lists for users, groups, autogroups, tags,
	// Tailscale IP addresses, and subnet ranges.
	"acls": [
		// Allow all connections.
		// Comment this section out if you want to define specific restrictions.
		{"action": "accept", "src": ["*"], "dst": ["*:*"]},
	],

	// Define users and devices that can use Tailscale SSH.
	"ssh": [
		// Allow all users to SSH into their own devices in check mode.
		// Comment this section out if you want to define specific restrictions.
		{
			"action": "check",
			"src":    ["autogroup:member"],
			"dst":    ["autogroup:self"],
			"users":  ["autogroup:nonroot", "root"],
		},
	],
	"derpMap": {
		"Regions": {
			"900": {
				"RegionID":   900,
				"RegionCode": "myderp",
				"Nodes": [
					{
						"Name":     "1",
						"RegionID": 900,
						"HostName": "derper.example.com",
						"DERPPort": 8443,
					},
				],
			},
		},
	},
	// Test access rules every time they're saved.
	// "tests": [
	//  	{
	//  		"src": "alice@example.com",
	//  		"accept": ["tag:example"],
	//  		"deny": ["100.101.102.103:443"],
	//  	},
	// ],
}

 保存后去admin machines 点开服务器查看,有900表示成功了

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Ubuntu上使用Docker搭建DNS服务器,可以按照以下步骤进行操作: 1. 安装Docker 在Ubuntu上安装Docker,可以通过以下命令完成: ``` sudo apt update sudo apt install docker.io ``` 2. 创建一个Docker容器 使用以下命令可以创建一个Docker容器: ``` sudo docker run -d --name dns-server -p 53:53/udp --restart=always --hostname dns.example.com jacobalberty/unbound:latest ``` 这个命令会从Docker Hub上下载jacobalberty/unbound镜像,并在容器中启动unbound DNS服务器。 3. 配置DNS服务器 可以通过以下命令进入容器的shell,并编辑unbound配置文件: ``` sudo docker exec -it dns-server bash vi /etc/unbound/unbound.conf ``` 在配置文件中,可以添加自己需要的DNS解析规则,例如: ``` local-zone: "example.com." redirect local-data: "example.com. IN A 192.168.1.1" ``` 4. 测试DNS服务器 可以使用dig命令测试DNS服务器是否正常工作,例如: ``` dig @localhost example.com ``` 如果返回了上面配置的IP地址,则说明DNS服务器已经正确地解析了域名。 5. 设置客户端DNS服务器 在客户端上,可以将刚才创建的DNS服务器地址添加到/etc/resolv.conf文件中,例如: ``` nameserver 192.168.1.2 ``` 其中,192.168.1.2是刚才创建的DNS服务器的IP地址。这样,客户端就可以使用该DNS服务器进行域名解析了。 以上就是在Ubuntu上使用Docker搭建DNS服务器的步骤。需要注意的是,由于DNS服务器需要使用53号端口,因此在创建Docker容器时需要将该端口映射到主机上。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值