使用FRP搭建P2P点对点穿透

做p2p穿透所使用的协议为xtcp,搭建最少需要一台服务端两台客户端。

优点:仅少量占用服务器带宽,占用的带宽可忽略不计,传输大文件利器!

1、将配置文件写入frps.ini(服务端配置)

# 服务端配置
[common]
bind_addr = 0.0.0.0
bind_port = 7000
bind_udp_port = 7001
kcp_bind_port = 7000
# 开启控制面板
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin

2、在需要穿透的主机内网开启一个frpc客户端,将配置文件写入frpc.ini(客户端配置)

# 连接服务器配置
[common]
server_addr = ***.***.***.***
server_port = 7000
# 开启控制面板
admin_addr = 127.0.0.1
admin_port = 80
# 设置控制面板账号密码
admin_user = admin
admin_pwd = admin
# 设置需要穿透的名称,但是在服务器后台是看不到该连接的
[Mstsc]
# 设置协议xtcp
type = xtcp
# 设置密钥
sk = abcdefg
# 设置需要穿透的IP
local_ip = 127.0.0.1
# 设置需要穿透的端口
local_port = 3389

3、在需要访问穿透主机的主机上开启一个frpc客户端,将配置文件写入frpc.ini(客户端配置)

# 连接服务器配置
[common]
server_addr = ***.***.***.***
server_port = 7000
# 开启控制面板
admin_addr = 127.0.0.1
admin_port = 80
# 设置控制面板账号密码
admin_user = admin
admin_pwd = admin
# 设置需要访问穿透的命名,可随意命名
[Mstsc_visitor]
# 设置协议xtcp
type = xtcp
# 设置角色为visitor
role = visitor
# 设置被穿透主机的frpc穿透名称
server_name = Mstsc
# 设置密钥
sk = abcdefg
# 将穿透的IP地址绑定为本地地址
bind_addr = 127.0.0.1
# 将穿透的端口绑定为本地端口
bind_port = 3390

4、开启所有服务,在本地运行mstsc进行测试,连接上即可。

localhost:3390

** 使用点对点直连 **
FPR提供了一种xtcp的直连方式,可以允许我们控制端与被控端进行点对点连接。原理是通过服务端找到双方位置,之后双方使用UDP进行通讯

下面修改服务端配置文件frps.ini

[common]
bind_port = 7000
bind_udp_port = 7001

可以看多了一个UDP端口,重启服务器
因为是直连,所以连接双方都要有frp

其中控制端frpc.ini文件如下:

[common]
server_addr = 你的IP地址
server_port = 7000

[p2p_mstsc_visitor]
#官方文档是使用xtcp,但是测试发现穿透率不高,所以改用stcp
type = stcp
# xtcp 的访问者
role = visitor
# 要访问的 xtcp 代理的名字
server_name = mstsc
# 只有 sk 一致的用户才能访问到此服务
sk = kangdi
# 绑定本地端口用于访问 ssh 服务
bind_addr = 127.0.0.1
bind_port = 6999

启动服务。

被控制端frpc.ini文件如下:

[common]
server_addr = 你的IP地址
server_port = 7000
auto_token=mstsc

[mstsc]
type = stcp
# 只有 sk 一致的用户才能访问到此服务
sk = kangdi
local_ip = 127.0.0.1
local_port = 3389

启动服务。

现在,在远程连接的时候输入localhost:6999就能点对点访问服务器了

所有评论(4)

  1. It’s perfecct time to make some plans for the future and it is time to bee happy.

    Ihavge read this pot andd if I could I wish to suggest you few interesting things or tips.
    Perhaps you can write next articles referriung to this article.
    I desire to read more things about it! https://glassi-App.Blogspot.com/2025/08/how-to-download-glassi-casino-app-for.html

  2. I know this if off topic but I’m looking into starting my own bloog and was wondering what
    all is required to get set up? I’m assming having a blog like yours
    would cost a pretty penny? I’m not very inteernet smart so I’m
    not 100% positive. Any recommendations or advice wouod be greatly appreciated.

    Many thanks https://glassiindia.wordpress.com

  3. Hello there! This is my 1st comment here sso I just wanted
    to give a quick sout out and tell you I truly enjoy reading your articles.
    Can you recommend any other blogs/websites/forums that ggo over the same subjects?
    Manny thanks! https://Izibiz.pl/companies/tonebet-casino/

  4. Magnificent goods from you, man. I have understand your stuff previous to and you are juszt extremely excellent.
    I actually likke wuat you havbe acquired here, certainly like what you’re
    stating and thee way in which you say it. You make it enjoyable and you still care for
    to keep iit smart. I can not wait to read much more from you.
    This is really a wonderful web site. https://WWW.Bridgewaystaffing.com/employer/tonybet/

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注