FRP 内网穿透

Summary: Author: 张亚飞 | 阅读时间: 2 minute read | Published: 2020-02-04
Filed under Categories: LinuxTags: Note,

FRP 内网穿透

GitHub: fatedier/frp

FRP 简介

FRP 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp 协议,为 httphttps 应用协议提供了额外的能力,且尝试性支持了点对点穿透.

FRP 作用

  • 利用处于内网或防火墙后的机器,对外网环境提供 httphttps 服务.
  • 对于 http, https 服务支持基于域名的虚拟主机,支持自定义域名绑定,使多个域名可以共用一个80端口.
  • 利用处于内网或防火墙后的机器,对外网环境提供 tcpudp 服务,例如在家里通过 ssh 访问处于公司内网环境内的主机.

部署 CentOS 服务端

/data/opt

wget https://github.com/fatedier/frp/releases/download/v0.31.1/frp_0.31.1_linux_amd64.tar.gz
tar -zxvf frp_0.31.1_linux_amd64.tar.gz
sudo cp -r frp_0.31.1_linux_amd64 /usr/local

修改服务的配置frps.ini:

/usr/local/frp_0.31.1_linux_amd64/frps.ini

[common]
bind_port = 7000
vhost_http_port = 7002

# 设置本地网页端观察服务器代理情况
[common]
dashboard_port = 7005
# dashboard 用户名密码,默认都为 admin
dashboard_user = admin
dashboard_pwd = admin

启动 frps 服务端:

/usr/local/frp_0.31.1_linux_amd64

$ ./frps -c ./frps.ini
2020/02/04 19:43:28 [I] [service.go:152] frps tcp listen on 0.0.0.0:7000
2020/02/04 19:43:28 [I] [service.go:194] http service listen on 0.0.0.0:7002
2020/02/04 19:43:28 [I] [service.go:251] Dashboard listen on 0.0.0.0:7005
2020/02/04 19:43:28 [I] [root.go:205] start frps success

管理后台: Server Dashboard


部署 CentOS 客户端 RaspberryPi

/data/opt

wget https://github.com/fatedier/frp/releases/download/v0.31.1/frp_0.31.1_linux_arm.tar.gz
tar -zxvf frp_0.31.1_linux_arm.tar.gz
sudo cp -r frp_0.31.1_linux_arm /usr/local

客户端配置文件

/usr/local/frp_0.31.1_linux_arm/frpc.ini

[common]
server_addr = 47.244.154.194
server_port = 7000

# 设置本地网页端观察本地代理情况
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = admin
admin_pwd = admin

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 7001

[range:tcp_port]
type = tcp
local_ip = 127.0.0.1
local_port = 3389,7400
remote_port = 7003,7004
use_encryption = false
use_compression = false

[web]
type = http
local_port = 6006
custom_domains = www.iirii.com

启动 frpc 客户端:

# ./frpc -c ./frpc.ini
2020/02/04 12:14:58 [I] [service.go:250] [245969157412e8ca] login to server success, get run id [245969157412e8ca], server udp port [0]
2020/02/04 12:14:58 [I] [proxy_manager.go:144] [245969157412e8ca] proxy added: [ssh tcp_port_1 tcp_port_0 web]
2020/02/04 12:14:58 [I] [service.go:130] admin server listen on 127.0.0.1:7400
2020/02/04 12:14:59 [I] [control.go:164] [245969157412e8ca] [tcp_port_0] start proxy success
2020/02/04 12:14:59 [I] [control.go:164] [245969157412e8ca] [ssh] start proxy success
2020/02/04 12:14:59 [I] [control.go:164] [245969157412e8ca] [tcp_port_1] start proxy success
2020/02/04 12:14:59 [I] [control.go:164] [245969157412e8ca] [web] start proxy success

客户端后台: Client Dashboard

可以通过 SSH 连接 RaspberryPi

ssh root@47.89.20.207 -p 7001

配置 Mysql 内网穿透

黑科技-内网穿透frp

[mysql]
type = tcp
local_ip = 127.0.0.1
local_port = 3306
remote_port = 1006

参考: Centos搭建Frp实现内网穿透

Comments

Cor-Ethan, the beverage → www.iirii.com