https://gitee.com/spoto/natserver

# Frp

# 服务器搭建(FRPS)

创建配置文件

# 创建存放目录
sudo mkdir /etc/frp
# 创建frps.ini文件
nano /etc/frp/frps.ini
1
2
3
4

frps.ini内容如下:

[common]
# 监听端口
bind_port = 7000
# 面板端口
dashboard_port = 7500
# 登录面板账号设置
dashboard_user = admin
dashboard_pwd = admin
# 设置http及https协议下代理端口(非重要)
vhost_http_port = 7080
vhost_https_port = 7081

# 身份验证
token = 1234567890abcdefg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#服务器镜像:snowdreamtech/frps
#重启:always
#网络模式:host
#文件映射:/www/frp/frps.ini:/etc/frp/frps.ini

docker run --restart=always --network host -d -v /www/frp/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps
1
2
3
4
5
6

开放7500端口,开放frpc服务端口

# 客户端配置(FRPC)

服务器镜像:snowdreamtech/frpc
重启:always
网络模式:host
文件映射:/路径/frp/:/etc/frp/
1
2
3
4

配置文件示例:

[common]
# server_addr为FRPS服务器IP地址
server_addr = x.x.x.x
# server_port为服务端监听端口,bind_port
server_port = 7000
# 身份验证
token = 1234567890abcdefg

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 2288

# [ssh] 为服务名称,下方此处设置为,访问frp服务段的2288端口时,等同于通过中转服务器访问127.0.0.1的22端口。
# type 为连接的类型,此处为tcp
# local_ip 为中转客户端实际访问的IP 
# local_port 为目标端口
# remote_port 为远程端口

[nginx]
type = tcp
local_ip = 127.0.0.1
local_port = 80
remote_port = 6000

[unRAID web]
type = tcp
local_ip = 192.168.1.229
local_port = 80
remote_port = 18088

[Truenas web]
type = tcp
local_ip = 192.168.1.235
local_port = 80
remote_port = 18188

[speedtest]
type = tcp
local_ip = 192.168.1.229
local_port = 6580
remote_port = 18190


[webdav]
type = tcp
local_ip = 192.168.1.235
local_port = 18080
remote_port = 18189

[RDP PC1]
type = tcp
local_ip = 192.168.1.235
local_port = 3389
remote_port = 18389
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$ docker run --restart=always --network host -d -v /www/frp/frpc.ini:/etc/frp/frpc.ini --name frpc snowdreamtech/frpc
1
  • 如果监听服务可以有IP限制的设置,需要允许的访问IP为中转内网设备的内网IP;
  • FRP由于端口会暴露在互联网上,虽然说使用方便但安全性较差;

# ZeroTier Moon

# 服务端

# 创建(伪)根服务器

| 项目地址:https://github.com/Jonnyan404/zerotier-planet (opens new window)

$ docker run --restart=on-failure:3 -d --name ztncui -e HTTP_PORT=4000 -e HTTP_ALL_INTERFACES=yes -e ZTNCUI_PASSWD=mrdoc.fun -p 4000:4000 keynetworks/ztncui
# 开放4000端口,登录用户密码admin/mrdoc.fun
# 登录后会提示修改密码length>=10
Add network
easy setup

1
2
3
4
5
6

# 创建 moon 服务器

| 项目地址:https://github.com/jonnyan404/docker-zerotier-moon (opens new window)

# 与ztncui在一个服务器
#创建容器
$ docker run --name zerotier-moon -d -p 9993:9993 -p 9993:9993/udp -v /etc/ztconf/:/var/lib/zerotier-one jonnyan404/zerotier-moon -4 [公网ipx.x.x.x]

#查看moon ID
$ docker logs zerotier-moon

[root@frpc ~]$ docker logs zerotier-moon
IPv4 address: 192.168.211.132
Your ZeroTier moon id is 4973b98bea, you could orbit moon using "zerotier-cli orbit 4973b98bea 4973b98bea"

$ docker exec zerotier-moon zerotier-cli orbit 4973b98bea 4973b98bea
1
2
3
4
5
6
7
8
9
10
11
12

# 客户端

https://www.zerotier.com/download/#downloadLinux

curl -s https://install.zerotier.com | sudo bash # 安装zerotier

#查看zerotier状态
zerotier-cli status

zerotier-cli join [xxxxxxxxxxxx] # network ID
zerotier-cli orbit [moon_ID] [moon_ID]

zerotier-cli listpeers 


yum remove zerotier-one
1
2
3
4
5
6
7
8
9
10
11
12
docker run -d --name zt --restart=always --cap-add NET_ADMIN -v /var/lib/zerotier-one:/var/lib/zerotier-one --network host zerotier/zerotier

# -v /var/lib/zerotier-one:/var/lib/zerotier-one
 
docker exec -it zt zerotier-cli status
 
 docker exec -it zt zerotier-cli join 111771bb9a4b92c4
 docker exec zt zerotier-cli orbit 51b8853c05 51b8853c05
 
 docker exec zt zerotier-cli listpeers 
1
2
3
4
5
6
7
8
9
10

# 群晖 DSM 7.x 安装Zerotier客户端

# 登录SSH并创建虚拟网络设备TUN

#获取权限
sudo -i

#创建“创建虚拟网络设备TUN”的脚本,并设为开机自动运行
echo -e '#!/bin/sh -e \ninsmod /lib/modules/tun.ko' > /usr/local/etc/rc.d/tun.sh

#给予脚本运行权限
chmod a+x /usr/local/etc/rc.d/tun.sh

#运行脚本创建TUN
/usr/local/etc/rc.d/tun.sh

#确认TUN是否创建成功
ls /dev/net/tun
1
2
3
4
5
6
7
8
9
10
11
12
13
14

创建存放配置文件的目录

mkdir /var/lib/zerotier-one
1

创建Zerotier应用容器:

docker run -d           \
  --name zt             \
  --restart=always      \
  --device=/dev/net/tun \
  --net=host            \
  --cap-add=NET_ADMIN   \
  --cap-add=SYS_ADMIN   \
  -v /var/lib/zerotier-one:/var/lib/zerotier-one zerotier/zerotier-synology:latest
1
2
3
4
5
6
7
8

常用命令:

#查看zerotier状态
docker exec -it zt zerotier-cli status

#加入网络
docker exec -it zt zerotier-cli join [xxxxxxxxxxxx]
#加入moon服务器
docker exec zt zerotier-cli orbit [moon_ID] [moon_ID]
#确认是否加入
docker exec zt zerotier-cli listpeers 
1
2
3
4
5
6
7
8
9

# Windows 客户端

cd C:\ProgramData\ZeroTier\One
zerotier-cli orbit [moon_id] [moon_id]
1
2