Bobay Stack

Networking & proxies / 2026-07-27

FRP Tunneling: Narrowing Your Ports Matters More Than Switching Tools

The tunneling tool is easy to set up; the hard part is remembering to close it down. How to work out a minimal exposure surface across three machines.

4 MIN READ BY BOBAY.TOP Updated 2026-08-02 ↖ All notes
FRP Tunneling: Narrowing Your Ports Matters More Than Switching Tools

The most common use of tunneling is "expose some panel at home so I can check it while I'm out." Once it works, few people go back and do the second thing: narrow the exposed range.

Make the list first, then configure ports

My current rule is that the server side opens exactly one port, and each service on the client side is declared explicitly:

# frps.toml
bindPort = 7000
auth.method = "token"
auth.token = "<pre-shared token>"
# frpc.toml
serverAddr = "<cloud host>"
serverPort = 7000

[[proxies]]
name = "panel"
type = "tcp"
localIP = "10.0.0.10"
localPort = 8080
remotePort = 18080

The key is remotePort: don't collide with common ports, and don't use a contiguous range. One port per service, open it when you need it.

Three openings you must close

  • The frps dashboard comes with a web console by default. Turn it off if you can; if you can't, bind it to 127.0.0.1.
  • Token auth is not optional. An frps without a token is an open door into your internal network for the whole internet.
  • Panel-type services are best put behind HTTP Basic or a front reverse proxy that restricts by source.

If you don't need HTTP, don't tunnel over HTTP

type = "http" brings a custom domain and Host header handling with it — convenient, but it adds another parsing surface. For SSH, databases and the like, plain tcp is cleaner and gets scanned less.

One easily overlooked side effect

Once the tunnel is up, the logs on the machine at home fill up with requests coming from the cloud host's IP. If you run fail2ban or rate limiting, remember to whitelist that cloud host IP, otherwise your own legitimate tunnel traffic gets banned by yourself.

Review checklist

  • [ ] frps has exactly one externally facing port
  • [ ] token / pre-shared key is configured and rotated regularly
  • [ ] every service pins localIP, none use 0.0.0.0
  • [ ] no console panel exposed to the public internet
  • [ ] cloud host IP whitelisted in the local ban rules

Three tiers of exposure

FRP's risk isn't in the protocol, it's in what you map out. By risk, high to low:

  1. Admin panels (BaoTa 8888, database 3306, SSH 22) — exposing them directly is hanging the key by the front door
  2. Internal services (NAS, router admin) — weak auth, no rate limiting
  3. Business ports (80/443) — these have to be exposed, but with a WAF and logs

There's only one principle: if a tunnel will do, don't open a port; if the internal network will do, don't go over the public internet.

Tightening the config

# frps.ini
[common]
bind_port = 7000
token = <long random string>
# only allow the agreed ports, don't set allow_ports = 1-65535
allow_ports = 8080,8443
# frpc.ini
[web]
type = http
local_port = 80
custom_domains = demo.example.com

Writing a range in allow_ports is the most common mistake: once the token leaks, the other side can map out any internal port.

Three locks you must add

  • Use a long random string for the token, not something like 123456; FRP compares tokens in plaintext and has no rate limiting.
  • frps should listen only on the internal network or a specific IP, never 0.0.0.0.
  • Keep logs: turn on log_file, record connection sources, so you can trace things after an incident.

Verify the exposure

nmap -p- --min-rate 2000 <public IP>       # what's actually open, seen from outside
ss -lntp                                   # what's listening, seen from inside

Compare the two results. If something is reachable from outside but nothing is listening inside, there's another forwarding layer you didn't account for.

FRPtunnelingattack surface

References

frp docs ↗