我正在尝试将具有动态外部 IP 的本地笔记本电脑连接到我们的 Azure SQL Server。为此,我创建了一个虚拟网络网关并将笔记本电脑连接到该网关。此外,我还向 SQL Server 添加了一个专用端点。之后,我可以使用telnet成功连接到SQL服务器IP,如果我解析hosts文件中的SQL服务器FQDS,我可以通过SSMS连接到服务器。但如果没有主机文件,笔记本电脑总是尝试通过其公共端点/地址连接到 SQL 服务器。
我找到了以下文章:https://techcommunity.microsoft.com/t5/azure-database-support-blog/azure-sql-db-private-link-private-endpoint-connectivity/ba-p/1235573 https://techcommunity.microsoft.com/t5/azure-database-support-blog/azure-sql-db-private-link-private-endpoint-connectivity/ba-p/1235573这篇文章很棒。建议使用您自己的 DNS 服务器将 SQL Server FQDN 解析为本地 IP。不幸的是,笔记本电脑无法访问任何自定义 DNS,因此该解决方案不适合。
有两个问题:
是否可以使用专用终结点但没有自己的 DNS 服务器在具有动态 IP 的本地计算机和 Azure SQL 服务器之间建立连接?
如果第一个问题的答案为“否”,是否有其他方法可以使用任何其他 Azure 应用程序将具有动态 IP 的本地计算机连接到 Azure SQL 服务器?
首先,没有DNS服务就不能使用FQDN。因此,您确实需要一个自定义 DNS 服务器,以便在连接字符串中使用服务器的 FQDN,以便客户端从本地 VM 连接到 Azure SQL 服务器。
由于您使用的是笔记本电脑,因此您的计算机使用的 DNS 服务器很可能是由您的 ISP 指定的。您无法对其进行更多控制,也无法要求您的 ISP 配置 DNS 转发器。否则,您需要在内部网络中部署 DNS 服务器。目前,在这种情况下,最好的方法是使用本地计算机上的 HOSTS 文件来覆盖公共 DNS。
但是,如果您不喜欢使用 HOSTS 文件,您可以配置 Azure VM 作为 DNS 服务器与虚拟网络网关位于同一 Azure 虚拟网络中。
主要步骤:
-
部署 Azure VM 和 RDP 到该 VM,并运行 PowerShell 命令来安装 DNS 服务器角色。
Install-WindowsFeature -Name DNS -IncludeManagementTools
Get-WindowsFeature *DNS*
Add Azure DNS (168.63.129.16
) as a forwarder on your custom DNS server according to the step 5 in this blog https://techcommunity.microsoft.com/t5/azure-database-support-blog/azure-sql-db-private-link-private-endpoint-connectivity/ba-p/1235573. If you do not want to use forwarder you can also create a forward lookup zone
and added manually the host to match the FQDN. You could read On-premises workloads using a DNS forwarder https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns#on-premises-workloads-using-a-dns-forwarder for more details.
After you have configured the DNS server and set the DNS forwarder. You could change the DNS server of Azure VNet to your Azure VM's private IP address.
-
重新启动 Azure VM 并重新下载 VPN 客户端包并重新连接 VPN 连接以进行网络更新。检查本地 VPN 客户端计算机上的 DNS 服务器,并将 DNS 服务器设置为 TCP/IP 设置中的自定义 DNS 服务器。然后,您将通过Azure服务的默认FQDN查找您的私有IP地址。
In my example, I am using Azure storage account but it works the same with Azure
SQL database when using a private endpoint on the Azure and P2S VPN connection.
In this way, it requires that there are not any other VPN connections except the
P2S VPN connection on the local machine.
然后,您可以将 Azure SQL 服务器 FQDN 解析为专用终结点的专用 IP 地址。但是,通过 VPN 连接连接到 Azure SQL Server 的性能可能并不比通过公共 Internet 和公共 DNS 服务直接连接到它更好。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)