Windows 7 / Networking

Managing Windows Firewall Using the Netsh Command

The Netsh command can be used to manage Windows Firewall either interactively from the command line or by using scripts. The Netsh command also has been enhanced in Windows 7 to expose almost all aspects of Windows Firewall to viewing and configuration (some settings, such as global quick mode, can only be configured using the Windows Firewall with Advanced Security snap-in. By using the netsh advfirewall context of this command, you can display the status and configuration of Windows Firewall, configure firewall and IPsec settings, create and configure both firewall and connection security rules, monitor active connections, and perform other management tasks.

Note You must run the netsh advfirewall command from an elevated command prompt to set (configure) Windows Firewall settings. You do not need to run it from an elevated command prompt if you only want to show (view) Windows Firewall settings.

To enter the netsh advfirewall context from the command line, type netsh and press Enter, then type advfirewall and press Enter.

C:\Windows\System32>netsh
netsh>advfirewall
netsh advfirewall>

The prompt indicates the current context of the command. Typing help at the netsh advfirewall prompt displays the following additional commands available for this context:

  • consec Changes to the netsh advfirewall consec context, which lets you view and configure connection security rules.
  • export Exports the current firewall policy to a .wfw file.
  • firewall Changes to the netsh advfirewall firewall context, which lets you view and configure firewall rules.
  • import Imports a .wfw policy file into the current policy store.
  • mainmode New in Windows 7, this changes to the netsh advfirewall mainmode context, which lets you view and configure main mode configuration rules.
  • monitor Enhanced with added functionality in Windows 7, this changes to the netsh advfirewall monitor context, which lets you view the current IPsec, firewall, and main mode states, and the current quick mode and main mode security associates established on the local computer.
  • reset Resets the firewall policy to the default out-of-box policy.
  • set Sets per-firewall profile and global firewall settings.
  • show Displays firewall profiles and global firewall settings.

Note To view all firewall settings including global settings, per-firewall profile settings, and all active firewall rules on the computer, type netsh advfirewall monitor show firewall verbose at a command prompt.

Also new in Windows 7 are the following two Netsh contexts:

  • netsh trace Enables ETW tracing and/or Network Diagnostics Framework (NDF) diagnostics for various features and scenarios including Windows Firewall and IPsec.
  • netsh wfp Enables WFP and Internet Key Exchange (IKE)/AuthIP tracing.

More Info For more information concerning Netsh syntax and examples of usage, see "Netsh Commands for Windows Firewall with Advanced Security" at http://technet.microsoft.com/en-us/library/cc771920.aspx.

[Previous] [Contents] [Next]

In this tutorial:

  1. Configuring Windows Firewall and IPsec
  2. Understanding Windows Firewall with Advanced Security
  3. Improvements to Windows Firewall Introduced Previously in Windows Vista
  4. Additional Improvements to Windows Firewall in Windows 7
  5. Understanding the Windows Filtering Platform
  6. Windows Firewall and the Startup Process
  7. Understanding Windows Service Hardening
  8. Understanding Service SIDs
  9. Windows Firewall and WSH
  10. Windows Firewall and Service Triggers
  11. Understanding Multiple Active Firewall Profiles
  12. Understanding Rules
  13. Understanding Firewall Rules
  14. Inbound vs . Outbound Rules
  15. Allow vs . Block Rules
  16. Allow If Secure Rules
  17. Authenticated Bypass Rules
  18. Filtering Conditions FOR Firewall RULES
  19. Understanding Connection Security Rules
  20. Types of Connection Security Rules
  21. Supported IPsec Settings for Connection Security Rules
  22. Default IPsec Settings for Connection Security Rules
  23. Windows Firewall and Windows PE
  24. Understanding Default Rules
  25. Understanding WSH Rules
  26. Understanding Rules Processing
  27. Managing Windows Firewall with Advanced Security
  28. Tools for Managing Windows Firewall with Advanced Security
  29. Managing Windows Firewall Using Control Panel
  30. Managing Windows Firewall Using the Windows Firewall with Advanced Security Snap-in
  31. Managing Windows Firewall Using Group Policy
  32. Considerations When Managing Windows Firewall Using Group Policy
  33. Managing Windows Firewall Using the Netsh Command
  34. Common Management Tasks
  35. Enabling or Disabling Windows Firewall
  36. Configuring Firewall Profiles and IPsec Settings by Using Group Policy
  37. Creating and Configuring Firewall Rules
  38. Creating and Configuring Connection Security Rules
  39. Monitoring Windows Firewall
  40. Troubleshooting Windows Firewall
  41. Troubleshooting Windows Firewall Using Firewall Logs
  42. Troubleshooting Windows Firewall Using Event Logs
  43. Troubleshooting Windows Firewall Using Auditing
  44. Troubleshooting IPsec Issues Using Netsh Wfp
  45. Troubleshooting Windows Filtering Platform and IPsec Issues Using Netsh Trace