保姆级教程:在Mac M1上5分钟搞定frp内网穿透,远程访问本地服务不求人

张开发
2026/4/16 10:26:15 15 分钟阅读

分享文章

保姆级教程:在Mac M1上5分钟搞定frp内网穿透,远程访问本地服务不求人
Mac M1极速内网穿透实战5分钟搭建FRP远程访问通道每次出差想连家里NAS找文件都要折腾半天端口映射团队协作时想共享本地开发环境却被内网限制搞得焦头烂额作为M1/M2芯片用户你可能已经发现许多传统教程在ARM架构上水土不服。别担心这份针对苹果芯片优化的实战指南将用最简配置带你在咖啡凉透前搞定远程访问。1. 准备工作精准获取ARM原生组件在M1/M2上跑x86程序就像用筷子吃牛排——不是不行但效率打折。我们直奔官方仓库获取darwin_arm64原生版本# 终端执行建议先cd到下载目录 curl -LO https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_darwin_arm64.tar.gz tar -zxvf frp_0.51.3_darwin_arm64.tar.gz cd frp_0.51.3_darwin_arm64提示若遇到证书错误可尝试追加--insecure参数或通过浏览器下载后解压验证文件架构是否匹配file frpc # 应显示Mach-O 64-bit executable arm642. 服务端配置云主机极简部署假设你已有Linux公网服务器推荐Ubuntu 22.04 LTS用SSH连接后执行wget https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_arm64.tar.gz tar -zxvf frp_0.51.3_linux_arm64.tar.gz cd frp_0.51.3_linux_arm64创建配置文件frps.ini[common] bind_port 7000 dashboard_port 7500 dashboard_user your_username dashboard_pwd your_password token your_secure_token_here启动服务推荐用systemd守护sudo cp frps /usr/local/bin/ sudo mkdir /etc/frp sudo cp frps.ini /etc/frp/ sudo nano /etc/systemd/system/frps.service粘贴以下服务配置[Unit] DescriptionFrp Server Afternetwork.target [Service] ExecStart/usr/local/bin/frps -c /etc/frp/frps.ini Restarton-failure [Install] WantedBymulti-user.target启用服务sudo systemctl enable --now frps sudo systemctl status frps # 验证状态3. 客户端配置M1专属优化方案回到Mac编辑frpc.ini配置文件[common] server_addr your.server.ip server_port 7000 token your_secure_token_here [mac_ssh] type tcp local_ip 127.0.0.1 local_port 22 remote_port 6000 [mac_webdev] type http local_port 3000 custom_domains dev.yourdomain.com重要提前在DNS将dev.yourdomain.com解析到服务器IP测试配置有效性./frpc verify -c frpc.ini4. 一键启动与自动化管理直接运行会占用终端我们用launchd实现后台运行nano ~/Library/LaunchAgents/com.user.frpc.plist粘贴以下内容修改路径为实际位置?xml version1.0 encodingUTF-8? !DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd plist version1.0 dict keyLabel/key stringcom.user.frpc/string keyProgramArguments/key array string/path/to/frpc/string string-c/string string/path/to/frpc.ini/string /array keyRunAtLoad/key true/ keyKeepAlive/key true/ /dict /plist加载配置launchctl load ~/Library/LaunchAgents/com.user.frpc.plist launchctl start com.user.frpc验证连接状态tail -f /tmp/frpc.log # 查看实时日志5. 高阶技巧安全加固与性能调优防火墙配置建议端口协议方向说明7000TCP入站仅限客户端IP7500TCP入站仅限管理IP6000TCP入站按需开放性能优化参数[common] tcp_mux true pool_count 5常见故障排查连接超时检查服务器安全组规则测试telnet your.server.ip 7000认证失败确认token两端一致检查时间同步时差超过2分钟会导致失败仪表盘无法访问确认dashboard_port未被占用检查防火墙放行情况6. 场景化配置模板远程开发环境[vscode_web] type http local_port 8080 custom_domains code.yourdomain.com http_user dev http_pwd secure_password家庭媒体中心[jellyfin] type tcp local_port 8096 remote_port 8096 use_encryption true use_compression true数据库穿透[mysql] type tcp local_port 3306 remote_port 3307 health_check_type tcp health_check_timeout_s 3 health_check_max_failed 3记得首次使用前用brew install mysql-client测试远程连接mysql -h your.server.ip -P 3307 -u root -p

更多文章