Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Manage Windows Firewall Using advfirewall via CMD

In the Windows environment, managing the firewall is a crucial task for ensuring the security of your system. Windows Firewall, also known as Windows Defender Firewall, can be controlled using the netsh advfirewall command-line tool. This tool allows administrators to configure and manage the firewall settings directly from the Command Prompt (CMD), providing a powerful and flexible way to handle firewall rules and policies.


Using netsh advfirewall, you can create, modify, and delete firewall rules, configure profiles, and monitor the firewall status. This article will guide you through the essential commands and provide practical examples to help you effectively manage Windows Firewall via CMD.


Examples:


1. Checking Firewall Status:
To check the current status of the firewall, use the following command:


   netsh advfirewall show allprofiles

This command will display the status of all firewall profiles (Domain, Private, and Public).


2. Enabling or Disabling the Firewall:
To enable the firewall for all profiles, use:


   netsh advfirewall set allprofiles state on

To disable the firewall for all profiles, use:


   netsh advfirewall set allprofiles state off

3. Creating a New Inbound Rule:
To create a new inbound rule that allows traffic on a specific port (e.g., port 80 for HTTP), use:


   netsh advfirewall firewall add rule name="Allow HTTP" protocol=TCP dir=in localport=80 action=allow

4. Deleting a Rule:
To delete a rule by its name, use:


   netsh advfirewall firewall delete rule name="Allow HTTP"

5. Blocking an Application:
To block an application from accessing the network, use:


   netsh advfirewall firewall add rule name="Block App" program="C:\Path\To\Application.exe" action=block dir=out

6. Allowing an Application:
To allow an application to access the network, use:


   netsh advfirewall firewall add rule name="Allow App" program="C:\Path\To\Application.exe" action=allow dir=in

7. Viewing All Rules:
To list all firewall rules, use:


   netsh advfirewall firewall show rule name=all

8. Resetting Firewall Settings:
To reset the firewall settings to their default state, use:


   netsh advfirewall reset

By mastering these commands, you can effectively manage the Windows Firewall and enhance the security of your system.


To share Download PDF