验证 VPN 网关连接Verify a VPN Gateway connection

本文介绍如何验证经典部署模型和 Resource Manager 部署模型的 VPN 网关连接。This article shows you how to verify a VPN gateway connection for both the classic and Resource Manager deployment models.

Azure 门户Azure portal

在 Azure 门户中,可通过导航到连接来查看 Resource Manager VPN 网关的连接状态。In the Azure portal, you can view the connection status of a Resource Manager VPN Gateway by navigating to the connection. 以下步骤演示导航到连接并进行验证的一种方法。The following steps show one way to navigate to your connection and verify.

  1. Azure 门户中,单击“所有资源”,并导航到虚拟网络网关。 In the Azure portal, click All resources and navigate to your virtual network gateway.

  2. 在“虚拟网络网关”边栏选项卡中,单击“连接”。 On the blade for your virtual network gateway, click Connections. 可查看每个连接的状态。You can see the status of each connection.

    查看连接

  3. 单击想要验证的连接的名称。Click the name of the connection that you want to verify. 在“概要”中,可以查看有关连接的详细信息。In Essentials, you can view more information about your connection. 成功连接后,“状态”值将是“成功”和“已连接”。The Status values are 'Succeeded' and 'Connected' when you have made a successful connection.

    验证连接

PowerShellPowerShell

若要使用 PowerShell 验证资源管理器部署模型的 VPN 网关连接,请安装最新版本的 Azure 资源管理器 PowerShell cmdletTo verify a VPN gateway connection for the Resource Manager deployment model using PowerShell, install the latest version of the Azure Resource Manager PowerShell cmdlets.

可以验证连接是否成功,方法是使用“Get-AzVirtualNetworkGatewayConnection”cmdlet,带或不带“-Debug”。You can verify that your connection succeeded by using the 'Get-AzVirtualNetworkGatewayConnection' cmdlet, with or without '-Debug'.

  1. 使用以下 cmdlet 示例,配置符合自己需要的值。Use the following cmdlet example, configuring the values to match your own. 如果出现提示,请选择“A”运行“所有”。If prompted, select 'A' in order to run 'All'. 在此示例中,“ -Name”是指要测试的连接的名称。In the example, '-Name' refers to the name of the connection that you want to test.

    Get-AzVirtualNetworkGatewayConnection -Name VNet1toSite1 -ResourceGroupName TestRG1
    
  2. cmdlet 运行完毕后,查看该值。After the cmdlet has finished, view the values. 在以下示例中,连接状态显示为“已连接”,且可以看到入口和出口字节数。In the example below, the connection status shows as 'Connected' and you can see ingress and egress bytes.

    "connectionStatus": "Connected",
    "ingressBytesTransferred": 33509044,
    "egressBytesTransferred": 4142431
    

Azure CLIAzure CLI

若要使用 Azure CLI 验证 Resource Manager 部署模型的 VPN 网关连接,请安装最新版本的 CLI 命令(2.0 或更高版本)。To verify a VPN gateway connection for the Resource Manager deployment model using Azure CLI, install the latest version of the CLI commands (2.0 or later).

可使用 az network vpn-connection show 命令来验证连接是否成功。You can verify that your connection succeeded by using the az network vpn-connection show command. 在此示例中,“ --Name”是指要测试的连接的名称。In the example, '--name' refers to the name of the connection that you want to test. 当连接处于建立过程中时,连接状态会显示“正在连接”。When the connection is in the process of being established, its connection status shows 'Connecting'. 建立连接后,状态更改为“已连接”。Once the connection is established, the status changes to 'Connected'.

az network vpn-connection show --name VNet1toSite2 --resource-group TestRG1

Azure 门户(经典)Azure portal (classic)

在 Azure 门户中,可通过导航到连接来查看经典 VNet VPN 网关的连接状态。In the Azure portal, you can view the connection status for a classic VNet VPN Gateway by navigating to the connection. 以下步骤演示导航到连接并进行验证的一种方法。The following steps show one way to navigate to your connection and verify.

  1. Azure 门户中单击“所有资源”,然后导航到经典虚拟网络 (VNet)。In the Azure portal, click All resources and navigate to your classic virtual network (VNet).

  2. 在虚拟网络页上,选择要查看的连接类型。On the virtual network page, select the type of connection that you want to see. 例如,“站点到站点连接”。For example, Site-to-site connections.

    本地站点

  3. 在“站点到站点连接”页的“名称”下,选择要查看的站点连接。On the Site-to-site connections page, under Name, select the site connection you want to view.

    本地站点名称

  4. 在“属性”页上,查看有关连接的信息。On the Properties page, view the information about the connection.

PowerShell(经典)PowerShell (classic)

若要使用 PowerShell 验证经典部署模型的 VPN 网关连接,请安装最新版本的 Azure PowerShell cmdlet。To verify your VPN gateway connection for the classic deployment model using PowerShell, install the latest versions of the Azure PowerShell cmdlets. 请务必下载并安装 Service Management 模块。Be sure to download and install the Service Management module. 使用“Add-AzureAccount”登录经典部署模型。Use 'Add-AzureAccount' to log in to the classic deployment model.

可使用“Get-AzureVNetConnection”cmdlet 来验证连接是否已成功。You can verify that your connection succeeded by using the 'Get-AzureVNetConnection' cmdlet.

  1. 使用以下 cmdlet 示例,配置符合自己需要的值。Use the following cmdlet example, configuring the values to match your own. 如果虚拟网络的名称包含空格,必须将该名称括在引号中。The name of the virtual network must be in quotes if it contains spaces.

    Get-AzureVNetConnection "Group ClassicRG TestVNet1"
    
  2. cmdlet 运行完毕后,查看该值。After the cmdlet has finished, view the values. 在以下示例中,“连接状态”显示为“已连接”,且可以看到入口和出口字节数。In the example below, the Connectivity State shows as 'Connected' and you can see ingress and egress bytes.

    ConnectivityState         : Connected
    EgressBytesTransferred    : 181664
    IngressBytesTransferred   : 182080
    LastConnectionEstablished : 10/19/22020 12:40:54 AM
    LastEventID               : 24401
    LastEventMessage          : The connectivity state for the local network site 'F7F7BFC7_SiteVNet4' changed from Connecting to
                                Connected.
    LastEventTimeStamp        : 10/19/2020 12:40:54 AM
    LocalNetworkSiteName      : F7F7BFC7_SiteVNet4
    

后续步骤Next steps