Alibaba Cloud Server builds FRP to achieve intranet penetration-P2P

Preface

  • Before understanding frp-p2p, please first understand how Alibaba Cloud Server builds FRP to achieve intranet penetration - forwarding: article address

1. What is frp-p2p

   frp (Fast Reverse Proxy) is an open source reverse proxy tool that provides a variety of functions, including port mapping, traffic forwarding, and intranet penetration. In frp, the P2P (Peer-to-Peer) function allows data to be transferred directly from one client to another without going through a server.

2. Demonstration environment

Insert image description here

1. File configuration of each terminal

1. Alibaba Cloud frps server configuration

fps.ini

# 配置项的分类,通常使用 [common] 表示
[common]
# 指定frps服务端绑定的网口IP地址。如有网口1和网口2,一般使用 0.0.0.0 表示绑定所有可用的网络接口
bind_addr = 0.0.0.0
# 指定frps服务端监听的端口号(该端口需要防火墙或安全组放行),用于接收来自外部客户端的连接,可修改
bind_port = 7000

# 用于验证客户端连接的令牌。客户端需要使用相同的令牌来与服务端建立连接,可修改
token = your_token

# 其余配置可自行增加

Start command: ./frps -c frps.ini

2. frpc client configuration on computer B

frpc.ini

[common]
# 自己的frps服务器,阿里云服务器绑定的域名(国内服务器绑定的域名需要备案)或公网IP地址
server_addr = X.X.X.X
# frps服务端监听的端口号
server_port = 7000

# 令牌,和服务端一致
token = your_token

# p2p点对点连接失败时,改用转发访问(转发)
[web_1]
# 使用TCP协议进行转发
type = tcp
# 应用程序本地的IP,默认即可
local_ip = 127.0.0.1
# 应用程序本地的访问端口号
local_port = 3030
# 应用程序外网的访问端口号
remote_port = 9000

# 配置节点名称,可修改,在frps中名称需要唯一(p2p点对点连接)
[p2p_web]
# 节点类型为 xtcp 协议,用于点对点通信
type = xtcp
# 密钥,用于加密和解密通信内容,确保通信的安全性,可修改
sk = 123456789
# 本地 IP 地址,指定了节点所在的网络地址(可以填写局域网内其他服务器地址[local_port端口保持一致],这台设备用于frpc和frps建立连接)
local_ip = 127.0.0.1
# 本地端口号,指定了节点监听的网络端口
local_port = 3030
# 是否使用加密,在通信过程中对数据进行加密保护
use_encryption = true

Start command: ./frpc -c frpc.ini

3. Computer A frpc client configuration

frpc.ini

[common]
# 自己的frps服务器,阿里云服务器绑定的域名(国内服务器绑定的域名需要备案)或公网IP地址
server_addr = X.X.X.X
# frps服务端监听的端口号
server_port = 7000

# 令牌,和服务端一致
token = your_token

[p2p_web_visitor]
# 使用 xtcp 协议进行通信
type = xtcp
# 定义当前角色为访问端
role = visitor
# 指定B客户端的节点名称
server_name = p2p_web
# 设置与B客户端进行通信的密钥
sk = 123456789
# 绑定地址为本地回环地址 127.0.0.1,即只监听来自本机的连接, 可修改
bind_addr = 127.0.0.1
 # 绑定端口号为 9000,用于接收来自服务器的连接请求, 可修改
bind_port = 9000
# 当需要自动隧道持久性时,将其设置为true
keep_tunnel_open = false
# 启用加密功能,确保与服务器之间的通信数据得到保护
use_encryption = true

Start command: ./frpc -c frpc.ini

3. Alibaba Cloud port opening

  • 7000 (frps server listening port), 9000 (website port)

After the above deployment is completed, the user can access server B by using 127.0.0.1:9000 in the browser of computer A (the access can only be accessed if the penetration is successful, and those who are unsuccessful need to forward: XXXX:9000)

Guess you like

Origin blog.csdn.net/qq_45664055/article/details/132508122