[SQL Server 2012] 使用 Script 在 Windows Server 2008 R2 設定 Firewall Port

[SQL Server 2012] 使用 Script 在 Windows Server 2008 R2 設定 Firewall Port

 

隨著Microsoft發表了最新一代的資料庫 SQL Server 2012,在做新的BI資料庫部屬及安裝常常會用到設定 Windows 2008 R2 的防火牆設定,當我們遵循 Microsoft 所發表的 KB: http://support.microsoft.com/kb/968872/en-us 去操作時會發現目前KB是使用 “netsh firewall” 指令,而Windows Server 2008 R2 卻是使用新的 “netsh advfirewall firewall”指令,所以我將指令從新編寫為新的格式:

 


@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 Debugger/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="SQL 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 TCP" dir=in action=allow protocol=TCP localport=2382
@echo Enabling port for SQL Server Browser Service's 'Browse' Button
netsh advfirewall firewall add rule name="SQL Browser UDP" dir=in action=allow protocol=UDP localport=1434
@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 Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh advfirewall set currentprofile settings unicastresponsetomulticast enable

1

 

設定通訊協定

在SQL Server中必須先確認 TCP/IP 通訊協定是否為啟用的狀態,開啟 『SQL Server 組態管理員』→『SQL Server 網路組態』→『MSSQLServer的通訊協定』→『TCP/IP』為已啟用.

2