一、 前提
有一臺遠程服務器,然后用Win的遠程桌面連接到公司內網電腦中
二、環境
- 公網服務器1臺,CentOS 7
- 內網客戶端1臺,Win10
三、服務器安裝frp
- 下載地址https://github.com/fatedier/frp/releases下載linux版本
wget https://github.com/fatedier/frp/releases/download/v0.31.1/frp_0.31.1_linux_amd64.tar.gz
- 解壓到/usr/local/frp目錄
tar zxf frp_0.31.1_linux_amd64.tar.gz
mv frp_0.31.1_linux_amd64 /usr/local/frp
- 配置服務端frps.ini
vim frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080
- 啟動
./frps -c ./frps.ini
四、客戶端配置
- 下載地址https://github.com/fatedier/frp/releases下載win版本
- 解壓到C:\Program Files\frp目錄
- 配置frpc.ini
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
[RDP]
type = tcp
local_ip = 0.0.0.0
local_port = 3389
remote_port = 6666
- 在命令行中啟動frp客戶端
C:\Program Files\frp\frpc.exe -c C:\Program Files\frp\frpc.ini
等待啟動完成
2020/01/11 13:18:22 [I] [service.go:250] [e126185cb2716a8e] login to server success, get run id [e126185cb2716a8e], server udp port [0]
2020/01/11 13:18:22 [I] [proxy_manager.go:144] [e126185cb2716a8e] proxy added: [RDP]
2020/01/11 13:18:22 [I] [control.go:164] [e126185cb2716a8e] [RDP] start proxy success
-
連接測試
五、 配置服務開機啟動
- linux下配置服務
vim /etc/systemd/system/frps.service
[Unit]
Description=frps daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/frp/frps -c /usr//local/frp/frps.ini
Restart= always
RestartSec=1min
[Install]
WantedBy=multi-user.target
啟動frps
systemctl start frps
- win下配置服務
借助 winsw 工具可以將frpc注冊為windows系統中的服務
將下載的winsw.exe放到frpc.exe同目錄下,并填寫winsw.xml配置文件
<service>
<id>frp</id>
<name>frp</name>
<description>用frp發布本地電腦網站到外網</description>
<executable>frpc</executable>
<arguments>-c frpc.ini</arguments>
<logmode>reset</logmode>
</service>
然后使用winsw install將frpc安裝為系統服務。
win+r后通過services.msc進入到服務列表頁面找到frp服務。
為了確保frpc在連接失敗后自動嘗試重新連接,在恢復tap頁進行如下設置
六、 擴展配置
frpc的web、ssh配置
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
[ssh]
type = tcp
local_ip = 0.0.0.0
local_port = 22
remote_port = 2222
[web]
type = http
local_port = 80
custom_domains = js.zengwu.com.cn