FRP GitHub 地址:https://github.com/fatedier/frp

FRP 中文说明文档:参考

准备一台具有公网IP的系统作为 FRP 服务器,我这里使用阿里云的 ECS,系统 Ubuntu 16.04 x64。

远程 Ubuntu,进入到适当的目录

cd /usr/share/frp

下载二进制文件

wget https://github.com/fatedier/frp/releases/download/v0.24.1/frp_0.24.1_linux_amd64.tar.gz

解压,重命名

tar -xf frp_0.24.1_linux_amd64.tar.gz
mv frp_0.24.1_linux_amd64 bin

编辑默认的FRP服务配置文件

cd bin
vi frps.ini

我的配置大致如下,各项配置意思可以去官网参考

bind_port = 7000
allow_ports=20,21,80,443,1080,8000-9000,3306,1433,1414,23,1521,5432,6379,3000-4000,20000-21000
dashboard_addr = 0.0.0.0
dashboard_port = 7001
#token = 密码
dashboard_user = admin
#dashboard_pwd = 密码
log_file=./frps.log
log_level=info
kcp_bind_port = 7000

启动 FRP 服务端

./frps -c frps.ini 

添加服务端后台运行,开机启动

vi /etc/rc.local

写入,路径根据自己设置的来

nohup /usr/share/frp/frps/frps -c /usr/share/frp/frps/frps.ini &

接下来是客户端

客户端我使用的是 Windows Server 2016,

下载适用于Windows 的二进制文件,参照 Github 文档说明进行配置,运行 frpc 即可。

后台启动

@echo off 
 if "%1" == "h" goto begin 
 mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
 :begin 
   "路径\frpc.exe" -c "路径\frpc.ini"

FTP协议有些特殊,FRP 无法对其实现较好的支持,并且作者没有计划对此进行支持,参考:#219

在搭建 FTP 服务器时,需要额外设置被动模式端口,并将这些端口也添加到映射中去。例如:FileZilla Server 便在 Passive mode setting 中设置 use custom port range。