你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

为虚拟 WAN 点到站点 VPN 配置强制隧道

使用强制隧道可将所有流量(包括 Internet 绑定流量)从远程用户发送到 Azure。 在虚拟 WAN 中,点到站点 VPN 远程用户的强制隧道意味着 0.0.0.0/0 默认路由播发至远程 VPN 用户。

创建虚拟 WAN 中心

本文中的步骤假设你已部署了具有一个或多个中心的虚拟 WAN。

若要创建新虚拟 WAN 和新中心,请使用以下文章中的步骤:

设置点到站点 VPN

本文中的步骤还假设你已在虚拟 WAN 中心中部署了点到站点 VPN 网关。 此外,还假设你已创建点到站点 VPN 配置文件并分配给了网关。

若要创建点到站点 VPN 网关和相关配置文件,请参阅创建点到站点 VPN 网关

可以使用多种方法配置强制隧道并将默认路由 (0.0.0.0/0) 播发至连接到虚拟 WAN 的远程用户 VPN 客户端。

  • 可以使用下一个跃点虚拟网络连接在 defaultRouteTable 中指定静态 0.0.0.0/0 路由。 这会强制将所有 Internet 绑定流量发送到部署在该分支虚拟网络中的网络虚拟设备。 有关详细说明,请考虑通过 NVA 路由中介绍的备用工作流。
  • 你可以使用 Azure 防火墙管理器,将虚拟 WAN 配置为通过虚拟 WAN 中心中部署的 Azure 防火墙发送所有 Internet 绑定流量。 有关配置步骤和教程,请参阅 Azure 防火墙管理器文档保护虚拟中心。 另外,也可以使用 Internet 流量路由策略对此进行配置。 有关详细信息,请参阅路由意向和路由策略
  • 你可以使用防火墙管理器通过第三方安全提供程序发送 Internet 流量。 有关此功能的详细信息,请参阅受信任的安全提供程序
  • 你可以将一个分支(站点到站点 VPN、ExpressRoute 线路)配置为将 0.0.0.0/0 路由播发至虚拟 WAN。

配置上述四种方法之一后,确保为点到站点 VPN 网关打开 EnableInternetSecurity 标志。 此标志必须设为 true,才能正确配置客户端以实现强制隧道。

若要打开 EnableInternetSecurity 标志,请使用以下 PowerShell 命令为环境替换适当的值。

Update-AzP2sVpnGateway -ResourceGroupName "sampleRG" -Name "p2sgwsamplename" -EnableInternetSecurityFlag

下载点到站点 VPN 配置文件

若要下载点到站点 VPN 配置文件,请参阅全局和中心配置文件。 从 Azure 门户下载的 zip 文件中的信息对于正确配置客户端至关重要。

为 Azure VPN 客户端 (OpenVPN) 配置强制隧道

配置强制隧道的步骤会有所不同,具体取决于最终用户设备的操作系统。

Windows 客户端

注意

对于 Windows 客户端,Azure VPN 客户端的强制隧道仅适用于软件版本 2:1900:39.0 或更高版本。

  1. 验证 Azure VPN 客户端的版本是否与强制隧道兼容。 为此,请单击 Azure VPN 客户端底部的三个点,然后单击“帮助”。 另外,导航到“帮助”的快捷键是 Ctrl-H。 可以在屏幕顶部查找到版本号。 确保版本号为 2:1900:39.0 或更高版本。

    显示如何配置 NVA 专用路由策略的屏幕截图。

  2. 打开从上一部分下载的 zip 文件。 你应会看到名为 AzureVPN 的文件夹。 打开文件夹,然后在收藏的 XML 编辑工具中打开 azurevpnconfig.xml。

  3. 在 azureconfig.xml 中,有一个名为 version 的字段。 如果版本标记之间的数字为 1,则将版本号更改为 2。

    <version>2</version>
    
  4. 将配置文件导入 Azure VPN 客户端。 有关如何导入配置文件的详细信息,请参阅 Azure VPN 客户端导入说明

  5. 连接到新添加的连接。 你现在正在以强制隧道方式将所有流量传输到 Azure 虚拟 WAN。

MacOS 客户端

