726 words
4 minutes
NAT Traversal with FRP

What I Needed#

I run quite a few services on my home server — alist, Open WebUI, and a handful of small projects of my own.

My previous setup used DDNS to pin down my dynamic public IP, with Nginx Proxy Manager in front to reverse-proxy everything to my LAN services.

The catch: residential broadband blocks certain ports — 80 (HTTP) and 443 (HTTPS) included — which forced me to reach alist at https://alist.mihouo.com:8443. Since 443 was blocked, Nginx Proxy Manager had to listen on 8443 and proxy through to 443.

My end goal was simple: kill the :8443 for good, so I could open https://alist.mihouo.com like a normal site.

What Is FRP#

FRP (Fast Reverse Proxy) is a high-performance reverse proxy application built for NAT traversal. It exposes services on a local network to the public internet, working around NAT and firewall restrictions. FRP consists of two parts: frps (the server) and frpc (the client). The idea is to tunnel an internal service out through a proxy so the outside world can reach it.

How FRP Works#

  1. Client (frpc): usually runs inside the LAN; it forwards local service traffic out over the tunnel.
  2. Server (frps): usually runs on a machine with a public IP; it receives requests from the outside and relays them to the corresponding local service.

frpc and frps communicate over a single TCP connection. frps acts as the proxy front end, accepting external requests and forwarding them to the right internal service, while frpc picks up whatever frps sends and hands it to the local service.

Configuring FRP#

FRP version: v0.61.1

Start by downloading FRP on both machines.

Terminal window
wget https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz

Extract the archive and cd into the folder:

Terminal window
tar -zxvf frp_0.61.1_linux_amd64.tar.gz
cd frp_0.61.1_linux_amd64
TIP

Make sure you grab the build that matches your server’s OS (Windows, Linux, macOS/darwin, …) as well as its CPU architecture (arm64, amd64, …).

Configuring FRPS#

Edit frps.toml with nano and add the following:

Terminal window
[common]
# The port frp listens on; 7000 by default, change it if you like
bind_port = 7000
# Auth token — pick something strong; the client will need this same token
token = token
# Port for the frp admin dashboard, adjust to your needs
dashboard_port = 7500
# Dashboard username and password — change these to your own
dashboard_user = user
dashboard_pwd = password
enable_prometheus = true
# Logging
log_file = ./frps.log
log_level = info
log_max_days = 3

Optional: Create a systemd Service#

Terminal window
sudo nano /etc/systemd/system/frps.service

Add the following:

Terminal window
[Unit]
Description=FRP Server
After=network.target
[Service]
Type=simple
ExecStart=/opt/frp_0.61.1_linux_amd64/frps -c /opt/frp_0.61.1_linux_amd64/frps.toml
Restart=on-failure
User=root
[Install]
WantedBy=multi-user.target

Start the Service#

Terminal window
sudo systemctl start frps
sudo systemctl stop frps

Check the Service Status#

Terminal window
sudo systemctl status frps

If it fails to start, it may be a permissions issue — run sudo chmod +x /opt/frp_0.61.1_linux_amd64/frps to fix it.

TIP

A status of active (running) means the service is up. If it fails, journalctl -u frps.service shows the detailed log.

To have it start on boot, run sudo systemctl enable frps.

Open the FRP Dashboard#

Visit the dashboard via your public IP and the dashboard port:

Terminal window
http://8.218.x.x:7500

Configuring FRPC#

On the other machine — the one behind NAT — edit frpc.toml with nano and add the following:

Terminal window
# [Public server address]
serverAddr = "8.218.x.x"
# [Public server port]
serverPort = 7000
# [Auth token — must match the server]
auth.token = "token"
[[proxies]]
name = "alist"
type = "tcp"
# Local service address
localIP = "127.0.0.1"
# Local service port
localPort = 5244
# The publicly exposed port
remotePort = 5244

Optional: Create a Service#

Following the frps setup, create a systemd unit for frpc (essentially just replace every frps with frpc).

My client machine is a Mac, so I used launchd to create a user-level service instead.

Terminal window
nano ~/Library/LaunchAgents/frpc.plist

Add the following:

Terminal window
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.frpc</string>
<key>ProgramArguments</key>
<array>
<string>~/opt/frp_0.61.1_darwin_arm64/frpc</string>
<string>-c</string>
<string>~/opt/frp_0.61.1_darwin_arm64/frpc.toml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/frpc.err</string>
<key>StandardOutPath</key>
<string>/tmp/frpc.out</string>
</dict>
</plist>

Load the Service#

Terminal window
launchctl load ~/Library/LaunchAgents/frpc.plist

Unload the Service#

Terminal window
launchctl unload ~/Library/LaunchAgents/frpc.plist

Start the Service#

Terminal window
launchctl start com.frp.client

Stop the Service#

Terminal window
launchctl stop com.frp.client

Check the Service Status#

Terminal window
launchctl list | grep frpc
TIP

For reasons I never fully tracked down, launchctl kept failing with failed: 5: Input/output error even though my config file was fine. In the end I just ran frpc inside tmux.

frp error log

Terminal window
tmux new-session -d -s frpc '~/opt/frp_0.61.1_darwin_arm64/frpc -c ~/opt/frp_0.61.1_darwin_arm64/frpc.toml'

If frpc starts cleanly, you can check the service status from the Dashboard.

frp Dashboard

At this point alist should be reachable at 8.218.x.x:5244.

That’s still not quite the end goal, though — the final step is using Nginx Proxy Manager to reverse-proxy port 5244 onto https://alist.mihouo.com.

See my Nginx Proxy Manager configuration guide

NAT Traversal with FRP
https://www.mihouo.com/en/posts/network/frp-intranet-penetration/
Author
Jia
Published at
2025-02-19
License
CC BY-NC-SA 4.0