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.
In this tutorial:
- Configuring Windows Firewall and IPsec
- Understanding Windows Firewall with Advanced Security
- Improvements to Windows Firewall Introduced Previously in Windows Vista
- Additional Improvements to Windows Firewall in Windows 7
- Understanding the Windows Filtering Platform
- Windows Firewall and the Startup Process
- Understanding Windows Service Hardening
- Understanding Service SIDs
- Windows Firewall and WSH
- Windows Firewall and Service Triggers
- Understanding Multiple Active Firewall Profiles
- Understanding Rules
- Understanding Firewall Rules
- Inbound vs . Outbound Rules
- Allow vs . Block Rules
- Allow If Secure Rules
- Authenticated Bypass Rules
- Filtering Conditions FOR Firewall RULES
- Understanding Connection Security Rules
- Types of Connection Security Rules
- Supported IPsec Settings for Connection Security Rules
- Default IPsec Settings for Connection Security Rules
- Windows Firewall and Windows PE
- Understanding Default Rules
- Understanding WSH Rules
- Understanding Rules Processing
- Managing Windows Firewall with Advanced Security
- Tools for Managing Windows Firewall with Advanced Security
- Managing Windows Firewall Using Control Panel
- Managing Windows Firewall Using the Windows Firewall with Advanced Security Snap-in
- Managing Windows Firewall Using Group Policy
- Considerations When Managing Windows Firewall Using Group Policy
- Managing Windows Firewall Using the Netsh Command
- Common Management Tasks
- Enabling or Disabling Windows Firewall
- Configuring Firewall Profiles and IPsec Settings by Using Group Policy
- Creating and Configuring Firewall Rules
- Creating and Configuring Connection Security Rules
- Monitoring Windows Firewall
- Troubleshooting Windows Firewall
- Troubleshooting Windows Firewall Using Firewall Logs
- Troubleshooting Windows Firewall Using Event Logs
- Troubleshooting Windows Firewall Using Auditing
- Troubleshooting IPsec Issues Using Netsh Wfp
- Troubleshooting Windows Filtering Platform and IPsec Issues Using Netsh Trace