P2P (Peer-to-Peer) is a type of network architecture in which all the nodes (typically computers) in the network are considered equal and can communicate directly with each other, sharing resources and data without the need for an intermediary server. This contrasts with the traditional client-server model, where clients request services from servers.
Frps configuration
Similarly as before, edit the frps.toml in the server end and add the following lines here. WebServer service and auth.token could be disabled as well, just follow your heart.
# frpc.toml serverAddr = "x.x.x.x" serverPort = 7000 # set up a new stun server if the default one is not available. # natHoleStunServer = "xxx"
[[proxies]] name = "p2p_ssh" type = "xtcp" secretKey = "abcdefg" localIP = "127.0.0.1" localPort = 22 # Here, I use ssh port as an example. Something else, such as 80(httpd) works as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
cat > /etc/systemd/system/frpc.service <<-'EOF' [Unit] Description=FRP Client Service After=network.target
Start another frpc (typically on another machine C) with the configuration to connect to SSH using P2P mode.
1 2 3 4
[root@VM-48-7-rockylinux ~]# mv frp_0.62.0_linux_amd64 /usr/local/bin/frp [root@VM-48-7-rockylinux ~]# cd /usr/local/bin/ [root@VM-48-7-rockylinux bin]# ls frp scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# frpc.toml serverAddr = "x.x.x.x" serverPort = 7000 # set up a new stun server if the default one is not available. # natHoleStunServer = "xxx"
[[visitors]] name = "p2p_ssh_visitor" type = "xtcp" serverName = "p2p_ssh" # The serverName here and that one in Proxy must be set to the same. secretKey = "abcdefg" # The secretKey here and that one in Proxy must be set to the same. bindAddr = "127.0.0.1" bindPort = 6000 # when automatic tunnel persistence is required, set it to true # keepTunnelOpen = false # Comment this line
Connect
On machine C, connect to SSH on machine B, using this command.
Login Successfully
1 2 3 4 5 6
[root@VM-48-7-rockylinux frp_0.62.0_linux_amd64]# ssh -oPort=6000 127.0.0.1 root@127.0.0.1's password: Activate the web console with: systemctl enable --now cockpit.socket
Last login: Sat Apr 26 21:30:24 2025 from 175.162.122.18 [root@VM-0-7-rockylinux ~]#
Congratulations! This image is an evidence to proof that The traffic did not go through the frps server, but instead, machine B and machine C are directly connected.
[root@VM-0-7-rockylinux ~]# systemctl enable httpd.service --now Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service. [root@VM-0-7-rockylinux ~]# systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled) Active: active (running) since Sat 2025-04-26 22:11:58 CST; 1s ago Docs: man:httpd.service(8) Main PID: 21890 (httpd) Status: "Started, listening on: port 80" Tasks: 177 (limit: 12140) Memory: 24.2M CPU: 47ms CGroup: /system.slice/httpd.service ├─21890 /usr/sbin/httpd -DFOREGROUND ├─21891 /usr/sbin/httpd -DFOREGROUND ├─21892 /usr/sbin/httpd -DFOREGROUND ├─21893 /usr/sbin/httpd -DFOREGROUND └─21894 /usr/sbin/httpd -DFOREGROUND
Apr 26 22:11:58 VM-0-7-rockylinux systemd[1]: Starting The Apache HTTP Server... Apr 26 22:11:58 VM-0-7-rockylinux httpd[21890]: Server configured, listening on: port 80 Apr 26 22:11:58 VM-0-7-rockylinux systemd[1]: Started The Apache HTTP Server.
Create a large file by dd command in machine B
1 2 3 4
[root@VM-0-7-rockylinux html]# dd if=/dev/zero of=testfile bs=1M count=5120 5120+0 records in 5120+0 records out 5368709120 bytes (5.4 GB, 5.0 GiB) copied, 25.0375 s, 214 MB/s
Move the large file to the httpd root directory in machine B
1
mv testfile /var/www/html
Use wget command in machine C and download the large file from machine B
1 2 3 4 5 6 7
[root@VM-48-7-rockylinux test_http]# wget http://127.0.0.1:6000/testfile --2025-04-26 22:17:00-- http://127.0.0.1:6000/testfile Connecting to 127.0.0.1:6000... connected. HTTP request sent, awaiting response... 200 OK Length: 5368709120 (5.0G) Saving to: ‘testfile.1’ testfile.1 10%[==> ] 529.66M 11.6MB/s eta 6m 47s ^C
Congratulations! This image is an evidence to proof that The traffic did not go through the frps server, but instead, machine B and machine C are directly connected.
Copyright Notice: This article is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the original author and source when sharing.