MacOS 客户端从 Azure 获知默认路由后,客户端设备会自动配置强制隧道。 无需采取额外步骤。 有关如何使用 macOS Azure VPN 客户端连接到虚拟 WAN 点到站点 VPN 网关的说明,请参阅 macOS 配置指南

为 IKEv2 客户端配置强制隧道

对于 IKEv2 客户端,无法直接使用从 Azure 门户下载的可执行配置文件。 若要正确配置客户端,需运行 PowerShell 脚本或通过 Intune 分布 VPN 配置文件。

根据点到站点 VPN 网关上配置的身份验证方法,使用其他 EAP 配置文件。 下面提供了示例 EAP 配置文件。

具有用户证书身份验证的 IKEv2

若要使用用户证书对远程用户进行身份验证,请使用以下 PowerShell 脚本示例。 若要将 VpnSettings 和 EAP XML 文件的内容正确导入 PowerShell,请导航到相应目录,然后运行 Get-Content PowerShell 命令。

# specify the name of the VPN Connection to be installed on the client
$vpnConnectionName = "SampleConnectionName"

# get the VPN Server FQDN from the profile downloaded from Azure Portal
$downloadedXML = [xml] (Get-Content VpnSettings.xml)
$vpnserverFQDN = $downloadedXML.VpnProfile.VpnServer

# use the appropriate EAP XML file based on the authentication method specified on the Point-to-site VPN gateway
$EAPXML = [xml] (Get-Content EapXML.xml)

# create the VPN Connection
Add-VpnConnection -Name $vpnConnectionName -ServerAddress $vpnserverFQDN -TunnelType Ikev2 -AuthenticationMethod Eap -EapConfigXmlStream $EAPXML

# enabled forced tunneling
Set-VpnConnection -Name $vpnConnectionName -SplitTunneling $false 

以下示例显示了用于实现基于用户证书的身份验证的 EAP XML 文件。 将 IssuerHash 字段替换为根证书的指纹,以确保客户端设备选择正确的证书并传递至 VPN 服务器进行身份验证。

<EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
    <EapMethod>
        <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">13</Type>
        <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId>
        <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType>
        <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
    </EapMethod>
    <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
        <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
            <Type>13</Type>
            <EapType xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
                <CredentialsSource>
                    <CertificateStore>
                        <SimpleCertSelection>true</SimpleCertSelection>
                    </CertificateStore>
                </CredentialsSource>
                <ServerValidation>
                    <DisableUserPromptForServerValidation>false</DisableUserPromptForServerValidation>
                    <ServerNames></ServerNames>
                </ServerValidation>
                <DifferentUsername>false</DifferentUsername>
                <PerformServerValidation xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">false</PerformServerValidation>
                <AcceptServerName xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">false</AcceptServerName>
                <TLSExtensions xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">
                    <FilteringInfo xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV3">
                        <CAHashList Enabled="true">
                            <IssuerHash> REPLACE THIS WITH ROOT CERTIFICATE THUMBPRINT </IssuerHash>
                        </CAHashList>
                    </FilteringInfo>
                </TLSExtensions>
            </EapType>
        </Eap>
    </Config>
</EapHostConfig>

具有计算机证书身份验证的 IKEv2

若要使用计算机证书对远程用户进行身份验证,请使用以下 PowerShell 脚本示例。 若要将 VpnSettings 和 EAP XML 文件的内容正确导入 PowerShell,请导航到相应目录,然后运行 Get-Content PowerShell 命令。

# specify the name of the VPN Connection to be installed on the client
$vpnConnectionName = "UserCertVPNConnection"

# get the VPN Server FQDN from the profile downloaded from Azure portal
$downloadedXML = [xml] (Get-Content VpnSettings.xml)
$vpnserverFQDN = $downloadedXML.VpnProfile.VpnServer

# create the VPN Connection
Add-VpnConnection -Name $vpnConnectionName -ServerAddress $vpnserverFQDN -TunnelType Ikev2 -AuthenticationMethod MachineCertificate 

# enabled forced tunneling
Set-VpnConnection -Name $vpnConnectionName -SplitTunneling $false 

具有基于用户名和密码的 RADIUS 服务器身份验证 (EAP-MSCHAPv2) 的 IKEv2

