1 准备工作
- linux系统
- frp 0.48版本,下载链接
- 1台具有公网IP访问的服务器
- 2台内网服务器
2 公网服务器部署server端
- 目录 /opt/frp

2.1 frps.ini配置
[common]
bind_port = 7070
dashboard_port = 7550
dashboard_user = admin
dashboard_pwd = admin
3 内网客户端部署client端
- 目录 /opt/frp
- 同一个frp压缩包解压后的东西,与server端一样

3.1 frpc.ini配置(内网服务器01)
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7070
[服务器01]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 21001
[web01]
type = tcp
local_ip = 127.0.0.1
local_port = 7777
remote_port = 27777
3.2 frpc.ini配置(内网服务器02)
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7070
[服务器01]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 21002
4 服务启动脚本
- 为了让 FRP 服务端和客户端在系统重启后自动启动,可以将其配置为系统服务。
4.1 公网服务器 server
sudo nano /etc/systemd/system/frps.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /opt/frp/frps -c /opt/frps.ini
Restart=always
RestartSec=5
StartLimitInterval=0
[Install]
WantedBy = multi-user.target
sudo systemctl enable frps
sudo systemctl start frps
4.2 内网服务器 client
sudo nano /etc/systemd/system/frpc.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /opt/frp/frpc -c /opt/frpc.ini
Restart=always
RestartSec=5
StartLimitInterval=0
[Install]
WantedBy = multi-user.target
sudo systemctl enable frpc
sudo systemctl start frpc
2 systemctl常见命令
sudo systemctl daemon-reload
sudo systemctl start frpc
sudo systemctl enable frpc
sudo systemctl stop frpc
sudo systemctl restart frpc
sudo systemctl status frpc
sudo journalctl -u frpc
3 FRP监控页面查看
