虚拟私有网络简介

详细介绍参见 虚拟私有网络学习笔记
虚拟私有网络分类
按协议分类:
虚拟私有网络 的隧道协议主要有三种,PPTP、L2TP 和 IPSec,
其中 PPTP 和 L2TP 协议工作在 OSI 模型的第二层,又称为二层隧道协议;IPSec 是第三层隧道协议。
PPTP(Point to Point Tunneling Protocol),即点对点隧道协议
L2TP 是一种工业标准的 Internet 隧道协议,功能大致和 PPTP 协议类似,比如同样可以对网络数据流进行加密。

  • PPTP 要求网络为 IP 网络,L2TP 要求面向数据包的点对点连接;
  • PPTP使用单一隧道,L2TP 使用多隧道;
  • L2TP 提供包头压缩、隧道验证,而 PPTP 不支持

IPSec(InternetProtocolSecurity) 是一种开放标准的安全通信协议簇,通过使用加密的安全服务确保在Internet 协议 (IP) 网络上迚行保密而安全的通讯。

按用途分类:

  • Access (远程接入):客户端到网关,使用公网作为骨干网在设备间传输 加密数据流量;
  • Intranet (内联网 ):网关到网关,通过公司的网络架构连接来自同公司的资源;
  • Extranet (外联网 ):与合作伙伴企业网构成 Extranet,将一个公司同另一个公司的资源迚行连接

Linux 下常用的 虚拟私有网络 软件
1、OpenV拼:
OpenV拼是一款在 Linux 网关服务器使用的开源的 虚拟私有网络 软件,用来打通一条安全的虚拟与用通道,实现用户进程办公,获取内网资源。
该软件可跨平台在在 Linux、xBSD、Mac OS X 不 Windows 间使用,并利用 openssl 作为加密库,使用加密证书或用户名/密码来实现身份验证,是一款不可多得的开源 VPN 解决方案。
2、SoftEther :
SoftEther 是日本筑波大学的一个研究项目,是一个开放源代码的跨平台多协议 虚拟私有网络程序,它包括服务器端、客户端、服务器端管理工具等数个软件,支持 SSL 协议、 L2TP/IPsec 协议、 Open拼 协议和 Microsoft SSTP 协议,Windows、linux、Android 和 IOS 等操作系统都可以连接到 SoftEther 服务器

部署配置服务器端

准备一台虚拟机
准备一台虚拟机 我们这里使用vmware 安装的centos7.8 内存3G 硬盘20G

安装依赖库

[root@localhost ~]# yum -y install gcc zlib-devel openssl-devel readline-devel ncurses-devel

Installed:
  ncurses-devel.x86_64 0:5.9-14.20130511.el7_4  openssl-devel.x86_64 1:1.0.2k-25.el7_9  readline-devel.x86_64 0:6.2-11.el7 

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7  krb5-devel.x86_64 0:1.15.1-54.el7_9   libcom_err-devel.x86_64 0:1.42.9-19.el7 
  libkadm5.x86_64 0:1.15.1-54.el7_9         libselinux-devel.x86_64 0:2.5-15.el7  libsepol-devel.x86_64 0:2.5-10.el7      
  libverto-devel.x86_64 0:0.2.5-4.el7       pcre-devel.x86_64 0:8.32-17.el7      

Updated:
  zlib-devel.x86_64 0:1.2.7-20.el7_9                                                                                       

Dependency Updated:
  e2fsprogs.x86_64 0:1.42.9-19.el7         e2fsprogs-libs.x86_64 0:1.42.9-19.el7    krb5-libs.x86_64 0:1.15.1-54.el7_9   
  libcom_err.x86_64 0:1.42.9-19.el7        libss.x86_64 0:1.42.9-19.el7             openssl.x86_64 1:1.0.2k-25.el7_9     
  openssl-libs.x86_64 1:1.0.2k-25.el7_9    zlib.x86_64 0:1.2.7-20.el7_9            

Complete!

下载softether安装包
这里使用已经下载好的软件包,点击softether 下载
也可以到官网下载:
http://www.softether-download.com/files/softether/v4.23-9647-beta-2017.10.18-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.23-9647-beta-2017.10.18-linux-x64-64bit.tar.gz