若要使用基于用户名和密码的 RADIUS 身份验证 (EAP-MASCHAPv2) 对远程用户进行身份验证,请使用以下 PowerShell 脚本示例。 若要将 VpnSettings 和 EAP XML 文件的内容正确导入 PowerShell,请导航到相应目录,然后运行 Get-Content PowerShell 命令。

# specify the name of the VPN Connection to be installed on the client
$vpnConnectionName = "SampleConnectionName"

# get the VPN Server FQDN from the profile downloaded from Azure portal
$downloadedXML = [xml] (Get-Content VpnSettings.xml)
$vpnserverFQDN = $downloadedXML.VpnProfile.VpnServer

# use the appropriate EAP XML file based on the authentication method specified on the Point-to-site VPN gateway
$EAPXML = [xml] (Get-Content EapXML.xml)

# create the VPN Connection
Add-VpnConnection -Name $vpnConnectionName -ServerAddress $vpnserverFQDN -TunnelType Point-to-sitev2 -AuthenticationMethod Eap -EapConfigXmlStream $EAPXML

# enabled forced tunneling
Set-VpnConnection -Name $vpnConnectionName -SplitTunneling $false 

以下是 EAP XML 文件示例。

<EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
    <EapMethod>
        <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">26</Type>
        <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId>
        <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType>
        <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
    </EapMethod>
    <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
        <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
            <Type>26</Type>
            <EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1">
                <UseWinLogonCredentials>false</UseWinLogonCredentials>
            </EapType>
        </Eap>
    </Config>
</EapHostConfig>

具有基于用户证书的 RADIUS 服务器身份验证 (EAP-TLS) 的 IKEv2

若要使用基于证书的 RADIUS 身份验证 (EAP-TLS) 对远程用户进行身份验证,请使用以下 PowerShell 脚本示例。 请注意,为了将 VpnSettings 和 EAP XML 文件的内容导入 PowerShell,必须导航到相应目录,然后运行 Get-Content PowerShell 命令。

# specify the name of the VPN Connection to be installed on the client
$vpnConnectionName = "SampleConnectionName"

# get the VPN Server FQDN from the profile downloaded from Azure portal
$downloadedXML = [xml] (Get-Content VpnSettings.xml)
$vpnserverFQDN = $downloadedXML.VpnProfile.VpnServer

# use the appropriate EAP XML file based on the authentication method specified on the Point-to-site VPN gateway
$EAPXML = [xml] (Get-Content EapXML.xml)

# create the VPN Connection
Add-VpnConnection -Name $vpnConnectionName -ServerAddress $vpnserverFQDN -TunnelType Ikev2 -AuthenticationMethod Eap -EapConfigXmlStream $EAPXML

# enabled forced tunneling
Set-VpnConnection -Name $vpnConnectionName -SplitTunneling $false 

下面是 EAP XML 文件示例。 将 TrustedRootCA 字段更改为证书颁发机构颁发的证书上的指纹,并将 IssuerHash 更改为根证书上的指纹。

<EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
    <EapMethod>
        <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">13</Type>
        <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId>
        <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType>
        <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
    </EapMethod>
    <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
        <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
            <Type>13</Type>
            <EapType xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
                <CredentialsSource>
                    <CertificateStore>
                        <SimpleCertSelection>false</SimpleCertSelection>
                    </CertificateStore>
                </CredentialsSource>
                <ServerValidation>
                    <DisableUserPromptForServerValidation>false</DisableUserPromptForServerValidation>
                    <ServerNames></ServerNames>
                    <TrustedRootCA> CERTIFICATE AUTHORITY THUMBPRINT </TrustedRootCA>
                </ServerValidation>
                <DifferentUsername>true</DifferentUsername>
                <PerformServerValidation xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">true</PerformServerValidation>
                <AcceptServerName xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">true</AcceptServerName>
                <TLSExtensions xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV2">
                    <FilteringInfo xmlns="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV3">
                        <CAHashList Enabled="true">
                            <IssuerHash> ROOT CERTIFCATE THUMBPRINT  </IssuerHash>
                        </CAHashList>
                    </FilteringInfo>
                </TLSExtensions>
            </EapType>
        </Eap>
    </Config>
</EapHostConfig>

后续步骤

有关虚拟 WAN 的详细信息,请参阅常见问题解答