无需付费的内网穿透工具(基于开源ngrok 1.7增强版,新增自动授权token验证)
最编程
2024-07-30 20:43:40
...
举例场景
- 本地WEB外网访问、本地开发微信、TCP端口转发
- 快速开发微信程序和第三方支付平台调试
- 管理内网服务器,内网web进行演示 将内网服务供外网访问
下载使用
- 百度网盘地址 包含了linux windows mac 客户端
- 请在命令行执行 由于目前都是64位系统 32位客户端不在提供
- 链接:https://pan.baidu.com/s/1AN6bZKiyZAiG0nZ-blHJlg 提取码:z57v
例如
-
1、内网搭建了一个虚拟机 想外网访问
#设置密钥 当前为测试token 有 1个月的使用期限 永久token请加微信 xinyangbest 获取 ./ngrok authtoken e10adc3949ba59abbe56e057f20f883e #输出配置文件所在路径 save authtoken to configuration file C:\Users\Administrator/.sltin/sltin.yml #操作进行内网转发 ./ngrok -proto=tcp 内网ip:ssh端口 #输出以下内容 ssh user@n.sltin.com -p 35109 即可访问内网主机 Tunnel Status online Version 1.7/1.7 Forwarding tcp://n.sltin.com:35109 -> 10.20.1.50:22 Web Interface 127.0.0.1:6060 Conn 0 Avg Conn Time 0.00ms
2、内网搭建了服务想要外网访问
# 操作进行内网转发
./ngrok -log=ngrok.log 内网ip:80
#浏览器访问 74926235.n.sltin.com 即可访问内网主机 https协议 加上https前缀即可
Tunnel Status online
Version 1.7/1.7
Forwarding http://74926235.n.sltin.com -> 10.20.1.50:80
Forwarding https://74926235.n.sltin.com -> 10.20.1.50:80
Web Interface 127.0.0.1:6060
# Conn 0
Avg Conn Time 0.00ms
配置文件详解
- 上面启动命令配置了很多参数 每次都要记录很不方便
- 比如我想要同时转发内网ssh登陆 和 其他web服务多个通道转发怎么转发呢?
- 那配置文件属性tunnels可以帮你解决这个问题
auth_token: e10adc3949ba59abbe56e057f20f883e #你的token 通过./ngrok authtoken xxxxx 可以自动设置保存
#http_proxy: "http://user:password@1.0.0.1:3128" #在一个高度限制的企业网络中时,默认遵守标准的Unix环境变量 http_proxy,也可以通过在配置文件http_proxy参数来指定。
inspect_addr: "127.0.0.1:6060" #本地web调试工具所绑定的端口 默认6060 可以修改为你自定义的 0.0.0.0:xxxx
tunnels:
k8s:
subdomain: "dashboard-proxy" #自定义子域名 适用于记录下了地址,避免每次启动随机生成子域名
#auth: "user:password" #设置httpauth认证
proto: #设置协议 例如 http 或 https
https: 10.20.1.110:8443
http: 10.20.1.110:8443
ssh:
#hostname: "test.com" #自定义*域名 需要设置域名cname解析到 n.sltin.com
subdomain: "test-ssh" #设置自定义子域名 适用于记录下了地址,避免每次启动随机生成子域名
remote_port: 6666 #远端端口 只有在tcp协议下有效,设置服务器端提供的端口
proto: #设置协议 例如进行ssh 或者长连接转发 请使用 tcp
tcp: 10.20.1.50:22
- 输出结果
./ngrok -log=ngrok.log start-all
ngrok (
Tunnel Status online
Version 1.7/1.7
Forwarding https://dashboard-proxy.n.sltin.com -> 10.20.1.110:8443
Forwarding http://dashboard-proxy.n.sltin.com -> 10.20.1.110:8443
Forwarding tcp://n.sltin.com:6666 -> 10.20.1.50:22
Web Interface 127.0.0.1:6060
# Conn 0
Avg Conn Time 0.00ms