Frp intranet penetration installation configuration and use

Post the document first (it seems to be online scientifically)
Github project address

View system architecture

A server is needed as a server for port forwarding. After connecting to the server, enter the following command to view the system

uname -a

Insert image description here

Pull package

Enter the following command to download the frp package, change the first command according to the version number, and change the pulled file type according to the system. Mine is 0.49.0. The above system shows that I am a Linux system arm64 architecture, so the command is as follows

# 设置变量FRP版本号
export FRP_VERSION=0.49.0
# 创建/etc/frp文件夹
sudo mkdir -p /etc/frp
# 打开/etc/frp文件夹
cd /etc/frp
# 下载符合要求的程序包,按需更改系统和架构
sudo wget "https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_arm64.tar.gz"
# 解压程序包
sudo tar xzvf frp_${FRP_VERSION}_linux_arm64.tar.gz
# 将解压出来的文件夹内的文件全部移动到/etc/frp文件夹
sudo mv frp_${FRP_VERSION}_linux_arm64/* /etc/frp

Insert image description here

After frp is decompressed, there are two ends, namely the server (frps) and the client (frpc), as well as their configuration files frps.ini and frpc.ini
Insert image description here

frps.ini in the server configuration directory

frps.ini configures transfer port and dashboard information, the following is a configuration example

[common]
# 服务端绑定的端口
bind_port = 7000
# 仪表盘绑定的端口
dashboard_port = 7500
# 客户端与服务端连接时配置的token
token = 123456789
# 仪表盘用户名
dashboard_user = admin
# 仪表盘密码
dashboard_pwd = 123456
# 设置监听 HTTP 请求端口
vhost_http_port = 7080

Insert image description here

The command to start the service directly

./frps -c ./frps.ini

Insert image description here

Release port 7500, you can see that you can already access the dashboard
Insert image description here

Use systemctl to configure background operation and boot self-start

sudo vim /lib/systemd/system/frps.service

Write the following in frps.service

[Unit]
# 服务描述:frps服务
Description=frps service
# 在network.target和syslog.target之后启动
After=network.target syslog.target
# 需要network.target服务
Wants=network.target

[Service]
# 服务类型为简单类型
Type=simple
# 执行启动frps服务的命令,并指定配置文件路径为/etc/frp/frps.ini
ExecStart=/etc/frp/frps -c /etc/frp/frps.ini

[Install]
# 安装为多用户目标所需
WantedBy=multi-user.target

Insert image description here

Use systemctl to start frps

sudo systemctl start frps

Turn on autostart

sudo systemctl enable frps

other

如果要重启应用,sudo systemctl restart frps
如果要停止应用,sudo systemctl stop frps
如果要查看应用的日志,sudo systemctl status frps

If port 7000 is occupied at startup

#查看端口号
netstat -anp|grep 7000

#查看端口号
lsof -i:7000

#查看程序进程
ps -ef|grep frps
得到进程id(pid)之后,使用下面命令杀掉进程

kill pid

frpc.ini in the client configuration directory

frpc.ini configures the information that needs to be penetrated, the following is a configuration example

[common]
# frp服务端ip
server_addr = frp服务端ip
# frp服务端绑定的端口
server_port = 7000
# frp服务端配置的token
token = 123456789

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 7022

Insert image description here

If the server is a foreign server, you need to attach a proxy to connect, otherwise it will report. i/o deadline reached
You need to add a proxy in the common of the client's configuration file.

protocol = tcp
http_proxy = http://user:pwd@代理ip:端口

Start directly with the following command

./frpc -c ./frpc.ini

Insert image description here

In the example above, the client configures ssh penetration, and the server opens the 7022 firewall port. The test uses the intranet penetration connection, and the connection can be normal
Insert image description here

Use systemctl to configure background operation and boot self-start

sudo vim /lib/systemd/system/frpc.service

Write the following content in frpc.service

[Unit]
# 服务单元:frpc service
Description=frpc service
# 在network.target和syslog.target之后启动
After=network.target syslog.target
# 需要network.target服务
Wants=network.target

[Service]
# 服务类型:简单
Type=simple
# 启动超时时间:10秒
TimeoutStartSec=10
# 重启延迟时间:30秒
RestartSec=30s
# 总是自动重启
Restart=always
# 执行启动frpc服务的命令,并指定配置文件路径为/etc/frp/frpc.ini
ExecStart=/etc/frp/frpc -c /etc/frp/frpc.ini

[Install]
# 安装为多用户目标所需
WantedBy=multi-user.target

Insert image description here

Start frpc with systemctl

sudo systemctl start frpc

Turn on autostart

sudo systemctl enable frpc

other

如果要重启应用,sudo systemctl restart frpc
如果要停止应用,sudo systemctl stop frpc
如果要查看应用的日志,sudo systemctl status frpc

Guess you like

Origin blog.csdn.net/sywdebug/article/details/132763528