Docker CentOS7 SoftEther VPN构造备忘录


概述

备注SoftEther VPN是在Docker环境中为我自己设置的
作为一名移动工程师,我对基础架构

并不了解

成立的目的

  • 我想要一个VPN环境,在这里我可以从公共Wifi处安心连接以学习VPN。
  • 我通常在咖啡馆学习,并且很长时间以来一直担心wifi的安全性(Wifi似乎被任何人捕获,并且可以通过http通讯等方式看到)。

设置VPN服务器安全吗?

  • 由于设置了VPN服务器,并且通过它加密了所有通信以与外界进行通信,因此即使有第三方正在使用wifi接入点监视数据包并尝试查看http通信,也将对其进行加密。
  • 首先,VPN服务器和VPN协议中都可能出现漏洞,但它们将更加安全。

尝试环境

  • 自己的PC环境

    • Mac OS Mojave 10.14
    • Docker for Mac 18.0.1-CE
    • docker-compose版本1.22.0,内部版本f46880f
  • VPN伺服器

    • SoftEther VPN v4.28-9669 linux-x64-64bit.tar.gz(2018.09.11)
    • 在Docker映像中的centos:7.5.1804之上构建
  • 使用的VPN协议

    • L2TP / IPSec
  • 实际上是某个VPS服务器设置了VPN

步骤移动

如果已安装Docker for Mac和Docker Compose,则可以仅通过docker-compose启动VPN服务器。

在适当的目录中

docker-compose.yml

1
2
3
4
5
6
7
8
version: '2'
services:
  vpn-test:
    build: .
    ports:
      - '5555:5555'
      - '500:500/udp'
      - '4500:4500/udp'
1
2
3
4
5
6
7
8
9
FROM centos:7.5.1804
ENV APP_ROOT=${APP_ROOT:-/usr/local}
WORKDIR $APP_ROOT
RUN yum -y install gcc make which net-tools
RUN curl -L https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.28-9669-beta/softether-vpnserver-v4.28-9669-beta-2018.09.11-linux-x64-64bit.tar.gz > softether-vpnserver-v4.28-9669-beta-2018.09.11-linux-x64-64bit.tar.gz
RUN tar -xvf softether-vpnserver-v4.28-9669-beta-2018.09.11-linux-x64-64bit.tar.gz
RUN cd vpnserver && make i_read_and_agree_the_license_agreement
RUN cd vpnserver && chmod 600 * && chmod 700 vpncmd && chmod 700 vpnserver
CMD ["/usr/local/vpnserver/vpnserver", "execsvc"]

准备

并按docker-compose up

这次我选择了linux,但是SoftEther本身与Windows / Mac / Linux兼容,并且Windows似乎运行最稳定。
参见此处https://ja.softether.org/4-docs/1-manual/7/7.3

连接到启动的VPN服务器

泊坞窗组成后,
连接到Docker容器

1
$ docker-compose exec vpn-test bash

从Docker容器内部连接到VPN服务器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ docker-compose exec vpn-test bash

[root@24ca9b305597 vpnserver]# cd vpnserver
[root@24ca9b305597 vpnserver]# ./vpncmd /SERVER localhost:443
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.28 Build 9669   (English)
Compiled 2018/09/11 12:23:27 by yagi at pc33
Copyright (c) SoftEther VPN Project. All Rights Reserved.

Connection has been established with VPN Server "localhost" (port 443).

You have administrator privileges for the entire VPN Server.

VPN Server>HELP

连接到VPN服务器后,HELP ?将显示命令列表

初始设定

这次只是备忘录,因此我将其省略。
必须设置VPN服务器管理密码,在与VPN连接的一侧设置帐户,创建虚拟集线器等,因此请参阅此区域
https://qiita.com/showwin/items/92861057a8b62611444d#3创建客户帐户

创建后,所有信息都将写入一个名为vpn_server.config的文件中,如果您下次启动VPN服务器时将其输入,则无需进行任何设置

客户端连接设置

要从客户端连接到VPN,请参阅此处(适用于Mac。其他设备可以由Google使用L2TP 設定 windows找到)
https://ja.softether.org/4-docs/2-howto/L2TP//IPsec_Setup_Guide_for_SoftEther_VPN_Server/5.Mac_OS_X_L2TP_Client_Setup

上瘾的备忘录

无法连接到本地构建的VPN服务器

11.1.2使用本地网桥时,如果无法从VPN内部与用于本地网桥的虚拟LAN卡的IP地址进行通信

  • https://ja.softether.org/4-docs/1-manual/B/11.1
  • 根据该区域,Linux服务器可以与本地计算机上构建的VPN服务器通信吗?我不太了解,但是当我站在外面时,我仍然可以交流

客户端日志

无法连接时,只能说"无法验证"或"无法连接到L2TP / IPSec服务器"。
如果您通过" VPN高级"选项创建详细日志,则该日志将显示在/var/log/ppp.log中。
如果响应成功来自服务器,则

1
2
3
Sun Oct 28 19:45:17 2018 : IPSec connection started
Sun Oct 28 19:45:17 2018 : IPSec phase 1 client started
Sun Oct 28 19:45:17 2018 : IPSec phase 1 server replied

返回时返回的感觉类似于

没有日志

  • 即使查看security_log,server_log,packet_log等,也不会输出任何内容。由于SoftEther最初禁用了数据包日志记录,因此我无法通过服务器端的日志检查连接。
  • 如果不是Docker,也许会出现类似/ var / log /的消息? systemctl服务无法正常工作,因此没有这样的文件