--- title: "FRP内网穿透" type: concept tags: [networking, self-hosted, reverse-proxy, tunneling] --- ## 定义 FRP(Fast Reverse Proxy)是一个高性能的内网穿透工具,通过在公网 VPS 上部署 frps 服务端(FRPS),在内网机器上部署 frpc 客户端,将内网服务暴露到公网。 ## 架构 ``` [内网服务] ←localhost:port← [frpc 客户端] ←TCP/UDP← [frps 服务端] ←公网← [用户] ``` - **frps(FRP Server)**:运行在有公网 IP 的 VPS 上,监听连接请求 - **frpc(FRP Client)**:运行在内网机器上,与 frps 保持心跳,转发请求到内网服务 ## 核心配置(frpc.toml) ```toml [[proxies]] name = "ssh-tunnel" type = "tcp" localIP = "127.0.0.1" localPort = 22 remotePort = 60022 # 公网 VPS 暴露的端口 ``` ## 在家庭基础设施中的应用 | 节点 | frpc 版本 | frps 服务器 | |------|-----------|-------------| | [[Mac Mini]] | 0.65.0 darwin arm64 | VPS1 :7000 | | [[Synology NAS DS718]] | 0.65.0 linux amd64 | VPS1 :7000 | | [[Ubuntu1]] | 0.65.0 linux amd64 | VPS1 :7000 | | [[Ubuntu2]] | 0.65.0 linux amd64 | VPS1 :7000 | ## 关键优势 - 不需要公网 IP,利用 VPS 中转实现内网暴露 - 支持 TCP/UDP/HTTP/HTTPS多种协议 - 可配置 auth_method 实现加密通信 - 通过 ini 或 toml 配置文件管理,版本可控 ## 管理命令 | 服务器 | 启动方式 | 重启命令 | |--------|---------|---------| | Mac Mini | launchd(plist) | launchctl unload/load plist | | Ubuntu1/2 | systemd --user | systemctl --user restart frpc | ## 与其他方案的比较 - **frp vs ngrok**:frp 完全自托管,无带宽限制,配置灵活 - **frp vs Cloudflare Tunnel**:frp 需要 VPS,Cloudflare Tunnel 依赖 Cloudflare 基础设施 ## 相关工具 - [[反向代理]]:Caddy 作为 HTTP 层反向代理 - [[内网穿透]]:frp 属于内网穿透工具类别