frp setup and usage tutorial

Background:
In the current complex environment for various reasons, it is inconvenient to access internal devices at home outside, and I want to find a solution - frp
Insert image description here

FRP is an open source, high-performance reverse proxy software, its full name is Fast Reverse Proxy. It is mainly used to expose an intranet service to the public network so that external network users can access the service. FRP is easy to use and supports multiple protocols, including TCP, UDP, HTTP, HTTPS, etc.

1. Preparation

An external network server (or a machine with a public IP address such as a Tencent server);
Tencent coupons

One intranet server (win7/10 computer);

2. Download files

Download address:GitHub address
Insert image description here
About arm/amd version:
Linux system can be confirmed by the following command

~ arch
# 查看当前系统是amd/arm
x86_64
# 返回x86_64就是amd架构的。
~ getconf LONG_BIT
64
# 返回64就是64位的

Insert image description here
I confirm here that it is the AMD64 bit version

Linux 0.51.2 version download location:
https://github.com/fatedier/frp/releases/download/v0.51.2/frp_0.51.2_linux_amd64.tar.gz

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

Window 0.51.2 version download address:
https://github.com/fatedier/frp/releases/download/v0.51.2/frp_0.51.2_darwin_amd64.tar.gz

Note that the client and server versions must be consistent as much as possible

Unzip

[~] tar -zxvf frp_0.51.2_linux_amd64.tar.gz 
frp_0.51.2_linux_amd64/
frp_0.51.2_linux_amd64/frpc.ini
frp_0.51.2_linux_amd64/frpc_full.ini
frp_0.51.2_linux_amd64/frps_full.ini
frp_0.51.2_linux_amd64/frps.ini
frp_0.51.2_linux_amd64/LICENSE
frp_0.51.2_linux_amd64/frpc
frp_0.51.2_linux_amd64/frps
# 改个名称方便后面操作
[~] mv frp_0.51.2_linux_amd64 frp_0.51.2

3. Configure the server (linux)

# 进入目录
[~] cd frp_0.51.2
# 展开列表
ll
[~ frp_0.51.2] ll
总用量 30768
-rwxr-xr-x 1 www docker 14278656 725 21:39 frpc
-rw-r--r-- 1 www docker    12669 725 21:44 frpc_full.ini
-rw-r--r-- 1 www docker      126 725 21:44 frpc.ini
-rwxr-xr-x 1 www docker 17182720 725 21:39 frps
-rw-r--r-- 1 www docker     5933 725 21:44 frps_full.ini
-rw-r--r-- 1 www docker       28 727 11:31 frps.ini
-rw-r--r-- 1 www docker    11358 725 21:44 LICENSE

# 注意frpc是客户端,如果用不到,相关的都可以删除
# frps是服务端,我用当前主机当服务端,所以需要修改frps.ini
vim frps.ini

The default port is 7000. For security, change it to15000 (note that this port needs to be opened in Linux and cloud server firewall)
In fact, there is also a default port 7500 for the web management terminal, which also needs to be opened
Insert image description here

4. Open the panel

Convenient for later monitoring status

vim frps.ini

[common]
bind_port = 15000

# 远程访问监控面板的端口
dashboard_port = 7501

# dashboard user and passwd for basic auth protect
dashboard_user = admin
dashboard_pwd = admin

# dashboard TLS mode
dashboard_tls_mode = false
# dashboard_tls_cert_file = server.crt
# dashboard_tls_key_file = server.key

# enable_prometheus will export prometheus metrics on {dashboard_addr}:{dashboard_port} in /metrics api.
enable_prometheus = true

Insert image description here

The server is basically ready

You can directly run the following command to start
./frps -c ./frps.ini
But in order to start automatically later, usesystemctl

5. Use systemctl to control frps

If it is not installed on the Linux serversystemd, you can use the commands yum or apt to install it systemd.

#  yum
yum install systemd
# apt
apt install systemd
  1. Enter the systemctl directory and createfrps.service
cd /etc/systemd/system/
vim frps.service
# 或者直接
vim /etc/systemd/system/frps.service

  1. Copy the following code into the file(frps.service)
[Unit]
# 服务名称,可自定义
Description = frp server
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /root/frp_0.51.2/frps -c /root/frp_0.51.2/frps.ini

[Install]
WantedBy = multi-user.target
  1. Saikansystemd Command
systemctl start frps       #启动frps
systemctl restart frps     #重启frps
systemctl stop frps        #停止frps
systemctl status frps   # 查看运行日志
  1. ConfigurationfrpsStartup
systemctl enable frps      #服务器开机自动启动frps

6. Configure the client

The client downloads directly. Indeed, the client and server are the same, but the files called are different. One is frpc/frps:
Window 0.51.2Version download address:
https://github.com/fatedier/frp/releases/download/v0.51.2/frp_0.51.2_windows_amd64.zip

注意电脑的杀毒软件可能会删除它
Insert image description here

  • Client decompression, note that only frpc will be used, others can be deleted
    Insert image description here

  • I wrote a scriptstartup.bat for convenience.
    Insert image description here

  • Openfrpc.ini and perform related configurations

Here are the parameters:
[ssh] In fact, it can be named arbitrarily, and multiple can be configured at the same time
local_ip needs to be mapped To the host on the external network
The local_port port is the host port that needs to be mapped to the external network
The remote_port is when accessed from the external network
The above configuration finally turns external network access192.168.1.123:22 into external network access
124.xxx.xxx.xxx:6000 (Tencent Cloud server public network IP)

Insert image description here

  • Client startup
    If you see success in the picture, it means it has started successfully.
    If you see success in the above picture, it means it has started successfully

Finally, you can access the server console to check the link status
http://124.xxx.xx.xx:7501
The account password can be viewed in the above configuration
Insert image description here

Guess you like

Origin blog.csdn.net/m0_37680500/article/details/131952918