Opening Ports on the Windows Firewall Using GUI
To open a port in the firewall using the GUI in Windows Server 2008/2012 R2 and Windows Server 2016, follow the below steps:
- Login using an administrator account.
- Click Start > Administrative Tools > Windows Firewall with Advanced Security
- Click on
Inbound Rules
, and then onNew Rule
The wizard to open a port and accept incoming connections has five steps: Rule Type
, Protocol
and Ports
, Action
, Profile
, and Name
. For this example, we will open TCP port 20002 on servers that are running the Parallels RAS Publishing Agents role:
-
In the
Rule Type
section, selectPort
and click Next: -
In the
Protocol
andPorts
section, select TCP as the type of protocol and type 20002 in the Specific local ports input field: -
In the
Action
section, selectAllow the Connection
and click Next. -
In the
Profile
section, select all three options and click Next. If you wish to limit the connection to a particular profile, you can do so by selecting only the profiles you think are appropriate to your setup. For this example, we will open the port on all profiles. -
In the
Name
section, enter a descriptive name for this rule. It is recommended to list the port number in the name, so the rule is easily recognizable. For example, name the new rule Pub_Agent_20002_IN. Click Finish when ready.
To open additional ports, repeat the above procedure for each additional port and/or protocol you’d like to open in each server.
Opening Ports on the Windows Firewall Using Command Line (netsh)
To open a port on the Windows Firewall using the netsh command line, follow the below procedure:
- Login to the server using an administrator account.
- Run the Command Prompt as Administrator.
- Execute the following command to open the TCP port 20002 on the servers running the Publishing Agents role:
netsh advfirewall firewall add rule name="name" dir=in|out protocol=tcp|udp localport=20002 action=allow
To open additional ports, repeat the above procedure for each additional port and/or protocol you’d like to open in each server.
Opening Ports on the Windows Firewall Using PowerShell
To open a port in the Windows Firewall using PowerShell commands, follow the below procedure (applies only for 2012 R2 and 2016 Windows Server OS):
- Logon using an administrator account.
- Run the Windows PowerShell as Administrator.
- Execute the following command to open the TCP port 20,002 on the servers running the Publishing Agents role:
New-NetFirewallRule -DisplayName "Name" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 2002