netsh configuration Windows Firewall (advfirewall)

Source: Internet
Author: User

One might say that Windows Firewall has a very friendly user interface, why use the command line interface to configure a Windows Firewall? There are

Personally think for a reason (aside some people like the command line does not like the interface, O (∩_∩) o haha)

First, configure faster-once you have mastered how to use the netsh advfirewall command, it is much faster to configure the firewall than to use a graphical interface.
Then, you can write scripts-using this tool you can script some common functions.

Last, the firewall can still be configured when the graphical interface is not available-like other command-line tools, when the graphical interface is not available, for example: in Windows Server Core mode, you will still be able to use the Netsh Advfirewall tool to configure the firewall.

So many Netsh commands, what should I do, remember? No,no,no. We only need a "help" command or a "? "Just fine."

Next look at another command: consec (connection security Rule) command

This connection rule allows you to create an IPSec VPN between two systems. In other words, the consec rule allows you to enhance the security of communication through the firewall, not just restricting or filtering it.

Let's take a look at the netsh advfirewall consec see six different commands

To view the current state of the firewall, you will have to use this show command

Another command: Export command

This command allows you to export all current configurations of the firewall to a single file. This command is very useful, because you can back up all the configuration to the file, if you are not satisfied with the configuration has been made, you can use this file at any time to revert to the state before the modification.

Then we open the path and see that the Advfirewallpolicy.pol file has been created:

Firewall command

With this command you can add new inbound and outbound rules to your firewall. It also allows you to modify the rules in the firewall.

The following is an example of adding and removing a firewall rule: Add an inbound rule for Messenger.exe

Remove all inbound rules for local 21 ports:

netsh advfirewall firewall delete name rule Name=all protocol=tcp localport=21

Import command

The import command allows you to import the configuration of a firewall from a file. This command allows you to restore the firewall configuration you exported before using the Export command. The example below (when using this command is blocked by 360, allowing access:

Reset command

This command lets you reset the firewall policy to the default policy state. Be careful when you use this command, because once you type this command and press ENTER, it will no longer let you confirm that you really want to reset it and restore the firewall policy directly.

The specific use is as follows:

Set command

The SET command allows you to modify the different setting states of the firewall. There are 7 related context commands.

Here are some examples of using the SET command:

Let the firewall close all configuration files, and after entering the command, you can see the firewall shutdown prompt at the lower right corner:

Set the default blocking inbound and allow outbound traffic in all configuration files:

To turn on remote administration in all configuration files:

netsh advfirewall set allprofiles settings remotemanagement enable

Log disconnected connections in all configuration files:

Refer again to the show command:

This show command will allow you to view the settings and global properties in all the different configuration files.

netsh configuration Windows Firewall (advfirewall)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.