跳转至

内网穿透

一、使用SSH做端口转发

vim /etc/ssh/ssh_config
添加GatewayPorts yes
使得所有ip都能访问,不填加则只能本地访问 title

把本地80端口转发到远程服务器的12345端口,0.0.0.0都能访问

ssh -NfR 0.0.0.0:12345:localhost:80 root@lich.ml

-f 后台认证用户/密码,通常和-N连用,不用登录到远程主机
-L 将本地机(客户机)的某个端口转发到远端指定机器的指定端口
-R 将远程主机(服务器)的某个端口转发到本地端指定机器的指定端口
-N 不执行脚本或命令,通常与-f连用

远程服务器已监听12345端口 title


二、使用autossh自动连接

autossh -M 5678 -NfR 0.0.0.0:12345:localhost:80 root@lich.ml

-M 5678:通过5678端口监视连接状态,连接有问题时就会自动重连
注意配置好公钥,才能使用-f,否则不加-f则手动输入密码


三、使用lcx做端口转发

lcx –listen 80 8080
vps上监听80和8080端口
lcx –slave X.X.X.X 80 127.0.0.1 1080
将私网机器的1080端口和vps80端口绑定
http:xxxx:8080
外网用户访问vps的8080端口即可访问内网


四、开启socks5代理

ssh -p 22 -qngfNTD 0.0.0.0:1080 root@localhost

五、frp内网穿透

服务端:

frps -c frps.ini
配置文件如下:
[common]
bind_addr = 0.0.0.0
bind_port = 7000

kcp_bind_port = 7000

vhost_http_port = 82
vhost_https_port = 444

dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = xxxxxx

log_file = ./frps.log
log_level = info
log_max_days = 3

privilege_token = 2808
客户端:
frpc -c frpc.ini
配置文件如下:
server_addr = lich.gq
server_port = 7000

log_file = ./frpc.log
log_level = info
log_max_days = 3

privilege_token = 2808

admin_addr = lich.gq
admin_port = 7500
admin_user = admin
admin_pwd = xxxxxx

pool_count = 5
tcp_mux = true
user = ubuntu
login_fail_exit = true
protocol = tcp

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

[web]
type = http
local_port = 80
custom_domains = lich.gq

[leanote]
type = tcp
local_ip = 127.0.0.1
local_port = 9000
remote_port = 83