Windows : How to open a port on firewall from command line (CLI)

By | December 13, 2021

Windows Firewall can be configured from the GUI (by using firewall.cpl UI console) and also using the command line. This quick tutorial will cover how to manipulate the rules from CLI to open, block a port and delete a rule.

In  a nutshell, here is the command sample:

The rest of this article will assume we want to play with TCP port 3001.

1. Open port tcp-3001:

2. Block port tcp-3001:

3. Delete the rule tcp-3001:

4. In case you want to play with existing rules, here is the command to show all existing rules:

BONUS. Here is the commands to enable/disable the firewall: