frp实现内网穿透

利用frp实现外网访问局域网系统,或进行微信开发等。frp项目地址:https://github.com/fatedier/frp

所需环境:

  1. 具有公网的服务器(服务端)
  2. 内网电脑(客户端)
  3. 可选使用域名或IP访问
  4. 云服务器安全组、宝塔等放行对应端口

步骤

  1. 通过github下载linux服务端及windows客户端
  2. 服务器和客户端对应修改配置项并启动

服务端配置
[common]
bind_port = 7000 #默认的配置信息中只有7000端口,外网服务器通过7000端口和客户端进行通信
vhost_http_port = 6001

启动服务端
nohup ./frps -c ./frps.ini > file.log 2>&1 &

客户端配置

[common]
server_addr = x.x.x.x #公网服务器地址
server_port = 7000

[ssh] #使用ssh连接内网服务器
type = tcp
local_ip = 127.0.0.1 # 绑定的ip,填写127.0.0.1表示本机即可
local_port = 22
remote_port = 6008 # ssh默认是22,现在转发为6008端口

[web] #访问web服务
type = http
local_port = 80
custom_domains = a.r1989.com #公网服务器IP地址或备案域名

[web2]
type = http
local_port = 81
custom_domains = b.r1989.com #公网服务器地址

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

启动客户端
./frpc -c ./frpc.ini

测试
ssh连接:ssh root@x.x.x.x -p 6008

Tags: Linux

添加新评论