How to Allow Pings (ICMP Echo Requests) Through Your Windows Firewall (Command line)

How to Allow Pings (ICMP Echo Requests) Through Your Windows Firewall (Command line)

Allow Ping Requests by Using the Command Prompt

The fastest way to create an exception for ping requests is with the Command Prompt. You’ll need to open it with admin privileges. To do so in Windows 8 and 10, press Windows+X and then select “Command Prompt (Admin).” In Windows 7, hit Start and type “command prompt.” Right-click the resulting entry and choose “Run as Administrator.”

To enable ping requests, you’re going to create two exceptions to allow traffic through the firewall—one for ICMPv4 requests and one for ICMPv6 requests. To create the ICMPv4 exception, type (or copy and paste) the following command at the prompt and then hit Enter:

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow

And to create the ICMPv6 exception, use this command:

netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol=icmpv6:8,any dir=in action=allow

The changes will take place immediately—no need to restart your PC or anything. Now, if you ping your PC from a remote device, you should get an actual result.

To disable ping requests again, you’ll need to disable both exceptions you created. For the ICMPv4 exception, type (or copy and paste) this command at the prompt and hit Enter:

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=block

And to disable ICMPv6 requests, use this command:

netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol=icmpv6:8,any dir=in action=block

When requests are blocked, ping requests to your PC will be met with a “Request timed out” error.

Note that when using the commands we just covered, you can use any name for the rule you want. However, when you go to disable a rule, you’ll want to use the same rule name as when you created it. If you forget the name of the rule, you can use the Command Prompt to see a list of all rules. Just type the following command and hit Enter:

netsh advfirewall firewall show rule name=all

You’ll see lots of rules listed, but scroll back up to the top of the list and you should see any rules you’ve created right at the top.

 

Credit goes to : 

Leave a Reply