Change firewall settings from command line

I was looking at options for enabling/disabling the Windows default firewall command line. Here’s how you can do it:

On Windows XP:

to disable the firewal

netsh firewall set opmode disable

to enable the firewall

netsh firewall set opmode enable

to allow ICMP ping to the box

netsh firewall set icmpsetting type = 8 mode = enable

to reset the firewall back to default settings:

netsh firewall reset

On Windows 7 ( & Windows 2008) commands have changed. You will need to run following commands as the machine (domain) administrator.

to disable firewall

netsh advfirewall set allprofiles state off

to enable firewall

netsh advfirewall set allprofiles state on

to reset firewall

netsh advfirewall reset

to allow ICMP ping to the box, add a new rule

netsh advfirewall firewall add rule name="ICMPv4 Allow" dir=in protocol="icmpv4:8,any" action=allow

delete the  ICMP ping rule that you just added

netsh advfirewall firewall delete rule name="ICMPv4 Allow"

For details check out the following KB article#947709

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s