How to disable windows Firewall using cmd

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).

Windows-Firewall-Configuration-using-cmd
Windows Firewall Configuration using Command prompt cmd

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.

    how-to-disable-windows-firewall-using-cmd-1
    How to disable Windows firewall using cmd
  • Then, you can below-mentioned command to disable the Windows firewall.
    NetSh Advfirewall set allprofiles state off

    Disable-Windows-Firewall-using-cmd
    How to disable Windows firewall using Netsh Command
  • Now, you can enable Windows Firewall using the below command.
    NetSh Advfirewall set allprofiles state on

    Enable-Windows-Firewall-using-cmd
    How to enable Windows Firewall using CMD
  • Last, if you want to know the status of the Windows Firewall, you can use the following guide.
    Netsh Advfirewall show allprofiles

    Status-of-Windows-Firewall-using-cmd
    Checking the Status of Windows Firewall using cmd

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
  1. 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.

    netsh advfirewall firewall add rule name=”All ICMP V4″ dir=in action=block protocol=icmpv4

    netsh advfirewall firewall add rule name=”All ICMP V4″ dir=in action=allow protocol=icmpv4
  2. 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:

    netsh advfirewall set currentprofile logging filename “C:\pfirewall.log”
  3. 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:

    netsh advfirewall firewall add rule name=”Example Communication Port 80″ dir=in action=allow protocol=TCP localport=80

     netsh advfirewall firewall add rule name=”Example Communication Port 80″ dir=out action=allow protocol=TCP localport=80
  4. 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:

    netsh advfirewall firewall add rule name=”Your Application” dir=in action=allow program=”C:\ProgramExample.exe”

    Note: This is a sample program, you can configure your program by giving the correct directory and correct program name.
  5. 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:

    netsh advfirewall firewall set rule group=”remote desktop connection” new enable=Yes
    netsh advfirewall firewall set rule group=”remote desktop connection” new enable=No
  6. 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:

    netsh advfirewall reset
  7. 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:

    netsh advfirewall export “C:\temp\WFconfiguration.wfw”

    netsh advfirewall import “C:\temp\WFconfiguration.wfw”

Related Articles

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.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *