Linux,tools FRP内网穿透工具 发表于 2022-10-30 浏览量 621 没有评论 # 简介 [官网](https://gofrp.org/)、[软件地址](https://github.com/fatedier/frp/releases) frp 采用 C/S 模式,将服务端部署在具有公网 IP 的机器上,客户端部署在内网或防火墙内的机器上,通过访问暴露在服务器上的端口,反向代理到处于内网的服务。 在此基础上,frp 支持 TCP, UDP, HTTP, HTTPS 等多种协议,提供了加密、压缩,身份认证,代理限速,负载均衡等众多能力 # 服务端安装 ``` [root@ewain-tencent:/data/app]# tar xf frp_0.44.0_linux_amd64.tar.gz [root@ewain-tencent:/data/app]# mv frp_0.44.0_linux_amd64 frp [root@ewain-tencent:/data/app]# cd frp [root@ewain-tencent:/data/app/frp]# vim frps.ini [common] # frp监听端口 bind_port = 7000 # frp授权码 token = 123.com # frp管理后台 dashboard_port = 7001 dashboard_user = admin dashboard_pwd = admin enable_prometheus = true # 日志文件 log_file = /var/log/frps.log log_level = info log_max_days = 3 ``` - 默认是前台启动,我们使用systemd来管理,如果没有systemd,需要自己安装! ``` [root@ewain-tencent:/data/app/frp]# vim /etc/systemd/system/frps.service [Unit] # 服务名称,可自定义 Description = frp server After = network.target syslog.target Wants = network.target [Service] Type = simple # 启动frps的命令,需修改为您的frps的安装路径 ExecStart = /data/app/frp/frps -c /data/app/frp/frps.ini [Install] WantedBy = multi-user.target ``` - 管理命令 ``` # 启动frp systemctl start frps # 停止frp systemctl stop frps # 重启frp systemctl restart frps # 查看frp状态 systemctl status frps # 开机自启 systemctl enable frps ``` # 客户端安装 ``` # 跟服务端同一个包 cd /data/app/frp_0.44.0_linux_amd64 vim frpc.ini [common] server_addr = 106.55.190.94 # 服务器IP server_port = 7000 # 服务器端口 token = 123.com # 密码 # 配置ssh服务器 [ssh] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 6000 # 远程端口,记得开放端口 ``` - 启动服务 ``` ./frpc -c frpc.ini 2022/08/24 00:08:03 [I] [service.go:349] [ec1a873fbe3e1f63] login to server success, get run id [ec1a873fbe3e1f63], server udp port [0] 2022/08/24 00:08:03 [I] [proxy_manager.go:144] [ec1a873fbe3e1f63] proxy added: [ssh] 2022/08/24 00:08:03 [I] [control.go:181] [ec1a873fbe3e1f63] [ssh] start proxy success ``` - 访问测试 ``` ssh root@106.55.190.94 -p 6000 The authenticity of host '[106.55.190.94]:6000 ([106.55.190.94]:6000)' can't be established. ECDSA key fingerprint is SHA256:8l5LQLAxZv7Z3fH1WRj0zz3+2U5g5sfpDuQcryTaC/A. ECDSA key fingerprint is MD5:66:3f:55:07:e3:e2:55:08:27:c5:34:61:10:ed:e0:5d. Are you sure you want to continue connecting (yes/no)? yes ``` - 还有很多具体的玩法,可以参考官网给出的示例