frp Intranet Penetration Tutorial

This article is transcoded by SimpRead, original address https://blog.loli.wang/blog/2024-08-17-frpinit/doc/

Happily building with astro

Recently, quite a few people have asked me about the issue of intranet penetration. I think as a developer, it is common to have such needs. Generally, I recommend products like Peanut Hull (花生壳), NATAPP, etc., but then they ask, what if there are too many ports to map? What if they want to bind a domain name? What if they don’t want to do ICP filing? And so on… I would recommend setting up your own service. However, the problem is that many people have never even heard of it.

Prerequisites for Setup

An external network server (VPS) with a public IP address

What is FRP

frp is a high-performance reverse proxy application focused on intranet penetration. It supports multiple protocols such as TCP, UDP, HTTP, HTTPS and also supports P2P communication. It allows internal network services to be securely and conveniently exposed to the public network through a relay node with a public IP.

Install the Server

Go to GitHub to find the latest released version and use the uname -m command on your server to check the current system architecture

https://github.com/fatedier/frp/releases/tag/v0.59.0

# Use wget command to download the server compressed package
wget https://github.com/fatedier/frp/releases/download/v0.59.0/frp_0.59.0_linux_amd64.tar.gz

# Extract to /usr/local
tar -zxvf frp_0.59.0_linux_amd64.tar.gz -C /usr/local

Enter the /etc/systemd/system/ directory and create a new file frps.service, configuring it as a Systemd service

# frps.service 
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
#Restart=always
Restart=on-failure
RestartSec=5s
# Command to start the service
ExecStart=/usr/local/frp_0.59.0_linux_amd64/frps -c /usr/local/frp_0.59.0_linux_amd64/frps.toml
[Install]
WantedBy=multi-user.target

Save and go back to our original directory /usr/local/frp_0.59.0_linux_amd64, modify the frps.toml file

[common]
bind_addr = xx.xx.xx.xx # your server IP address
bind_port = 7000
kcp_bind_port = 7000
vhost_https_port = 7001
dashboard_addr = xx.xx.xx.xx
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
log_file = ./frps.log
log_level = info
log_max_days = 3
authentication_timeout = 900
token=mowangmowang
allow_ports = 2000-3000,3001,3003,4000-50000,3362
max_pool_count = 50
max_ports_per_client = 0

Server Configuration Details - gofrp

This pretty much completes the configuration.

Start the frp server on your server

# Enable autostart on boot
sudo systemctl enable frps
# Start frp
sudo systemctl start frps
# Check startup log
sudo systemctl status frps 
# Restart frp service
sudo systemctl restart frps 
# Stop frp service
sudo systemctl stop frps

Then visit the web management panel at ip:7500 to check if it is working normally, and enter the account and password set in the configuration file, both are admin

This means the server-side is successfully configured.

Client Usage (WIN)

In fact, installing the server as a client is very simple, it’s just a matter of usage. Here, I’ll only explain how to use it.

Download the Windows package and unzip it to your hard drive

Edit the frpc.toml file and simply map port 4321 locally to 2000 externally

[common]
server_addr = "your server ip"
server_port = 7000
token = "mowangmowang"

[[proxies]]
name = "web"
type = "tcp"
local_ip = "127.0.0.1"
local_port  = 4321
remote_port  = 2000

Run the command line

frpc -c frpc.toml

Mapping successful

Related Resources

Server Configuration Details - gofrp

Official GITHUB - frp

After tinkering all night, I finally learned it!