Microsoft Windows Server 2008 R2 Allow SQL Server access through windows firewall


rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 2081 times

Scenario:

You have a Microsoft Windows Server 2008 R2 Server that is running a SQL Server 2008 r2 express database.


Problem:

You have a branch office connected through an ipsec VPN tunnel users on that network are complaining about access to their database application returning the following error:

“The database was not found or access denied”

 

 


Solution:

This usually revolves windows firewall disallowing traffic to the database. If you turn the windows firewall off on the database server you will see that users can once again access the application.

The script that is discussed in this section opens the firewall ports for SQL Server.

To create the script, follow these steps:

  1. Start Notepad.
  2. Copy and paste the following code into Notepad:
    netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
    
    @echo =========  SQL Server Ports  ===================
    @echo Enabling SQLServer default instance port 1433
    netsh advfirewall firewall add rule name="SQL Server" dir=in action=allow protocol=TCP localport=1433
    @echo Enabling Dedicated Admin Connection port 1434
    netsh advfirewall firewall add rule name="SQL Admin Connection" dir=in action=allow protocol=TCP localport=1434
    @echo Enabling Conventional SQL Server Service Broker port 4022
    netsh advfirewall firewall add rule name="SQL Service Broker" dir=in action=allow protocol=TCP localport=4022
    @echo Enabling Transact SQL/RPC port 135
    netsh advfirewall firewall add rule name="SQL Debugger/RPC" dir=in action=allow protocol=TCP localport=135
    @echo =========  Analysis Services Ports  ==============
    @echo Enabling SSAS Default Instance port 2383
    netsh advfirewall firewall add rule name="Analysis Services" dir=in action=allow protocol=TCP localport=2383
    @echo Enabling SQL Server Browser Service port 2382
    netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=TCP localport=2382
    
    @echo =========  Misc Applications  ==============
    @echo Enabling HTTP port 80
    netsh advfirewall firewall add rule name="HTTP" dir=in action=allow protocol=TCP localport=80
    @echo Enabling SSL port 443
    netsh advfirewall firewall add rule name="SSL" dir=in action=allow protocol=TCP localport=443
    @echo Enabling port for SQL Server Browser Service's 'Browse' Button
    netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=UDP localport=1434
    @echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
    netsh firewall set multicastbroadcastresponse ENABLE
  3. Save the file as a .txt file by using the following name: OpenSqlServerPort.txt
  4. Rename the OpenSqlServerPort.txt file to the following: OpenSqlServerPort.bat

Before you run the OpenSqlServerPort.bat script, you must copy the script to the computer that has the firewall and then run the script on that computer. To run the script, follow these steps:

  1. Click Start, click Run, type cmd, and then click OK.
  2. At the command prompt, use the cd command to move to the folder in which you saved the OpenSqlServerPort.bat file.
  3. To run the OpenSqlServerPort.bat script, type OpenSqlServerPort.bat at the command prompt, and then press Enter.
Or simply download and run this fix it:
To fix this problem automatically, click the Fix this problem link. Click Run in the File Download dialog box, and then follow the steps in this wizard.

Fix this problem 
Microsoft Fix it 50169

Note This wizard may be in English only, but the automatic fix also works for other language versions of Windows.

Note If you are not on the computer that has the problem, save the Fix it solution to a flash drive or a CD and then run it on the computer that has the problem.

Source: http://support.microsoft.com/?scid=kb;en-us;968872