前言
现在越来越多的家宽没有公网IP
不要说固定的IP
甚至有一家连动态IP都不给
那我们现在还想远程连回家
那我们就试试用Frp吧
原理拓扑
借用大佬的拓扑图
我们可以看到
我们游戏服务器和朋友的主机
都位于各自运营商的大内网中
现在我们借助一台VPS做中转
只要我们都能访问到那台VPS
我们就可以一起愉快的玩游戏
Frp 文件下载
Frp 源码
1
| https://github.com/fatedier/frp
|
Windows 下载
直接下载就好
咁都唔识,小儿麻痹咩你~
下载完就解压啦
Linux 下载
- 按照
最新版本号更改下载链接
1
| wget https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_amd64.tar.gz
|
- 解压下载好的安装包
1
| tar -zxvf frp_0.51.3_linux_amd64.tar.gz
|
删除无用配置
Frp Server 配置
1 2
| sudo rm -f frpc* sudo rm -f systemd/frpc*
|
Frp Client 配置
1 2
| sudo rm -f frps* sudo rm -f systemd/frps*
|
Frp Server 配置
修改 Frp Server 配置
frps.ini 参考配置
可以参考进行修改
1 2 3 4 5 6 7 8 9 10 11
| [common]
bind_port = 7000
dashboard_port = 7500
dashboard_user = xxx
dashboard_pwd = xxx
token = xxx
|
保持后台运行
1 2 3 4
| screen -S frp
./frps -c ./frps.ini
|
Screen 命令简介
1 2 3 4 5 6 7 8 9 10 11 12
| screen -S [xxx]
Ctrl + A + D
screen -r [xxx]
screen -D -r xxx
screen -list
screen -S [xxx] -X quit
|
注册系统服务
1
| sudo vim /etc/systemd/system/frps.service
|
修改 Frp Server 服务文件
1 2 3 4 5 6 7 8 9 10 11 12 13
| [Unit] Description=Frp Server Daemon After=network.target
[Service] Type=simple Restart=on-failure RestartSec=5s
ExecStart=/home/ecs-user/frp/frps -c /home/ecs-user/frp/frps.ini
[Install] WantedBy=multi-user.target
|
Frp 系统命令
1 2 3 4 5 6 7 8
| sudo systemctl start frps.service
sudo systemctl status frps.service
sudo systemctl stop frps.service
sudo systemctl enable frps.service
|
Frp Server 开放端口
例如我就是开启了7000和7500端口
服务端搭建成功
系统服务
Frp 管理后台
Frp Client 配置
修改 Frp Client 配置
修改 frpc.ini
frps.ini 参考配置
可以参考进行修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| [common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
token = xxx
autostart = true
[xxx]
type = tcp
local_ip = 127.0.0.1
local_port = xxx.xxx.xxx.xxx
remote_port = xxx.xxx.xxx.xxx
|
客户端示例配置
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
| [SSH] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 22
[RDP] type = tcp local_ip = 127.0.0.1 local_port = 3389 remote_port = 3389
[MC] type = tcp local_ip = 127.0.0.1 local_port = 25565 remote_port = 25565
[MCBE] type = tcp local_ip = 127.0.0.1 local_port = 19132 remote_port = 19132
[TR] type = tcp local_ip = 127.0.0.1 local_port = 7777 remote_port = 7777
|
开启 Frp Client 服务
Frp Client 开机自启
Win + R 打开 taskschd.msc
- 创建基本任务
- 选择
计算机启动时
- 选择
启动程序
- 配置自动执行脚本
- 完成配置
- 不管用户是否登录都要运行
Frp Client 开放端口
本地网关路由器
例如我就是开启了3389端口
云主机 VPS
所以云主机还要开启3389端口
Frp 连接成功
参考 & 引用
https://www.zouht.com/727.html
https://learnku.com/articles/45769
https://cloud.tencent.com/developer/article/1700417
https://wp.gxnas.com/12153.html