实现 Azure VPN 选项

已完成

Contoso 的数据中心支持远程连接,使用户能够远程工作。 并且一些分支机构通过站点到站点 VPN 连接到总部数据中心。 作为首席系统工程师,你必须实现一个能够对当前使用场景提供持续支持的 VPN 解决方案。

VPN 网关设计

使用 Azure 网关,你可以实现下面各种类型的 VPN 连接,以满足组织的需求:

  • S2S
  • 多站点
  • P2S
  • VNet 到 VNet

站点到站点

你通过 Internet 协议安全性 (IPsec)/Internet 密钥交换 (IKE) 实现 S2S 连接。 并使用 S2S 连接来支持跨界和混合配置。 要实现 S2S 连接,必须有一个具有公共 IP 地址的 VPN 设备,如下图所示。

A diagram of a typical S2S VPN configuration. A VNet (IP: 10.10.0.0/16) labelled VNet1 connects via a VPN Gateway device (IP: 131.1.1.) through an IPsec/IKE VPN tunnel to a VPN device (IP: 33.2.1.5) in LocalSite1 at the head office.

多站点

多站点连接是 S2S 连接的变体。 使用此连接类型,可以创建多个来自 VNet 网关的 VPN 连接。 实现多站点连接时,必须使用基于路由的 VPN 类型。

顾名思义,此连接类型通常用于连接多个本地站点,如下图所示。

A diagram of a typical multi-site VPN configuration. VNet1 in US West connects through a VPN Gateway (IP: 131.1.1.1). The gateway has two IPsec/IKE VPN tunnels. One connects to LocalSite1(IP: 128.8.8.8), and the other to LocalSite2 (IP: 139.9.9.9).

提示

一个 VNet 只能有一个 VPN 网关,因此所有连接共享带宽。

点到站点

P2S VPN 连接使用户能够从远程网络(如其家庭或公共 Wi-Fi 热点)连接到组织。 用户通常会发起 P2S 连接,如下图所示。 在此图中,两名用户发起安全套接字隧道协议 (SSTP) 连接,另一名用户使用 IKEv2。 不同于 S2S 连接,你不需要用本地公共 IP 地址或 VPN 设备来实现 P2S 连接。

A diagram of a typical P2S configuration. VNet1 in East US connects to a VPN gateway (IP: 131.1.1.1). Three VPN tunnels are connected inbound to the VPN gateway. Two are of type SSTP while the third is IKEv2. Clients users and devices are displayed on the far side of the tunnel, each with a private IP address allocated from a pool.

提示

可以通过同一个 VPN 网关将 P2S 连接和 S2S 连接一起使用。

VNet 到 VNet

实现 VNet 到 VNet 连接在某些方面类似于将单个 VNet 连接到本地站点位置 (S2S)。 在这两种情况中,你都是使用 VPN 网关来实现 IPsec/IKE 隧道。

备注

通过 VPN 网关实现 VNet 到 VNet 连接时,VNet 不需要位于相同 Azure 区域或订阅中。

提示

还可以使用对等互连来连接 VNet,无需考虑位置或订阅。 此方法可能速度更快、更具资源效率。

A diagram of a typical Vnet-to-Vnet connection. VNet1 in East US connects through a VPN Gateway (IP: 131.1.1.1). An IPsec/IKE tunnel connects to a VPN Gateway (IP: 151.2.2.2) which resides on the edge of VNet4, West US region.

ExpressRoute 连接

你可以使用 Azure ExpressRoute 连接帮助实现从本地网络到 Microsoft 云或到组织中的其他站点的专用连接。 网络连接是专用的,因此更安全,还可能带来显著的性能优势。 你使用 VNet 网关配置 ExpressRoute 连接。 但对于 ExpressRoute 连接,应使用 ExpressRoute 这种网关类型来配置 VNet 网关,而不是使用 VPN。

提示

虽然经由 ExpressRoute 线路的流量是默认不加密的,但你可以配置用于发送加密流量的连接。

