Skip to content

Install FRP

本文发布时的最新frp版本为v0.36.2,服务器以x64架构为例,客户端以arm架构为例

Config on Server

1. Download FRP

fatedier/frprelease页面下载相应平台最新的预编译程序包。

在服务器的任意位置下载并解压

wget https://github.com/fatedier/frp/releases/download/v0.36.2/frp_0.36.2_linux_amd64.tar.gz
tar -zxvf frp*.tar.gz 

2. Install FRPS

cd frp*
mv frps /usr/bin/frps
mkdir /etc/frp
mv frps.ini /etc/frp/frps.ini

From Step2 to Step4 need ROOT authority, you need add sudo before each command if NOT a ROOT user.

3a. Configuration of FRPS(befor version 0.52.0)

编辑frp的config文件vim /etc/frps.ini,按照如下的格式填写

[common]
bind_port = [your_port1]
token =  [your_token]
vhost_http_port = [your_port2]
bing_udp_port = [your_port3]
vhost_https_port = [your_port4]

dashboard_port = [your_port5]
dashboard_user = [User_name]
dashboard_pwd = [your_Password]

[common]之下的bind_porttoken为必须项,其他均为可选项

在较新的版本中,bind_portvhost_http_portvhost_https_port可以设置为同一端口

3b. Configuration of FRPS(newer then 0.52.0)

编辑frp的config文件vim /etc/frps.toml,按照如下的格式填写

bindAddr = "0.0.0.0"
bindPort = [bind_port]
transport.tcpMux = true
transport.tls.force = false
vhostHTTPPort = [http_port]
vhostHTTPSPort = [https_port]

webServer.addr = "127.0.0.1"
webServer.port = [web_port]
webServer.user = "web_user_name"
webServer.password = "web_user_password"

auth.method = "token"
auth.token = "auth_token"

4. Register Service and Start On boot

mv systemd/frps.service /etc/systemd/system/frps.service
systemctl daemon-reload
systemctl start frps
systemctl enable frps

Config on Client

客户端的安装方式与服务器安装方式完全一致,仅在配置文件上有所不同,因此只对与服务器安装不同之处做出说明。

1. Download FRP for Client

wget https://github.com/fatedier/frp/releases/download/v0.34.0/frp_0.34.0_linux_arm.tar.gz

2. Replace all frps with frpc

3a. Configuration of FRPC(before 0.52.0)

编辑frp的config文件vim /etc/frpc.ini,按照如下的格式填写

[common]
server_addr = [your_ip]
server_port = [your_port]
token = [your_token]

[Service]
type = [tcp,http,https...]
local_ip = 127.0.0.1
local_port = [your_local_service_port]
remote_port = [your_remote_service_port]

  • server_addr填写FRPS的ipv4地址
  • server_port为服务器的bind_port对应的端口
  • token为服务器对应的token

3b. Configuration of FRPC(newer then 0.52.0)

编辑frp的config文件vim /etc/frpc.toml,按照如下的格式填写

user = "user_name"
serverAddr = "srv_ip"
serverPort = [srv_bind_port]
loginFailExit = false

auth.method = "token"
auth.token = "auth_token"

transport.dialServerTimeout = 10
transport.tcpMux = true
transport.protocol = "tcp"
transport.connectServerLocalIP = "0.0.0.0"

transport.tls.enable = false

[[proxies]]
name = "proxy_name"
type = "tcp/http/https..."
localIP = "127.0.0.1"
localPort = [local_port]

Config HTTP Connection for Client

1. 在域名网站设置好域名解析

  • 将某个自定义域名的A/AAAA记录解析到FRP服务器的公网IP地址

2. 添加客户端设置

[SERVICE_NAME]
type = http
local_ip = 127.0.0.1
local_port = 0000
custom_domains = CUSTOM_DOMAIN.com
- CUSTOM_DOMAIN填入上一步设置好的域名

One More Thing

FRP一键安装脚本 - linux平台,amd64架构 - 默认服务端口7000, - dashboard用户名、密码均为admin - Token 为随机

! Onekey script only working for version 0.36.2

1. 下载一键安装脚本

wget https://gitlab.dashdreams.com/Haoran.Qi/RaspberryPi/-/raw/main/Shell/FRP_OneKey/install_frp.sh

2. 运行脚本

./install_frp.sh

ROOT authority needed, add sudo before each command if NOT a ROOT user.

REF

[1]. https://github.com/fatedier/frp