新版本(0.50+)FRP使用教程

🚀 frp(Fast Reverse Proxy)如何使用?

frp 是一个高性能的内网穿透工具,可以把你内网的服务(SSH、网站、Minecraft、面板等)映射到公网服务器上。

它由两部分组成:

  • frps → 服务端(部署在有公网 IP 的 VPS 上)

  • frpc → 客户端(部署在内网机器上)


一、基本使用流程

🖥️ 场景示例

假设:

  • 公网 VPS:1.2.3.4

  • 内网机器:192.168.1.10

  • 想把内网 22 端口(SSH)映射到公网 6000 端口


二、服务端(VPS)配置

1️⃣ 下载 frp

去 GitHub 下载最新版:

👉 https://github.com/fatedier/frp

Linux 示例:

wget https://github.com/fatedier/frp/releases/latest/download/frp_0.xx.x_linux_amd64.tar.gz
tar -zxvf frp_0.xx.x_linux_amd64.tar.gz
cd frp_0.xx.x_linux_amd64

2️⃣ 创建 frps.toml(服务端配置)

新版本(0.50+)使用 toml 格式:

bindPort = 7000   # 客户端连接端口

auth.method = "token"
auth.token = "123456"

3️⃣ 启动服务端

./frps -c frps.toml

后台运行:

nohup ./frps -c frps.toml &

三、客户端(内网机器)配置


1️⃣ 下载 frp

和服务端一样下载解压。


2️⃣ 创建 frpc.toml

serverAddr = "1.2.3.4"
serverPort = 7000

auth.method = "token"
auth.token = "123456"

[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000

3️⃣ 启动客户端

./frpc -c frpc.toml

四、测试连接

现在在任意地方可以:

ssh -p 6000 user@1.2.3.4

就会连接到你的内网 SSH。


五、常见用途示例

🔹 映射网站(HTTP)

[[proxies]]
name = "web"
type = "http"
localPort = 80
customDomains = ["test.example.com"]

⚠ 需要服务端配置:

vhostHTTPPort = 80

🔹 映射 Minecraft

[[proxies]]
name = "mc"
type = "tcp"
localIP = "127.0.0.1"
localPort = 25565
remotePort = 25565

🔹 映射面板 / Docker 服务

直接映射对应端口即可。


六、做成 systemd 服务(推荐)

/etc/systemd/system/frps.service

[Unit]
Description=frp server
After=network.target

[Service]
Type=simple
ExecStart=/root/frp/frps -c /root/frp/frps.toml
Restart=always

[Install]
WantedBy=multi-user.target

然后:

systemctl daemon-reload
systemctl enable frps
systemctl start frps

七、安全建议 ⚠

  • 一定要开启 token

  • VPS 防火墙只开放必要端口

  • 不建议暴露 22 到公网

  • 可以配合 nginx 做反代

  • 建议改默认端口


八、排错思路

问题 排查
连接不上 VPS 防火墙是否放行 7000
客户端连不上 token 是否一致
端口无法访问 VPS 是否开放 remotePort
日志查看 ./frps -c frps.toml -L info

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享