Detailed installation and usage tutorial for fatedier/frp intranet penetration

"Reference Address"
fatedier/frp is an open source intranet penetration tool developed mainly using Go language. Mainly divided into server (frps) and client (frpc).
Simple understanding: the server (frps) is deployed to the public network IP server to be called by the client (frpc). The server (frps) can be understood as the registration and service discovery center in our microservices, namely: Eureka, Nacos, ZooKeeper. The client (frpc) is the SpringBoot project or other projects that we need to register with the Registration and Service Discovery Center.
Function: Call our intranet projects, remote desktop, proxy server through the public network IP: PORT, store data to the local server through the proxy server, etc.
Conditions: A cloud server with a public IP is required.

The following commands are executed by the root user by default. If you are not the root user, please add sudo before executing the command.

Official website address

"fatedier/frp GitHub official website address"

Public network server installation server (frps)

"Download the compressed package corresponding to the operating system"
For example: centos76-bit operating system, then download: frp_0.51.3_linux_amd64.tar.gz.
If you are not sure how many bits the operating system is, use the following command to check

uname -a

Linux VM-8-4-centos 3.10.0.1.el7.x64 #1 SMP Tue Tue 7 15:41:52 UTC 2023 x64 GNU/Linux

Insert image description here

Linux server downloads directly through wget command

If the download speed of the Linux server is slow, you can also download it locally first and upload it to the Linux server through files.
Order

wget [URL] -P [路径]

Create /data/download and download the file to the directory

mkdir -p /data/download
wget https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_amd64.tar.gz -P /data/download

Unzip

Order

tar -xvf 文件名.tar -C 目标路径

Unzip it to the data directory and rename it to frp

tar -zxvf /data/download/frp_0.51.3_linux_amd64.tar.gz -C /data/
mv /data/download/frp_0.51.3_linux_amd64 /data/frp
cd /data/frp/ && ll

Only keep the following files, others can be deleted.
Insert image description here

Modify frps configuration file

vi /data/frp/frps.ini
[common]
# frp监听的端口,默认是7000(无特殊要求可以不改,这个必须开放对应端口。云服务器一般在对应的云控制台开放端口,默认的Linux服务器的防火墙是关闭的,如果有防火墙,那么防火墙也要开放相应的端口。)
bind_port = 7000
# 临时凭证,越复杂越好。推荐使用2个去除-的UUID。
token = UUID

# frp管理后台端口,默认7500(无特殊要求可以不改,这个可以不用开放端口。)
dashboard_port = 7500
# frp管理后台用户名和密码
dashboard_user = admin
dashboard_pwd = admin
enable_prometheus = true

# frp日志配置
log_file = /var/log/frps.log
# 日志级别
log_level = error
# 日志保存天数
log_max_days = 2

start frps

Because frps does not use a background startup command, we write one ourselves.

vi /lib/systemd/system/frps.service
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
#ExecStartf分别对应frps的安装路径和配置文件路径
ExecStart=/data/frp/frps -c /data/frp/frps.ini

[Install]
WantedBy=multi-user.target

Start and set up startup

systemctl start frps && systemctl enable frps

stop

systemctl stop frps

Restart

systemctl restart frps

Check if startup is successful

systemctl status frps

Insert image description here

If you cannot connect to the server, please check whether the firewall is turned on.

Window installation client (frpc)

Just download the Windows compressed package in the previous picture.
For example: Windows 10 64-bit operating system, download: frp_0.51.3_windows_amd64.zip and decompress it. If the download speed is slow, you can use third-party download tools, such as Thunder, IDM, etc.

Unzip

Unzip it to D:/software/frp or other location. Keep frpc related files and delete frps related files.
Insert image description here

Modify frpc configuration file

[common]
# 公网IP地址
server_addr = x.x.x.x
# 默认是7000
server_port = 7000
# 临时凭证(必须跟上面frps服务端token一致)
token = UUID

#自定义客户端服务别名
[springboot]
# 请求类型
type = tcp
#本地ip地址
local_ip = 127.0.0.1
#本地映射端口号
local_port = 8081
#服务端映射端口号(这里只是演示,所以用80,而且80也是默认是开放的。)
remote_port = 80

start frpc

Create a new frpc.bat startup script in the frp directory
Insert image description here

@echo off
REM 延迟30秒启动,防止网络驱动没有启动好导致启动失败。
ping 127.1 -n 10 > nul
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
REM 进入到frp目录下,启动frpc并指定配置文件
cd D:/software/frp
frpc -c frpc.ini
exit

Double-click frpc.bat to start the client frpc, then open the task manager to view the user's corresponding application list to see if there is frpc.exe
Insert image description here

Set up the startup client frpc

WIN + R input

shell:startup

Copy the frpc.bat file shortcut file to the Start Menu\Programs\Startup directory (note: copy the shortcut, do not copy the source file! Otherwise it may not start!)
Insert image description here

Access a locally started SpringBoot project with Port 8081 through the public IP: proxy port

Insert image description here
Insert image description here
Browser access: public IP:port/hi
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_43933728/article/details/132783275