【问题标题】:SQL server - Client Connection works in one network not on anotherSQL server - 客户端连接在一个网络中工作而不是在另一个网络上
【发布时间】:2020-10-23 16:04:52
【问题描述】:

我们无法从客户端计算机(客户端)访问网络 A 上的 SQL Server 计算机(服务器),但在另一台 B 上成功。服务器计算机安装了 SQL Server 2019,客户端计算机安装了 SQL Native Client 11.0。我们可以使用 sqlcmd、udl 接口或 Telnet 从该客户端连接到网络 A 上的服务器。但是在不同的网络 B 上,我们无法从同一个 Client 连接到同一个 Server!什么网络配置可以避免 SQL Server 连接?

服务器参数:

1. We defined firewall rules to allow inbound connection on ports 1433 for TCP and 1434 for UDP. We verified that that is the case on the Server by using "netstat -aon". We disabled the Norton Smart Firewall.

2. We have set this rule to apply to all profiles: Domain, Public, Private.

3. We ensured that all protocols for SQLEXPRESS are allowed and enabld in the SQL Server Configuration Manager, specifically TCP/IP. 

4. We have enabled SQL Server Browser.

5. We have restarted all services multiple times after our configuration changes. We have even restarted the machine.

6. We made sure that the Server is accessible remotely and using SQL Server Authentication. 

7. We reset both the modem and the router for both Networks before testing. 

8. We confirmed both the Computer and the SQL Instance names in the SMSS logins and logs.

Tests we did on Network A:

1. We can ping the Client from the Server, the Server from the Client both with IP addresses and computer names (On Server: "ping -a ClientIP/ComputerName", On Client: "ping -a ServerIP/ComputerName". Both results with "Reply...").

2. We can access the database in the Server using SSMS both with Windows Authentication and SQL Server Authentication.  

3. We cannot access to Server from the Client by Windows Authentication either by using "sqlcmd -S Server\sqlexpress -E".

4. We cannot access to Server from the Client by SQL Server Authentication by using "sqlcmd -U User -P Password -S Server\SQLExpress".

On the other hand, when these computers are in Network B, without changing anything we can connect to Server from the Client.

以下是我们收到的错误消息:

sqlcmd -U 用户 -P 密码 -S 服务器\SQLExpress

【问题讨论】:

    标签: sql-server networking


    【解决方案1】:

    默认情况下,命名实例使用动态端口,您不允许通过防火墙。

    最好的解决方案可能是简单地将 SQL Server 实例配置为侦听固定端口 1433,然后您不需要使用实例名称或显式端口来连接。

    为此,我们SQL Server Configuration Manager 将实例配置为侦听所有 IP 上的端口 1433。它应该是这样的:

    动态端口为空,TCP IP 端口为 1433。

    然后重新启动 SQL Server 实例,在 SQL Server 日志中您应该会看到类似的消息

    Server is listening on [ 'any' <ipv4> 1433].
    

    然后尝试连接喜欢

    sqlcmd -U User -P Password -S Server
    

    您可以使用 Powershell 进行测试

      PS C:\> test-netconnection Server -port 1433 
    

    如果您这样做,则不需要 SQL 浏览器服务或端口 1434 的防火墙规则。

    【讨论】:

    • 我已经这样做了。测试“test-netconnection Server -port 1433”返回False,但“test-netconnection ServerIP -port 1433”返回true。
    • (其中 ServerIP 是计算机的 IP 地址)。所以我可以在 1433 端口上 ping 通服务器,但我无法访问它。 SQL Server 日志显示“服务器正在侦听 ['any'
    • 而且这个问题对于几台服务器和客户端计算机都是一样的。我无法从客户端计算机连接到服务器。当然,事实并非如此。我们的网络配置发生了一些变化。
    • 当我使用有线网络而不是无线网络时,我也能够连接到这个网络。无线网络中似乎有些东西无法将客户端连接到服务器。
    猜你喜欢
    • 1970-01-01
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多