ICode9

精准搜索请尝试: 精确搜索
首页 > 互联网> 文章详细

穿透内网实现从外网远程桌面或ssh到内网x Vtamins的博客

2018-12-06 16:34:18  阅读:1192  来源: 互联网

标签:


版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014762921/article/details/50976130

本人读研中,妹纸在工作。和妹纸在外面租房住,此时遇到一个大问题,我现在学习压力大,常常回到家也要远程到实验室,或者git取实验室的项目。但是,实验室的平台在内网,又没有外网ip,于是乎,苦思良久,终于在朋友的帮助下成功穿越内网,远程到实验室的内网,同时可以用git 和maven、远程桌面等。

需要的工具:softether client 、softeher server、带外网ip的vps一台。

下面就开始了。

阿里云搞学生计划,vps10元一月,带ipv4一个,性能比较一般,网速1m

softether vpn可以翻墙到官网下载。



下面动作开始了(这里以vps操作系统为linux为举例):

1.上传softeher vpn server 安装文件到vps,本人的机器是centos6

用winscp连接你的vps ,将softether vpn server 文件上传到root目录下并解压。



解压tar zxvf

出现一个vpnserver的目录文件。

请容我搬运以下代码:

cd vpnserver
sudo make i_read_and_agree_the_license_agreement
//然后运行
./vpnserver start
//然后设置你的vpn server 
./vpncmd
设置好连接密码。至此,命令符操作部分结束,后面可以 用图形界面操作了。

eg:

root@server:~/vpnserver# ./vpncmd
vpncmd command - SoftEther VPN Command Line Management UtilitySoftEther VPN Command Line Management Utility (vpncmd command)Version 4.10 Build 9473   (English)Compiled 2014/07/12 02:33:15 by yagi at pc26
Copyright (c) SoftEther VPN Project. All Rights Reserved.By using vpncmd program, the following can be achieved. 
1. Management of VPN Server or VPN Bridge 
2. Management of VPN Client3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool)Select 1, 2 or 3: [在这里输入1]Specify the host name or IP address of the computer that the destination VPN Server or VPN Bridge is operating on. 
By specifying according to the format 'host name:port number', you can also specify the port number. 
(When the port number is unspecified, 443 is used.)If nothing is input and the Enter key is pressed, the connection will be made to the port number 8888 of localhost (this computer).Hostname of IP Address of Destination:[在这里敲回车键] 
If connecting to the server by Virtual Hub Admin Mode, please input the Virtual Hub name. 
If connecting by server admin mode, please press Enter without inputting anything.Specify Virtual Hub Name: [在这里敲回车键] 
Connection has been established with VPN Server "localhost" (port 443).You have administrator privileges for the entire VPN Server.
VPN Server>[输入ServerPasswordSet]ServerPasswordSet command - Set VPN Server Administrator PasswordPlease enter the password. To cancel press the Ctrl D key.Password: [输入你的密码]Confirm input: [再次输入你的密码]
(此段从别人论坛贴过来的,声明一下,地址http://www.freebuf.com/tools/40418.html)

2.设置你的windows server并与vps上的 server桥接。

在你的 要穿透的内网的电脑上安装 softether vpn server,打开

server manager。


需要添加两个 server 一个是你本地刚刚安装的,一个是你vps刚刚安装的server


本地的勾选localhost就可以了,刚才vps上的,填上你的vps地址,并输入刚才设置server管理密码。

1)连接你的vps上的server并新建一个hub。


增加一个用户,


设置dhcp服务器,此处很重要要按照我设置(跟我一模一样的设置就行)。




2)断开连接,连接你本地的 server。

管理你的default hub。

管理你的级联接。


新建一个连接到你的vps,刚才新建的hub(要输入刚才增加的账户与密码),并启用。

开启本地dhcp服务。

按照我给的图的配置,出错了就连不上。


3.最后一步

此时你离成功已经非常近了。

用你处于外网的电脑,安装 softether vpn client

添加一个vpn连接,到vps的上的被级联的hub。

成功获取到ip。


大功告成。

试一下ping内网


用阿里云做中转 延迟大概100左右(主要是学生优惠节点比较慢,试过搞网速的节点,延迟30左右)

至此

可以用git 可以用 maven 可以用 ssh 可以用 远程桌面 可以用 ……

原理解释:通过在vps建立一个虚拟hub,也就是虚拟路由,内网机器建立一个虚拟路由vps上的虚拟路由连接。

通过nat,我们访问的 时候,从外网到vps再到内网,来进行数据的通讯。

标签:
来源: https://blog.csdn.net/u014762921/article/details/50976130

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有