frp 实现内网穿透
FRP 下载
frp 采用 Golang 编写,支持跨平台
Github:
github.com/gofrp/frp-site
github.com/fatedier/frp
frp 中文文档:github.com/fatedier/frp/blob/dev/R...
frp 中文文档: https://gofrp.org
配置
服务器端
前提条件
无服务需要有能访问到的公网 IP
一、下载解压
$ mkdir frp && cd frp
$ wget https://github.com/fatedier/frp/releases/download/v0.34.2/frp_0.34.2_linux_amd64.tar.gz
tar -zxvf frp_0.34.2_linux_amd64.tar.gz
cd frp_0.34.2_linux_amd64
二、修改配置
修改服务器端配置文件 frps.ini
[common]
bind_port = 7000 # 与客户端绑定进行通行的端口
vhost_http_port = 6081 # 访问客户端 web 服务自定义的端口
三、运行
./frps -c ./frps.ini
客户端
一、下载解压压缩包,同上
二、修改配置文件frpc.ini
[common]
server_addr = xxx.xxx.xxx.xxx # frps 所在服务器的公网 IP
server_port = 7000 # 与服务端 bind_port 一致
# 公网通过 ssh 访问内部服务器
[ssh]
type = tcp # 连接协议
local_ip = 192.168.1.65 # 本地需要暴露到公网的服务地址
local_port = 22 # 本地需要暴露到公网的服务地址
remote_port = 6000 # 在 frp 服务端监听的端口,访问此端口的流量将会被转发到本地服务对应的端口
# 公网访问内部 web 服务器以 http 方式
[web]
type = http # 访问协议
local_port = 8081 # 内网 web 服务的端口号
custom_domains = my.test.com # 所绑定的服务器域名,一级二级都行
三、启动客户端 frpc 服务
./frpc -c ./frpc.ini
效果
记得将防火墙对应的端口开放,不然所有的请求会被防火墙拦截
ssh 连接
$ ssh -oPort=6000 username@xxx.xxx.xxx.xxx
页面访问
my.test.com:8081
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: