通过 SQL Server 防火墙允许 IP 地址

时间:2021-06-21 08:19:22

标签: azure azure-sql-database azureportal

我有一个网站(应用服务),1 个 Sql Server,上面有 2 个数据库。 每个月我都会随机收到一个错误:

Cannot open server 'myServer' requested by the login. Client with IP address 'xx.xxx.87.3' is not allowed to access the server. 
To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. 
It may take up to five minutes for this change to take effect.

我的问题是,我怎么知道这个 IP 地址是什么应用程序/服务? 这不是我网站的 IP 地址,如果我 ping 数据库的 CNAME,它与此 IP 不匹配。但是如果我不添加它,我的整个网站就无法运行。 当某些事情发生变化时,我必须每月手动添加一次。我如何找出这个 IP 地址连接到什么?

2 个答案:

答案 0 :(得分:1)

基本上,有两种方法可以解决您的问题:

  1. 在 SQL Server firewall-config 上将 Allow Azure services and resources to access this server 指定为 Yes,以便您的 SQL Server 允许所有 Azure 资源访问。

  2. 将所有 outbound IPs of your Azure app service 添加到您的 SQL Server 防火墙白名单中。它比第一种方式具有更高的安全级别。您可以在此处找到 Azure 门户上的所有出站 IP:

enter image description here

答案 1 :(得分:0)

  1. 我们可以设置“是”以允许 Azure 服务和资源访问 Azure SQL DB 的服务器。 enter image description here

  2. 为名为 AllowAllWindowsIP 的 IP 0.0.0.0 - 0.0.0.0 创建入站防火墙规则。

<块引用>

要允许托管在 Azure 内部的应用程序连接到您的 SQL 服务器,必须启用 Azure 连接。要启用 Azure 连接,必须有一个防火墙规则,并将起始和结束 IP 地址设置为 0.0.0.0。