frp 内网穿透 连接内网服务器和内网web
一、frp 的介绍
- fro 是一个高性能的反向代理应用,支持 tcp, udp, http, https 协议。
- frp 需要一台拥有公网IP的服务器作为中转,实现访问内网机器。
二、具有公网ip的服务器 安装 frp
- 我使用的系统是centos7
- frp可以在github 查看
- 当前frp最新版是 v0.45.0
- 下载完上传到在拥有公网ip的服务器或则直接通过wget下载到指定目录
# 下载 wget https://github.com/fatedier/frp/releases/download/v0.45.0/frp_0.45.0_linux_amd64.tar.gz # 解压 tar -zxvf frp_0.45.0_linux_amd64.tar.gz cd frp_0.45.0_linux_amd64 # 查看解压的目录 ls -alh
- 配置frps.ini,
shell vim frps.ini
[common] # 是frp客户端连接服务端的端口 bind_port = 7000 # 是http访问的端口(内网映射web的时候用到) vhost_http_port = 8088 # 授权码 token = 123456 # frp UI管理后台端口,请按自己需求更改,配置完成可以通过 http://公网ip:7500 直接访问 dashboard_port = 7500 # frp UI管理后台用户名和密码,请改成自己的 dashboard_user = admin dashboard_pwd = 123456
- 启动frp服务(以后台运行的方式启动)
nohup ./frps -c frps.ini > frps_log.log 2>&1 & # 查看是否启动成功 cat frps_log.log 2022/11/21 11:35:25 [I] [root.go:206] frps uses config file: frps.ini 2022/11/21 11:35:26 [I] [service.go:196] frps tcp listen on 0.0.0.0:7000 2022/11/21 11:35:26 [I] [service.go:241] http service listen on 0.0.0.0:8088 2022/11/21 11:35:26 [I] [service.go:297] Dashboard listen on 0.0.0.0:7500 2022/11/21 11:35:26 [I] [root.go:215] frps started successfully
三、win10安装frp
- 下载对应windows版本的frp, 下载
- 直接window解压,查看文件
- 修改配置文件:frpc.ini
[common] # 服务器ip server_addr = xxx.xxx.xxx.xxx # 服务器frp端口 server_port = 7000 # token token = 123456 # 内网映射web配置 [web] type = http # 本地机器内ip地址 local_ip = 192.168.33.10 # 本地机器web开放的web端口 local_port = 8080 #use_compression = true #外网服务器B转发内网服务器A使用的域名 #我们这边没有域名,直接使用服务器ip custom_domains = xxx.xxx.xxx.xxx [ssh] type = tcp # 本地机器内ip地址 local_ip = 192.168.33.10 # 本地机器开放的ssh端口 local_port = 22 #remote_port 表示在 frp 服务端监听的端口,访问此端口的流量将会被转发到本地服务对应的端口。 remote_port = 5011
- 启动客户端frp服务
> frpc.exe -c frpc.ini # 以下表示启动成功 2022/11/21 13:19:16 [I] [service.go:349] [058f56195485ceeb] login to server success, get run id [058f56195485ceeb], server udp port [0] 2022/11/21 13:19:17 [I] [proxy_manager.go:144] [058f56195485ceeb] proxy added: [web ssh] 2022/11/21 13:19:17 [I] [control.go:181] [058f56195485ceeb] [web] start proxy success 2022/11/21 13:19:17 [I] [control.go:181] [058f56195485ceeb] [ssh] start proxy success
四、ssh连接内网测试
ssh -p 5011 root@xxx.xxx.xxx.xxx
# 备注
- 5011表示远程服务器开放的连接ssh的端口,表示客户端frpc.ini remote_port的配置
- xxx.xxx.xxx.xx 表示远程frp服务器ip
- 连接内网服务成功
五、内网穿透web测试
- 直接通过远程服务器ip+端口的方式访问
- xxx.xxx.xxx.xxx:8088/
- 8088 表示远程服务器frps.ini中vhost_http_port的配置
- xxx.xxx.xxx.xx 表示远程frp服务器ip
- 访问内网web成功
六、访问frp dashboard
http:/xxx.xxx.xxx.xxx:7500/
- xxx.xxx.xxx.xxx 表示服务器ip
- 7500 表示frps.ini中 dashboard_port 的配置
会弹出让我们输入用户名和密码,直接用frps.ini中配置的 dashboard_user 和 dashboard_pwd
登录成功
友情链接
本作品采用《CC 协议》,转载必须注明作者和本文链接