【Amazon】AWS VPN 虚拟私有网络解决方案学习笔记

文章目录

    • [AWS Client VPN实验架构图](#AWS Client VPN实验架构图)
    • [1.AWS VPN介绍](#1.AWS VPN介绍)
    • [2.AWS Client VPN系统结构](#2.AWS Client VPN系统结构)
    • [3.AWS Client VPN - 生成上传VPN证书](#3.AWS Client VPN - 生成上传VPN证书)
    • [4.AWS Client VPN - 建立 VPN 使用的 安全组](#4.AWS Client VPN - 建立 VPN 使用的 安全组)
    • [5.AWS Client VPN - 建立客户端 VPN 终端节点](#5.AWS Client VPN - 建立客户端 VPN 终端节点)
    • [6.AWS Client VPN - 关联 VPN 终端节点](#6.AWS Client VPN - 关联 VPN 终端节点)
    • [7.AWS Client VPN - 授权客户端访问网络](#7.AWS Client VPN - 授权客户端访问网络)
    • [8.AWS Client VPN - 建立授权配置文件](#8.AWS Client VPN - 建立授权配置文件)
    • [9.AWS Client VPN - 修改路由表](#9.AWS Client VPN - 修改路由表)
    • [10.AWS Client VPN - 使用 OpenVPN 连接 Client VPN 终端节点](#10.AWS Client VPN - 使用 OpenVPN 连接 Client VPN 终端节点)

AWS Client VPN实验架构图

1.AWS VPN介绍

AWS 虚拟私有网络解决方案可在您的本地网络、远程办公室、客户端设备和 AWS 全球网络之间建立安全的连接。AWS VPN 由两种服务组成:AWS Site-to-Site VPN AWS Client VPN。这两种服务一起,可提供高度可用且具有弹性的托管云 VPN 解决方案,以保护您的网络流量安全。


AWS Site-to-Site VPN 可在您的网络与 Amazon Virtual Private Cloud 或 AWS Transit Gateway 之间建立加密隧道。要管理远程访问,AWS Client VPN 可使用 VPN 软件客户端将您的用户连接到 AWS 或本地资源。

基础知识:网络安全、加密技术、AWS VPC网络概念

2.AWS Client VPN系统结构

AWS Client VPN 是一项完全托管的弹性 VPN 服务,可根据用户需求自动扩展或缩减。由于它是一个云 VPN 解决方案,因此,您无需安装和管理基于硬件或基于软件的解决方案,也无需尝试估计一次支持多少个远程用户。

参考链接:https://aws.amazon.com/cn/vpn/features/

AWS Client VPN 功能

AWS Client VPN 提供了一个完全托管的 VPN 解决方案,可通过 Internet 连接和兼容 OpenVPN 的客户端从任何位置访问。它具有出色的弹性,能够自动扩展,满足您的需求。您的用户可以连接到 AWS 网络和本地网络。AWS Client VPN 与您现有的 AWS 基础设施(包括 Amazon VPC 和 AWS Directory Service)无缝集成,因此您无需更改网络拓扑。

身份验证

AWS Client VPN 将使用 Active Directory 或证书进行身份验证。Client VPN 与 AWS Directory Service 集成,AWS Directory Service 与您现有的本地 Active Directory 相连接,因此您无需将数据从现有的 Active Directory 复制到云中。采用 Client VPN 的基于证书的身份验证与 AWS Certificate Manager 集成在一起,可轻松预置、管理和部署证书。

授权

AWS Client VPN 提供基于网络的授权,因此您可以基于 Active Directory 组定义访问控制规则,以限制对特定网络的访问。

安全连接

AWS Client VPN 使用安全的 TLS VPN 隧道协议对流量进行加密。单个 VPN 隧道在每 个Client VPN 终端节点处终止,并为用户提供访问所有 AWS 和本地资源的权限。

连接管理

您可以使用 Amazon CloudWatch Logs 从 AWS Client VPN 连接日志监控、存储和访问您的日志文件。然后,您可以从 CloudWatch Logs 中检索关联的日志数据。您可以轻松地监控、取证分析和终止特定连接,同时控制可访问您网络的用户。

与员工设备的兼容性

AWS Client VPN 旨在将设备连接到您的网络。它允许您从基于 OpenVPN 的客户端中进行选择,从而使您的员工可以使用自己选择的设备,包括 Windows、Mac、iOS、Android 和 Linux 设备。

3.AWS Client VPN - 生成上传VPN证书

参考连接:https://docs.aws.amazon.com/zh_cn/vpn/latest/clientvpn-admin/client-authentication.html

  • 在 EC2 实例中生成 VPN 服务器和客户端的证书密钥
  • 将建立的证书上传到ACM

操作演示

在 EC2 实例中,生成VPN RSA证书。

shell 复制代码
# 系统更新
$ sudo yum update -y

# 安装Git
$ sudo yum install -y git

# 将OpenVPN easy-rsa 存储库克隆到本地
$ git clone https://github.com/OpenVPN/easy-rsa.git
$ cd easy-rsa/easyrsa3

# 初始化一个新的 PKI环境(PKI:公钥基础设施)
$ ./easyrsa init-pki

# 构建新的证书颁发机构(CA)
$ ./easyrsa build-ca nopass

# 生成服务器证书和密钥
$ ./easyrsa build-server-full server.vpn.xybaws.com nopass

# 生成客户端证书和密钥
$ ./easyrsa build-client-full client1.vpn.xybaws.com nopass

# 将服务器证书和密钥和客户端证书和密钥复制到项目文件夹
$ mkdir ~/xybaws-vpn/
$ cp pki/ca.crt ~/xybaws-vpn/
$ cp pki/issued/server.vpn.xybaws.com.crt ~/xybaws-vpn/
$ cp pki/private/server.vpn.xybaws.com.key ~/xybaws-vpn/
$ cp pki/issued/client1.vpn.xybaws.com.crt ~/xybaws-vpn/
$ cp pki/private/client1.vpn.xybaws.com.key ~/xybaws-vpn/
$ cd ~/xybaws-vpn

# 将服务器证书和密钥以及客户端证书和密钥上传到 ACM
$ aws acm import-certificate \
	--certificate fileb://server.vpn.xybaws.com.crt \
	--private-key fileb://server.vpn.xybaws.com.key \
	--certificate-chain fileb://ca.crt \
	--tags Key=Name,Value=xybaws-vpn-server \
	--region ap-northeast-1
$ aws acm import-certificate \
	--certificate fileb://client1.vpn.xybaws.com.crt \
	--private-key fileb://client1.vpn.xybaws.com.key \
	--certificate-chain fileb://ca.crt \
	--tags Key=Name,Value=xybaws-vpn-client1 \
	--region ap-northeast-1

💢报错

shell 复制代码
[ec2-user@ip-172-16-10-10 xybaws-vpn]$ pwd
/home/ec2-user/xybaws-vpn
[ec2-user@ip-172-16-10-10 xybaws-vpn]$ aws acm import-certificate \
> --certificate fileb://server.vpn.xybaws.com.crt \
> --private-key filed://server.vpn.xybaws.com.key \
> --certificate-chain filed://ca.crt \
> --tags Key=Name,Value=xybaws-vpn-server \
> --region ap-northeast-1
Unable to locate credentials. You can configure credentials by running "aws configure".
[ec2-user@ip-172-16-10-10 xybaws-vpn]$

Installing or updating the latest version of the AWS CLI

shell 复制代码
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

参考链接:Installing or updating the latest version of the AWS CLI - AWS Command Line Interface

shell 复制代码
[ec2-user@ip-172-16-10-16 xybaws-vpn]$ aws configure
AWS Access Key ID [None]: AKIA****************M6
AWS Secret Access Key [None]: xDvX*********************************pFn
Default region name [None]: ap-northeast-1
Default output format [None]: json
[ec2-user@ip-172-16-10-16 xybaws-vpn]$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************2WM6 shared-credentials-file
secret_key     ****************hpFn shared-credentials-file
    region           ap-northeast-1      config-file    ~/.aws/config
[ec2-user@ip-172-16-10-16 xybaws-vpn]$ aws acm import-certificate \
> --certificate fileb://server.vpn.xybaws.com.crt \
> --private-key fileb://server.vpn.xybaws.com.key \
> --certificate-chain fileb://ca.crt \
> --tags Key=Name,Value=xybaws-vpn-server \
> --region ap-northeast-1
{
    "CertificateArn": "arn:aws:acm:ap-northeast-1:540*******692:certificate/1bf78b2b-6e05-487d-af6b-965f02d2e51d"
}
[ec2-user@ip-172-16-10-16 xybaws-vpn]$ aws acm import-certificate \
> --certificate fileb://client1.vpn.xybaws.com.crt \
> --private-key fileb://client1.vpn.xybaws.com.key \
> --certificate-chain fileb://ca.crt \
> --tags Key=Name,Value=xybaws-vpn-client1 \
> --region ap-northeast-1
{
    "CertificateArn": "arn:aws:acm:ap-northeast-1:540*******692:certificate/374b2569-18cf-4fc2-9418-ae3dbcbc6d57"
}
[ec2-user@ip-172-16-10-16 xybaws-vpn]$

4.AWS Client VPN - 建立 VPN 使用的 安全组

官方链接:https://docs.aws.amazon.com/zh_cn/vpn/latest/clientvpn-admin/client-authorization.html

VPC / 安全组 / 创建安全组

  • 安全组名称:
    • Name:xybaws-vpn-security-group
  • VPC
    • xybaws-vpc
  • 入站规则 / 添加规则
    • 所有流量
    • 0.0.0.0/0

5.AWS Client VPN - 建立客户端 VPN 终端节点

建立客户端 VPN终端节点

官网地址:https://docs.aws.amazon.com/zh_cn/vpn/latest/clientvpn-admin/cvpn-getting-started.html

操作步骤:

客户端 VPN 终端节点 > 创建客户端 VPN 终端节点

  • 名称标签

    • xybdiy-vpn
  • 客户端 IPv4 CIDR(以 CIDR 记法表示的 IP 地址范围,从该范围中为客户端分配 IP 地址。)

    • 10.0.0.0/22
  • 服务器证书 ARN

  • 身份验证选项

  • DNS服务器 1 的IP地址(VPC DNS 内部地址)

    • 172.16.0.2
  • VPC ID (与终端节点关联的 VPC,一个终端节点仅可与一个VPC相关联)

    • xybaws-vpc
  • 安全组 ID (指定特定 VPC 中的安全组以应用到客户端 VPN 终端节点)

    • xybaws-vpn-securiy-group

✨要想访问到外网,此VPC需要创建互联网网关,能访问到外网,私有网络需要设置NAT网关。客户端VPN端点中的DNS服务器地址应该设置成此VPC DNS的IP地址。✨

6.AWS Client VPN - 关联 VPN 终端节点


7.AWS Client VPN - 授权客户端访问网络

授权规则指定哪些客户端可以访问 VPC

VPC / 客户端 VPN 终端节点 / xybaws-vpc

授权 / Authorize Ingress

  • 要启动访问权限的目标网络
    • 0.0.0.0/0
  • 授权访问权限
    • 允许访问所有用户

!!!授权成功!!!

8.AWS Client VPN - 建立授权配置文件

下载客户端 ovpn 文件,建立授权配置

  • 下载客户端 ovpn文件


  • 编辑授权配置文件
bash 复制代码
<cert>
Contenets of client certificate (.crt) file
</cert>

<key>
Contents of private key (.key) file
</key>
  • 修改 DNS 名称
yml 复制代码
remote client1.cvpn-endpoint-0bebae19c3283ab85.prod.clientvpn.ap-northeast-1.amazonaws.com 443

9.AWS Client VPN - 修改路由表

修改 VPN 终端节点的路由表

VPC / 客户端 VPN 终端节点 / xybaws-vpn

路由表 / Create Route

  • 路由目标

    • 0.0.0.0/0
  • 目标 VPC 子网 ID

    • xybaws-web-1a

10.AWS Client VPN - 使用 OpenVPN 连接 Client VPN 终端节点

  • 下载 OpenVPN 客户端
  • 使用 OpenVPN 连接 Client VPN 终端节点
  • 测试 VPC内网访问

未连接VPN时,私有IP地址无法访问内网

连接VPN时,私有IP地址可以访问内网



完结🎉


相关推荐
楠了个难44 分钟前
HDMI色块移动——FPGA学习笔记13
笔记·学习
Gabriel Drop Out1 小时前
12年计算机408考研-计算机网络
网络·计算机网络
bite_joker_xue1 小时前
HCIA--实验十七:EASY IP的NAT实现
网络·tcp/ip·智能路由器
dxgzg2 小时前
ps学习。
学习
Sunsets_Red2 小时前
Linux 系统
linux·运维·服务器·c++·学习·系统架构·系统安全
北飞的山羊2 小时前
【计算机网络】详解UDP套接字&网络字节序&IP地址&端口号
linux·服务器·网络·后端·计算机网络·udp·信息与通信
mljy.2 小时前
STL简介
c++·学习
洛寒瑜2 小时前
【读书笔记-《网络是怎样连接的》- 0】全书整体结构
网络·网络是怎样连接的
会蹦的鱼4 小时前
React学习day07-ReactRouter-抽象路由模块、路由导航、路由导航传参、嵌套路由、默认二级路由的设置、两种路由模式
javascript·学习·react.js
Miraitowa_cheems5 小时前
[JavaEE] UDP协议
网络·tcp/ip·java-ee