还可以合并 ExpressRoute 和 S2S 连接,如下图所示。 例如,可以配置 S2S VPN:

  • 作为 ExpressRoute 的安全故障转移路径。
  • 以连接不属于自己的网络但通过 ExpressRoute 连接的站点。

A diagram of a dual connection from VNet1, East US, via both an ExpressRoute gateway and a VPN Gateway (IP: 131.1.1.1). The ExpressRoute connection provides private connectivity to On-premises HQ site (IP: 141.4.4.4). The HQ site also has an IPsec/IKE tunnel that connects to VNet1. Finally, VNet1 uses the VPN Gateway to connect to LocalSite2 through an IPsec/IKE tunnel..

实现 VPN 网关

配置 VPN 网关时,你必须选择并配置许多设置。 首先,必须确定是要实现基于策略还是路由的配置。

基于策略

如果选择实现基于策略的网关(以静态路由为基础),你必须定义该网关用于确定数据包目标的 IP 地址集。 此网关根据这些 IP 地址集评估每个数据包,以确定用于数据包加密和路由的隧道。

基于路由

你可以使用基于路由的网关,以免必须定义每个隧道后的 IP 地址。 使用基于路由的网关,IP 路由确定通过哪一个隧道接口发送每个数据包。

提示

应当为本地设备选择基于路由的 VPN,因为它们对拓扑更改(例如在 VNet 中创建新子网)更具弹性。

应始终为以下类型的连接选择基于路由的 VPN 网关:

  • 虚拟网络之间的连接
  • P2S 连接
  • 多站点连接
  • 与 Azure ExpressRoute 网关共存

其他设置

此外,还必须为实现 VPN 网关定义以下设置:

  • VPN 或 ExpressRoute。 选择连接的基本类型。
  • 网关子网地址范围。 指定与 VPN 网关关联的专用 IP 地址范围。
  • 公共 IP 地址。 指定与 VPN 网关关联的公共 IP 地址对象。

创建 VNet

若要实现 VPN 网关,必须具有 VNet。 可以在配置 VPN 网关之前或配置过程中创建 VNet。 我们首先将创建一个。 为此,请打开 Azure 门户并完成以下过程:

  1. 选择“创建资源”,然后搜索并选择“虚拟网络”。

  2. 在“虚拟网络”边栏选项卡上选择“创建”。

  3. 通过指定相应属性(订阅、资源组、名称和区域)来创建 VNet。

    A screenshot of the Create a virtual network page. The administrator has defined the subscription, and selected the ContosoResourceGroup. The VNet name is ContosoVPN1 in the East US region.

  4. 选择“下一步: IP 地址 >”。

  5. 通过接受默认设置或配置自己的设置来配置要与 VNet 关联的子网。

  6. 选择“查看 + 创建”,然后选择“创建”。

创建网关

创建相应的 VNet 后,现在必须创建 VPN 网关。 例如,若要使用 Azure 门户创建基于路由的 VPN 网关,请使用以下过程:

  1. 在 Azure 门户中,搜索并选择“虚拟网关”。

  2. 在“虚拟网关”边栏选项卡上,选择“创建”。

  3. 在“创建虚拟网关”边栏选项卡上,通过指定相应的属性(订阅、名称和区域)来创建网关。

  4. 然后选择是要实现 VPN 连接还是 ExpressRoute 连接。

  5. 对于 VPN,选择“基于路由”或“基于策略”。

    A screenshot of the Create a virtual network gateway page. The administrator has defined the subscription. The Name is ContosoVPNGateway, in the East US region. Gateway type is VPN, and VPN type is Route-based.

  6. 选择之前创建的虚拟网络。

  7. 配置“网关子网地址范围”和“公共 IP 地址”设置。

    A screenshot of the Create a virtual network gateway page. The administrator has selected the Gateway subnet address range (10.3.1.0/24) and has opted to create a new Public IP address called ContosoVPNPublic. Other options are disabled..

  8. 选择“查看 + 创建”,然后选择“创建”。

试试看

如果要使用 Azure VPN,请尝试这些实验室练习。 练习基于沙盒环境,无需 Azure 订阅即可完成: