本文及资源最后更新时间 2020-06-29 by sky995
内网穿透对于很多人来说,都是必不可少的,他可以让你在家访问公司电脑,或者在公司取家里电脑上的文件,简直是灰常方便有木有。国内的内网穿透服务大部分都是收费的,要么就是带宽很小卡顿感很严重。
前言
之前小编搭建的nps,也是github 获赞最多的开源内网穿有服务程序,采用Go语言开发,搭建非常简单,但是我测试有一个严重的问题:时间长了总是休眠断链。于是就放弃了。
本次我推荐的是一款采用java开发:lanproxy
,同样是开源的内网穿透程序,经过一个月的测试,稳定性相当好,个人测试只要网络环境正常从来没有断过。本次我就教大家如何使用自己的vps搭建内网穿透服务。
下载编译包
去GitHub
下载编译包(服务端和客户端):博主使用的是Linux CentOS服务端
和Windows客户端
,下载对应的程序:
部署服务端
下载完成后,将proxy-server-0.1.zip
解压然后找到proxy-server-0.1\conf\
下的config.properties
,使用编辑器打开修改配置
<code class=" language-properties"><span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">bind</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span></span> <span class="token comment"><span class="com">#与代理客户端通信端口</span></span> <span class="token comment"><span class="com">#这个端口是指客户端连接时对应的端口</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">port</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">4900</span></span> <span class="token comment"><span class="com">#ssl相关配置</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">enable</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="kwd">false</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">bind</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">port</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">4993</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">jksPath</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="pln">test</span><span class="pun">.</span><span class="pln">jks</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">keyStorePassword</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">123456</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">keyManagerPassword</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">123456</span></span> <span class="token comment"><span class="com">#这个配置可以忽略</span></span> <span class="token attr-name"><span class="pln">server</span><span class="pun">.</span><span class="pln">ssl</span><span class="pun">.</span><span class="pln">needsClientAuth</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="kwd">false</span></span> <span class="token comment"><span class="com">#WEB在线配置管理相关信息</span></span> <span class="token comment"><span class="com">#服务端ip地址一般不用修改默认就好</span></span> <span class="token attr-name"><span class="pln">config</span><span class="pun">.</span><span class="pln">server</span><span class="pun">.</span><span class="pln">bind</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span></span> <span class="token comment"><span class="com">#后台控制面板端口(如果有防火墙,请放行)</span></span> <span class="token attr-name"><span class="pln">config</span><span class="pun">.</span><span class="pln">server</span><span class="pun">.</span><span class="pln">port</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="lit">8090</span></span> <span class="token comment"><span class="com">#后台控制面板账号密码</span></span> <span class="token attr-name"><span class="pln">config</span><span class="pun">.</span><span class="pln">admin</span><span class="pun">.</span><span class="pln">username</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="pln">admin</span></span> <span class="token attr-name"><span class="pln">config</span><span class="pun">.</span><span class="pln">admin</span><span class="pun">.</span><span class="pln">password</span></span><span class="token punctuation"><span class="pun">=</span></span><span class="token attr-value"><span class="pln">admin</span></span></code>
修改完后吧解压的程序上传到你的服务器上任意目录,如/data
,把程序和子目录都给777
权限
然后使用命令行进入你上传程序目录下的/bin
执行startup.sh
启动服务
<code class=" language-shell"><span class="pun">[</span><span class="pln">root@10</span><span class="pun">-</span><span class="lit">9</span><span class="pun">-</span><span class="lit">50</span><span class="pun">-</span><span class="lit">195</span><span class="pln"> bin</span><span class="pun">]</span><span class="com"># cd /data/proxy-server-0.1/bin</span> <span class="pun">[</span><span class="pln">root@10</span><span class="pun">-</span><span class="lit">9</span><span class="pun">-</span><span class="lit">50</span><span class="pun">-</span><span class="lit">195</span><span class="pln"> bin</span><span class="pun">]</span><span class="com"># ./startup.sh</span> <span class="typ">Starting</span><span class="pln"> the proxy server </span><span class="pun">...</span><span class="pln">started PID</span><span class="pun">:</span> <span class="lit">13314</span> <span class="pun">[</span><span class="pln">root@10</span><span class="pun">-</span><span class="lit">9</span><span class="pun">-</span><span class="lit">50</span><span class="pun">-</span><span class="lit">195</span><span class="pln"> bin</span><span class="pun">]</span><span class="com"># </span></code>
如上代码,服务端就算搭建成功了,打开地址 http://ip:8090进入控制台(这里的8090是你刚才设置的控制面板端口) 。
服务端配置
登录后台添加你的客户端:
然后在配置管理
就会出现你添加的客户端,对你的客户端添加配置
,服务端的配置就算完成了。
客户端链接
这里举个例子:比如我想用A
电脑访问B
电脑的文件
在B
电脑上解压刚才下载的客户端文件lanproxy-client-windows-amd64-20190523.tar
,解压后会看到有一个client_windows_amd64.exe
文件。接下来打开cdm进入你解压的client_windows_amd64.exe
目录执行如下命令:
<code class=" language-shell"><span class="pln">client_windows_amd64</span><span class="pun">.</span><span class="pln">exe </span><span class="pun">-</span><span class="pln">s </span><span class="lit">123.123</span><span class="pun">.</span><span class="lit">66.666</span> <span class="pun">-</span><span class="pln">p </span><span class="lit">4900</span> <span class="pun">-</span><span class="pln">k e05f2ce5737644bc959f017a6bacf851</span></code>
说明:
123.123.66.666
是你服务端的IP4900
是你配置文件的与代理客户端通信端口e05f2ce5737644bc959f017a6bacf851
是你在控制台创建客户端时的密码
如上图,代表映射成功。然后去我们的控制台看一下我们刚才添加的客户端,已经显示在线了。
这样,我们就可以直接使用B
电脑访问你服务端ip:你设定的端口
就可以访问A
电脑了