Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
本文可帮助你为 VPN 网关点到站点 (P2S) 连接配置 Azure VPN Client 的可选设置。 可以配置 DNS 后缀、自定义 DNS 服务器、自定义路由和 VPN 客户端强制隧道。
注意
Azure VPN 客户端仅支持 OpenVPN® 协议连接。
先决条件
本文中的步骤假设你已配置 P2S 网关,并已下载 Azure VPN 客户端来连接客户端计算机。 有关步骤,请参阅以下文章:
使用 VPN 客户端配置文件
要执行本文中的步骤,你需要修改和导入 Azure VPN 客户端配置文件。 根据为 P2S VPN 网关配置的身份验证类型,将生成以下配置文件。
- azurevpnconfig.xml:仅选择一种身份验证类型时,将生成此文件。
- azurevpnconfig_aad.xml:选择多个身份验证类型时,将为 Microsoft Entra ID 身份验证生成此文件。
- azurevpnconfig_cert.xml:选择多个身份验证类型时,将为证书身份验证生成此文件。
若要使用 VPN 客户端配置文件(xml 文件),请执行以下步骤:
找到配置文件,然后使用所选的编辑器将其打开。
使用以下各部分中的示例,根据需要修改文件,然后保存所做的更改。
导入文件以配置 Azure VPN 客户端。 可使用以下方法为 Azure VPN Client 导入文件:
Azure VPN Client 界面:打开 Azure VPN Client,然后依次单击 + 和“导入”。 找到修改后的 .xml 文件,根据需要在 Azure VPN 客户端接口中配置任何其他设置,然后单击“保存”。
命令行提示:将下载的相应 xml 配置文件置于 %userprofile%\AppData\Local\Packages\Microsoft.AzureVpn_8wekyb3d8bbwe\LocalState 文件夹中,然后运行与配置文件名称相对应的命令。 例如,
azurevpn -i azurevpnconfig_aad.xml
。 若要强制导入,请使用 -f 开关。
DNS
添加 DNS 后缀
若要添加 DNS 后缀,请修改下载的配置文件 XML 文件,并添加 <dnssuffixes><dnssufix></dnssufix></dnssuffixes> 标记。
<azvpnprofile>
<clientconfig>
<dnssuffixes>
<dnssuffix>.mycorp.com</dnssuffix>
<dnssuffix>.xyz.com</dnssuffix>
<dnssuffix>.etc.net</dnssuffix>
</dnssuffixes>
</clientconfig>
</azvpnprofile>
添加自定义 DNS 服务器
若要添加自定义 DNS 服务器,请修改下载的配置文件 XML 文件,并添加 <dnsservers><dnsserver></dnsserver></dnsservers> 标记。
<azvpnprofile>
<clientconfig>
<dnsservers>
<dnsserver>x.x.x.x</dnsserver>
<dnsserver>y.y.y.y</dnsserver>
</dnsservers>
</clientconfig>
</azvpnprofile>
注意
使用 Microsoft Entra ID 身份验证时,Azure VPN 客户端使用 DNS 名称解析策略表 (NRPT) 条目,这意味着 DNS 服务器不会在 ipconfig /all
的输出下列出。 若要确认使用中的 DNS 设置,请使用 PowerShell 中的 Get-DnsClientNrptPolicy。
路由
拆分隧道
默认情况下,为 VPN 客户端配置了拆分隧道。
强制隧道
可以配置强制隧道,以便将所有流量定向到 VPN 隧道。 可使用两种不同的方法配置强制隧道:播发自定义路由,或修改配置文件 XML 文件。 如果使用 Azure VPN 客户端版本 2.1900:39.0 或更高版本,则可以包含 0/0。
注意
不通过 VPN 网关提供 Internet 连接。 因此,会删除所有绑定到 Internet 的流量。
播发自定义路由:可以播发自定义路由
0.0.0.0/1
和128.0.0.0/1
。 有关详细信息,请参阅为 P2S VPN 客户端播发自定义路由。配置文件 XML:可以修改下载的配置文件 XML 文件,并添加 <includeroutes><route><destination><mask></destination></mask></route></includeroutes> 标记。
<azvpnprofile> <clientconfig> <includeroutes> <route> <destination>0.0.0.0</destination><mask>1</mask> </route> <route> <destination>128.0.0.0</destination><mask>1</mask> </route> </includeroutes> </clientconfig> </azvpnprofile>
注意
- clientconfig 标记的默认状态为
<clientconfig i:nil="true" />
,可根据要求对其进行修改。
添加自定义路由
可以添加自定义路由。 修改下载的配置文件 XML 文件,并添加 <includeroutes><route><destination><mask></destination></mask></route></includeroutes> 标记。
<azvpnprofile>
<clientconfig>
<includeroutes>
<route>
<destination>x.x.x.x</destination><mask>24</mask>
</route>
<route>
<destination>y.y.y.y</destination><mask>24</mask>
</route>
</includeroutes>
</clientconfig>
</azvpnprofile>
阻止(排除)路由
Azure VPN 客户端不支持完全阻止路由的功能。 Azure VPN 客户端不支持从本地路由表中删除路由。 相反,可以从 VPN 接口中排除路由。 修改下载的配置文件 XML 文件,并添加 <excluderoutes><route><destination><mask></destination></mask></route></excluderoutes> 标记。
<azvpnprofile>
<clientconfig>
<excluderoutes>
<route>
<destination>x.x.x.x</destination><mask>24</mask>
</route>
<route>
<destination>y.y.y.y</destination><mask>24</mask>
</route>
</excluderoutes>
</clientconfig>
</azvpnprofile>
注意
- 若要包含/排除多个目标路由,请将每个目标地址置于单独的路由标记下(如上述示例所示),因为单个路由标记下不能有多个目标地址。
- 如果遇到错误“目标不能为空或路由标记内有多个条目”,请检查配置文件 XML 文件,并确保 includeroutes/excluderoutes 节在一个路由标记内只有一个目标地址。
Azure VPN 客户端版本信息
有关 Azure VPN 客户端版本信息,请参阅 Azure VPN 客户端版本。
后续步骤
有关 P2S VPN 的详细信息,请参阅以下文章: