
SoftEtherVPN是由 日本筑波大学 (University of Tsukuba) 的登 大遊 (Daiyu Nobori)在硕士论文中提出的开源、跨平台、多重协议的虚拟专用网方案。
本文以 64 位 CentOS 7 安装环境为例,讲解如何安装 SoftEtherVPN Server For Linux。
第一部分:安装 SoftEtherVPN Server
安装编译环境
yum -y install gcc
从 SoftEther 下载中心下载 SoftEtherVPN Server For Linux
wget http://www.softether-download.com/files/softether/v4.30-9696-beta-2019.07.08-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.30-9696-beta-2019.07.08-linux-x64-64bit.tar.gz
或者从 GitHub 下载 SoftEtherVPN Server For Linux
wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.30-9696-beta/softether-vpnserver-v4.30-9696-beta-2019.07.08-linux-x64-64bit.tar.gz
解压文件
tar -zxvf softether-vpnserver-*.tar.gz
进入到解压目录
cd vpnserver
启动安装脚本
./.install.sh
阅读 License,根据提示,输入“1”然后回车确认。
如果提示不识别某些命令比如 gcc,另行安装即可。如果没有异常则说明安装成功。
启动服务
./vpnserver start
(停止服务命令为:./vpnserver stop
)
在 CentOS 7 系统中可以用 systemd 启动 vpnserver,先新建启动脚本 /etc/systemd/system/vpnserver.service:
[Unit]
Description=SoftEther VPN Server
After=network.target
[Service]
Type=forking
ExecStart=/root/vpnserver/vpnserver start
ExecStop=/root/vpnserver/vpnserver stop
[Install]
WantedBy=multi-user.target
然后就可以通过 systemctl start vpnserver
启动了,并通过 systemctl enable vpnserver
设置开机自启。
启动成功后我们需要设置远程登录密码以便本地管理服务。运行下面的命令进入 VPN 的命令行:
./vpncmd
选择 1. Management of VPN Server or VPN Bridge
这里需要选择地址和端口。默认 443 端口,如果需要修改,可以输入 localhost:5555(实际端口),然后出现:
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:
这里就是指定一个虚拟 HUB 名字,用默认的直接回车就行。
Connection has been established with VPN Server "localhost" (port 5555).
You have administrator privileges for the entire VPN Server.
VPN Server>
这时我们需要输入 ServerPasswordSet 命令设置远程管理密码,确认密码后就可以通过 Windows 版的 SoftEther VPN Server Manager 远程管理了。
第二部分:VPN 管理
首先下载并安装SoftEther VPN Server Manager,安装之后运行它:
在这里点新建:
Host Name 填服务器的地址或域名,端口如果之前改过了在这也记得改过来,右下角的密码填之前设置过的密码。新建完成后 Connect 就会弹出 Easy Setup 窗口(如果提示连不上请检查一下服务器的防火墙设置):
这里在第一个远程连接挑钩然后下一步即可,虚拟 HUB 名像之前一样默认就好。
然后会弹出一个动态 DNS 功能的窗口,由于不能确定它给的域名是不是被墙了,我们就不去用它,把这个窗口关了就行了。
之后会有一个协议设置的窗口:
这里把启用 L2TP 挑上钩,下面设置一个 IPsec 预共享密钥就行了。
之后又会弹出一个 VPN Azure Cloud 服务的窗口,感觉没什么用,禁用了就行了。即使有用以后也可以再启用。
接下来要新建用户:
其中用户名是必填的,验证类型选密码验证就行,然后在右侧设置用户密码。
之后回到管理界面,点管理虚拟 HUB:
点虚拟 NAT 和虚拟 DHCP 服务器,弹出窗口:
在里面启用 SecureNAT 并点 SecureNAT 配置:
注意 DNS 要改为 8.8.8.8 和 8.8.4.4。这里就算配置完毕。然后顺便生成一下 OpenVPN 的配置文件,点 OpenVPN / MS-SSTP Setting:
然后点击新窗口中部的按钮生成配置文件:
打开导出的压缩包会看到里面有两个.ovpn 文件,一般我们要用到 *_openvpn_remote_access_l3.ovpn 这个文件,因为我们是通过 IPv4 地址管理的 VPN,所以这个配置文件里的 remote 一项会是 IPv4 地址,如果需要使用 IPv6 的 VPN 就将其替换为相应的 IPv6 地址即可。
微信扫描下方的二维码阅读本文