命令
systemctl enable frps.service # 设置开机启动
systemctl disable frps.service # 取消开机启动
systemctl daemon-reload # 重载配置
systemctl start frps # 启动 frps 服务
systemctl restart frps # 重启 frps 服务
systemctl stop frps # 停止 frps 服务
systemctl status frps # 查看 frps 服务状态
systemctl cat frps # 查看 frps 服务配置
[!tip] 原理
客户端 -> 服务端 -< 客户端
一 服务器开放端口
- TCP:
7000
frps 服务/7500
管理后台/7400
被访问客户端管理后台 /6000
被访问客户端ssh - UDP:
7001
p2p
二 下载frp
https://github.com/fatedier/frp/releases
- 云服务器:
frp_x.x.x_linux_amd64.tar.gz
三 配置文件
修改服务端与客户端配置
# frps.ini
[common]
bind_port = 7000
bind_udp_port = 7001
# 超时时间
authentication_timeout = 0
# 加密方式
authentication_method = token
# token
token = yanan155**
# frp服务端后台
dashboard_port = 7500
dashboard_user = yanan
dashboard_pwd = frps28**
# 日志
log_file = /www/server/frp/frps.log
# 日志级别
log_level = info
# 日志留存3天
log_max_days = 3
四 配置服务
临时启动: 断开ssh后自动关闭
cd /www/server/frp ./frps -c frps.ini
新建frps.service
文件并写入以下内容
[Unit]
Description=Frp Server Service
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
ExecStart=/www/server/frp/frps -c /www/server/frp/frps.ini
[Install]
WantedBy=multi-user.target
cp /www/server/frp/frps.service /lib/systemd/system/frps.service
五 设置服务开机启动
- 宝塔系统启动项 ->服务中添加
frps.service
六 参数
# tcp: 普通 tcp 模式
# udp: 普通 udp 模式
# stcp: 加密tcp模式
# [访问客户端安装frp,指定sk 验证码/role访问者/server_name服务名,remote_port无效]
# xtcp: p2p连接模式
# [访问客户端安装frp,指定sk 验证码/role访问者/server_name服务名,remote_port无效]