So far, we have come to know about the Windows Firewall. In the previous article, we learned about how we can disable Windows firewalls using GUI (Graphical User Interface). The objective of this article is to disable Windows Firewall using cmd (command prompt).
How to Enable or Disable Windows Firewall?
As we know Windows Firewall, by default, is enabled on Microsoft Operating System. For many reasons, you may need to disable the Windows Firewall. To disable the Windows firewall, we can either use the Graphical User Interface (GUI) or use the command prompt (cmd) mode. This article will guide you on how to disable Windows firewalls using cmd.
Steps to disable Windows Firewall using cmd
- Open cmd using Administrator Privileges as shown in the below picture.
- Then, you can below-mentioned command to disable the Windows firewall.
[terminal]NetSh Advfirewall set allprofiles state off[/terminal] - Now, you can enable Windows Firewall using the below command.
[terminal]NetSh Advfirewall set allprofiles state on[/terminal] - Last, if you want to know the status of the Windows Firewall, you can use the following guide.
[terminal]Netsh Advfirewall show allprofiles[/terminal]
Advanced netsh configuration of Windows Firewall
So far, we discussed some simple commands to enable or disable Windows firewalls. But, the cmd can be used for the advanced configuration of the Windows firewall. Now, we will discuss on below topics one by one and learn the complete configurations of the Windows Firewall. Before we start, we need to know about various profiles that are builtin with the Operating System:
- Public
- Private
- Domain
-
Disable ICMP Protocol:
ICMP stands for Internet Control Message Protocol and is used to disable or enable PING(Packet InterNet Groper). By default, ICMP is blocked on public network profiles and allowed on private profiles. If we require to block “ping” we have to disable “ICMP” network packets. The following command will show you how to disable or enable “ICMP” packets to disable or enable “ping” requests in the inbound direction on the IPv4 network. After the implementation of this command, your system will drop all packets of ICMP.[terminal]netsh advfirewall firewall add rule name=”All ICMP V4″ dir=in action=block protocol=icmpv4[/terminal]
[terminal]netsh advfirewall firewall add rule name=”All ICMP V4″ dir=in action=allow protocol=icmpv4[/terminal] -
Monitor Firewall Logs:
By default, the log of Microsoft Windows Firewall is “\Windows\system32\LogFiles\Firewall\pfirewall.log“, and we can change it to a particular file at a particular location. We must audit firewall logs to identify a particular threat or network that tries to attack our system. We can configure logs using the below command in command prompts:
[terminal]netsh advfirewall set currentprofile logging filename “C:\pfirewall.log”[/terminal] -
Configure Firewall Ports:
As we know ports are virtual paths from source to destination. To secure our network, we must disable or close unused ports. Windows firewalls and other firewalls can be used to disable or enable various ports. To disable or enable particular ports we can use the following commands in the Windows Command prompt:
[terminal]netsh advfirewall firewall add rule name=”Example Communication Port 80″ dir=in action=allow protocol=TCP localport=80[/terminal]
[terminal] netsh advfirewall firewall add rule name=”Example Communication Port 80″ dir=out action=allow protocol=TCP localport=80[/terminal] -
Disable or Enable Windows Program:
As we know, a Windows firewall can be used to Block or Enable a Windows program. A program might reach the internet or not, depending upon the following commands:
[terminal]netsh advfirewall firewall add rule name=”Your Application” dir=in action=allow program=”C:\ProgramExample.exe”[/terminal]
Note: This is a sample program, you can configure your program by giving the correct directory and correct program name. -
Enable RDP (Remote Desktop Protocol):
Remote Desktop Connection commonly known as RDP can be used to take the console of a remote system. That particular user can be in a private network or a public network. We commonly enable RDP on Microsft Server like Windows Server 2012 R2. To enable RDP you can follow the below command:
[terminal]netsh advfirewall firewall set rule group=”remote desktop connection” new enable=Yes[/terminal][terminal]netsh advfirewall firewall set rule group=”remote desktop connection” new enable=No[/terminal] -
Reset Windows Firewall:
You can use your command prompt to reset all manual settings that are misconfigured on Windows Firewall. To restore default settings you can use the following:
[terminal]netsh advfirewall reset[/terminal] -
Export/ Import Firewall Configuration:
If you fully configured your firewall with the required configurations, then it’s a good idea to export the current configuration to a file so that you can restore the original configuration whenever required. To export current settings you can follow the below commands:
[terminal]netsh advfirewall export “C:\temp\WFconfiguration.wfw”[/terminal]
[terminal]netsh advfirewall import “C:\temp\WFconfiguration.wfw”[/terminal]
Related Articles
- How to configure Static Route | Windows | Linux
- How to Enable or Disable Windows Firewall
- Download GNS3 – Latest Version of 2023 [Offline Installer]
- Cisco Packet Tracer 7.3 Free Download (Offline Installers)
References
Summary
In this article, we learn how to disable Windows firewalls using the command prompt. First of all, we learned how to disable or enable Windows firewalls. We also learn how to check the status of the Windows firewall. After all, we came to know about some important commands of netsh utility to manage Windows firewall efficiently.
Thanks, Nice article.