NAT Traversal Guide - Frp

NAT Traversal Guide - Frp

Shetty Yttehs Lv1

Before Reading

Note: This is a guide on how to obtain ssh connection via NAT traversal.

What’s NAT Traversal

fatedier/frp

Map the port of the internal network device to the external network device.

Architecture ( From Github ):

architecture

Errate

Before delving into the text, it’s important to note that there may be some grammar or syntax errors present. This could be due to translation errors, typing mistakes, or the author’s unique writing style ( I’m a Chinese native speaker 😅 ).

Requirements

TypeDescription
Servera device or vps with a public IP and terminal access
Clientlocal device
  • My environment:
TypeServerClient
DeviceVps ( CentOS )Laptop ( ArchLinux )
PlatformLinuxLinux

Download Frp Tools

fatedier/frp Releases

  1. Choose the latest version and the specific CPU architecture of the device.

Download at both server and client.

  • If you are using ArchLinux:

Add archlinuxcn source first ( At /etc/pacman.conf ).

For server:

1
sudo pacman -S frps

For client:

1
sudo pacman -S frpc
  1. Extract the file
1
tar -xvf frp_x.x.x_<platform>_<architecture>.tar.gz

Configure Toml File

Enter the unzipped folder.

1
cd /path/to/folder

Server Configuration

1
vim frps.toml
  • If you are using ArchLinux:
1
sudo vim /etc/frp/frps.toml
1
bindPort = 7000             # custom

Client Configuration

1
vim frpc.toml
  • If you are using ArchLinux:
1
sudo vim /etc/frp/frpc.toml
1
2
3
4
5
6
7
8
9
serverAddr = "host_name"    # replace host_name with the IP or domain of your server
serverPort = 7000 # same as bindport in frps.toml

[[proxies]]
name = "test-tcp"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000 # custom

Start Frp

Start sshd service first.

1
sudo systemctl start sshd

For Server

1
2
./frps -c frps.toml         # run
nohup ./frps -c frps.toml # run on background
  • If you are using ArchLinux:
1
sudo systemctl start frps

For Client

1
2
./frpc -c frpc.toml         # run
nohup ./frpc -c frpc.toml # run on background
  • If you are using ArchLinux:
1
sudo systemctl start frpc

Usage

In terminal of any device with Internet connection.

1
2
3
ssh -oPort=6000 <user_name>@<host_name>
# user_name from client
# host_name of server

References

Frp Offical Repository

  • Title: NAT Traversal Guide - Frp
  • Author: Shetty Yttehs
  • Created at : 2024-04-29 10:07:58
  • Updated at : 2024-09-01 12:58:06
  • Link: https://blog.shettyyttehs.org/2024/04/29/nat-traversal-guide-frp/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments