目錄 1 準備工作 2 公網服務器部署server端 3 內網客戶端部署client端 3.1 frpc.ini配置(內網服務器01) 3.2 frpc.ini配置(內網服務器02) 4 服務啟動腳本 4.1 公網服務器 server 4.2 內網服務器 client 2 systemctl常見命令 3 FRP監控頁面查看
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監控頁面查看