More netsh firewall command options in Windows.
- February 27th, 2015
- Write comment
Here is some very good information from Microsoft for the netsh command in Windows:
http://support.microsoft.com/kb/947709
I have just listed a few of the commands in both the new version of the command and the old.
Show all the current firewall rules:
New:
netsh advfirewall firewall show rule name=all
To disable or enable all firewall profiles (Domain,Private or Public):
Old:
netsh firewall set opmode ENABLE
Old:
netsh firewall set opmode DISABLE
New:
netsh advfirewall set allprofiles state on
New:
netsh advfirewall set allprofiles state off
To reset the firewall back to the defaults:
Old:
netsh firewall reset
New:
netsh advfirewall reset
To log firewall activity:
Old:
netsh firewall set logging “C:\FWLogs\FW.log” 4096 ENABLE ENABLE
New:
netsh advfirewall set currentprofile logging filename “C:\FWLogs\FW.log”
To open or close access to a network port:
Old:
netsh firewall add portopening TCP 80 “Open Port 80”
Old:
netsh firewall delete portopening TCP 80 “Open Port 80”
New:
netsh advfirewall firewall add rule name=”Open Port 80″ dir=in action=allow protocol=TCP localport=80
New:
netsh advfirewall firewall delete rule name=”Open Port 80″ protocol=tcp localport=80
To enable a program:
Old:
netsh firewall add allowedprogram C:\myprograms\myprogram.exe “Allow My Program” ENABLE
New:
netsh advfirewall firewall add rule name=”Allow My Program” dir=in action=allow program=”C:\myprograms\myprogram.exe”