Thursday, September 1, 2011

How to enable and disable and config firewall windows xp by command line


------------------------

Enable by port & exe

------------------------
Sample old
------------------------
netsh firewall add portopening TCP 80 “HTTP”

netsh firewall add portopening TCP 23 “Telnet”

netsh firewall add allowedprogram C:\MyApp\MyApp.exe "My Application" ENABLE
------------------------
Sample new server 2008
------------------------
netsh advfirewall firewall add rule name=”HTTP” dir=in action=allow protocol=TCP localport=80

netsh advfirewall firewall add rule name=”My Application” dir=in action=allow program=”C:\MyApp\MyApp.exe” enable=yes
------------------------

Disable by port & exe

------------------------
Sample old
------------------------
netsh firewall delete allowedprogram C:\MyApp\MyApp.exe

delete portopening protocol=UDP port=500
------------------------
Sample new server 2008
------------------------
netsh advfirewall firewall delete rule name=rule name program=”C:\MyApp\MyApp.exe”

netsh advfirewall firewall delete rule name=rule name protocol=udp localport=500

Restore policy defaults
netsh firewall reset

netsh advfirewall reset

Enable Windows Firewall

netsh firewall set opmode ENABLE

netsh firewall set opmode DISABLE




No comments:

Post a Comment

Popular Posts