上传程序包到虚拟机

[root@localhost ]# ll
total 29120
-rw-r--r--. 1 root root 23550997 Mar  7 12:18 softether-vpn_admin_tools-v4.22-9634-beta-2016.11.27-win32.zip
-rw-r--r--. 1 root root  6264293 Mar  7 12:18 softether-vpnserver-v4.20-9608-rtm-2016.04.17-linux-x64-64bit.tar.gz

解压vpnserver程序包

[root@localhost ]# tar -zvxf softether-vpnserver-v4.20-9608-rtm-2016.04.17-linux-x64-64bit.tar.gz 
......
[root@localhost vpn]# ll
total 29120
-rw-r--r--. 1 root root 23550997 Mar  7 12:18 softether-vpn_admin_tools-v4.22-9634-beta-2016.11.27-win32.zip
-rw-r--r--. 1 root root  6264293 Mar  7 12:18 softether-vpnserver-v4.20-9608-rtm-2016.04.17-linux-x64-64bit.tar.gz
drwxrwxrwx. 4 root root      265 Apr 17  2016 vpnserver

开始安装

[root@localhost vpn]# cd vpnserver/
[root@localhost vpnserver]# ll
total 1456
-rwxrwxrwx. 1 root root    1881 Apr 17  2016 Authors.txt
drwxrwxrwx. 2 root root      41 Apr 17  2016 code
-rwxrwxrwx. 1 root root 1295106 Apr 17  2016 hamcore.se2
drwxrwxrwx. 2 root root     170 Apr 17  2016 lib
-rwxrwxrwx. 1 root root    2138 Apr 17  2016 Makefile
-rwxrwxrwx. 1 root root   30801 Apr 17  2016 ReadMeFirst_Important_Notices_cn.txt
-rwxrwxrwx. 1 root root   36297 Apr 17  2016 ReadMeFirst_Important_Notices_en.txt
-rwxrwxrwx. 1 root root   50695 Apr 17  2016 ReadMeFirst_Important_Notices_ja.txt
-rwxrwxrwx. 1 root root   58932 Apr 17  2016 ReadMeFirst_License.txt
[root@localhost vpnserver]# make
.....
期间出现选项都输入1
......
*** How to switch the display language of the SoftEther VPNServer Service ***
SoftEther VPN Server supports the following languages:
  - Japanese
  - English
  - Simplified Chinese

You can choose your prefered language of SoftEther VPN Server at any time.
To switch the current language, open and edit the 'lang.config' file.


*** How to start the SoftEther Server Service ***

Please execute './vpnserver start' to run the SoftEther Server Background Service.
And please execute './vpncmd' to run the SoftEther Command-Line Utility to configure SoftEther Server.
Of course, you can use the VPN Server Manager GUI Application for Windows on the other Windows PC in order to configure the SoftEther Server remotely.
--------------------------------------------------------------------

make[1]: Leaving directory `/root/vpn/server'

启动vpnserver

[root@localhost server]# ./server start
The SoftEther Server service has been started.

设置vpn管理员密码

[root@localhost server]# ./vpncmd 
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.20 Build 9608   (English)
Compiled 2016/04/17 21:59:35 by yagi at pc30
Copyright (c) SoftEther Project. All Rights Reserved.

By using vpncmd program, the following can be achieved. 

1. Management of Server or VPN Bridge 
2. Management of Client
3. Use of Tools (certificate creation and Network Traffic Speed Test Tool)

Select 1, 2 or 3: 1   -------------这里选择1 回车

Specify the host name or IP address of the computer that the destination Server or 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  Server "localhost" (port 443).

You have administrator privileges for the entire Server.

Server>ServerPasswordSet
ServerPasswordSet command - Set  Server Administrator Password
Please enter the password. To cancel press the Ctrl+D key.

Password: ******        ----------------输入两次密码 就可以设置成功
Confirm input: ******


The command completed successfully.

创建虚拟HUB

Server>HubCreate MOB   --------创建MOB 这个虚拟hub
HubCreate command - Create New Virtual Hub
Please enter the password. To cancel press the Ctrl+D key.
----------输入管理员密码后创建成功
Password: ******
Confirm input: ******
The command completed successfully.

退出管理程序

 Server>exit
You have new mail in /var/spool/mail/root
[root@localhost server]# 

虚拟 HUB功能说明
虚拟 HUB 就是我们的虚拟局域网
"softether"是一个能虚拟网卡和集线器(HUB)的工具,只要可以访问互联网,都可以使用它来组建虚拟局域网。在此虚拟的局域网上能迚行所有物理局域网上的操作。可以互相访问,可以联网玩支持局网的游戏(TCP/IP)。
该软件能够突破防火墙拦戔,信息包都经过加密,安全上丌存在问题。
SoftEther 分为虚拟集线器(HUB)和虚拟网卡两部分,使用服务器/客户端的方式工作时,虚拟集线器就是服务器,虚拟网卡就是客户端。客户端连接时利用 SoftEther 提供的连接管理工具将虚拟网卡连接到服务端的虚拟集线器上,这样你的计算机就相当于接入了虚拟集线器构建的局域网,可以访问该虚拟局域网内的其他计算机。

使用管理软件管理vpn服务器

准备一台win7虚拟机
在这里插入图片描述
将截图中的软件上传到 win7虚拟机中 ,并解压 找到并运行vpnsmgr.exe 文件
在这里插入图片描述
双击运行
在这里插入图片描述
配置链接信息

点击【新设置】
在目标 VPN Server 的主机名输入服务器 IP,端口号默认 443,中继代理服务器选择TCP/IP 连接,如果有代理的话,可以选择自己对应的代理服务类型,填写相关的服务器 IP,端口 ,用户名,密码;
选择管理模式并输入密码,点击【虚拟 HUB 管理模式】,虚拟 HUB 名选择上文在服务器建好的名称,MOB,然后输入vpn管理员管理密码,点击【确定】
在这里插入图片描述
选择新建的配置 点击【连接】就可以进入配置页面
在这里插入图片描述
新建用户
连接成功进入管理界面,选中虚拟hub 点击【管理虚拟HUB】弹出管理页面,再点击【管理用户】弹出用户管理界面
在这里插入图片描述
点击【新建】 输入用户名 user1 密码 123456 点【确定】
在这里插入图片描述
提示用户创建成功 ,并且用户列表中可以看到该用户。点击【关闭】关闭用户管理界面。

在这里插入图片描述
启动 SecyreNAT,开启 NAT 转换和 DHCP 服务
在使用客户端登录之前,还需要启劢 SecyreNAT 服务。
在管理虚拟 HUB-MOB 界面,点击【虚拟 NAT 和虚拟 DHCP 服务器】,在弹出的设置界面点击【启用 secyreNAT】即可。

在这里插入图片描述
启用完成后界面如下
在这里插入图片描述
可以看到secureNAT的配置信息系如下
在这里插入图片描述
配置完成关闭配置页面

安装客户端并进行连接测试

上传客户端软件
将下载好的客户端软件(softether-vpnclient-v4.20-9608-rtm-2016.04.17-windows-x86_x64-intel.exe)上传到win7虚拟机,并安装

客户端安装
双击开始安装,选择 安装 client 下一步
在这里插入图片描述
同意相关协议并一直点击【下一步】便可完成安装
在这里插入图片描述

运行client管理工具
安装完成后,双击快捷方式便可运行客户端工具。
在这里插入图片描述
双击【添加新的VPN连接】 点击【确定】就会自动创建一个新的网卡适配器

在这里插入图片描述
在这里插入图片描述
空白处右击,选择 【新 VPN 连接设置向导】进行如下配置,点击【确定】
在这里插入图片描述

设置完成后 双击连接 便可 建立连接。同时提示分配的ip
在这里插入图片描述

如果vin7 和softether server的时间不同步,那么就会出现连接失败。
只需要同步二者的时间即可,windows直接同步internet时间
centos执行如下命令

[root@localhost vpnserver]#  service ntpd stop
Redirecting to /bin/systemctl stop ntpd.service
You have new mail in /var/spool/mail/root
[root@localhost vpnserver]# ntpdate time.windows.com
21 Jul 00:13:20 ntpdate[2372]: step time server 52.231.114.183 offset 4447363.047880 sec
[root@localhost vpnserver]# date
Thu Jul 21 00:13:23 +08 2022
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