OPNsense Forum

English Forums => General Discussion => Topic started by: ืnut43150tier2 on March 24, 2019, 06:04:13 am

Title: Enable or disable Windows Firewall from Command Prompt.
Post by: ืnut43150tier2 on March 24, 2019, 06:04:13 am
Manage Windows Firewall from a command prompt
First, see if Windows Firewall is enabled on the server or computer. Type this command at a command prompt:

netsh advfirewall show allprofiles
Make sure you open an administrator command prompt (click Start, type CMD, then right click on Command Prompt and choose Run as Administrator). You should get something similar to what is shown below. :
สล็อตฝากไม่มีขั้นต่ำ (https://bit.ly/2undNXb)
(http://th.tipsandtricks.tech/images/27/netsh-advfirewall-cmd.png)

By default, you should see three separate listings here: Setting up a domain profile, personal profile Public profile settings and settings These three types match three states. You can place each network connection on your computer. If you connect to your home network and select Home Network, the system will use your personal profile settings.

State means if the firewall is on or off, the firewall policy tells you how incoming and outgoing policies are applied to each profile.

To disable the firewall for a specific profile, you will use the following command:

So if you want to disable all firewalls, you will use allprofiles instead of personal profiles If you want to reactivate it, place it on the end instead of closing it.
Open ports in the firewall using the command line.
Now what to do if you want to open a port in the firewall using the command line? too easy

Suppose you want to open port 3389 which is used for remote desktop in Windows. You will run this command:

netsh advfirewall firewall add rule name = "Open Remote Desktop" protocol = TCP dir = in localport = 3389 action = allow
This statement is quite long. But quite easy to break down You can add rules to names, select protocols (TCP or UDP), choose the direction (enter or exit), give the port number and select the action. (Allow or reject)

If you want to run this command, then go to see the apps that are allowed in the Windows Firewall. You will see that the Remote Desktop list has been checked:

(http://th.tipsandtricks.tech/images/27/remote-desktop-port.png)

If you want to open various ports, use a simple dash. For example, here I open ports 600 to 7000 for UDP outbound traffic:

netsh advfirewall firewall add rule name = "UDP ports" protocol = UDP dir = out localport = 6000-7000 action = allow
There are many advanced commands that you can use to manage all aspects of Windows Firewall. So make sure to use characters. /? At the end of any order to see all options and examples
Title: Re: Enable or disable Windows Firewall from Command Prompt.
Post by: hbc on March 24, 2019, 07:03:27 pm
Wrong forum? Or how does this affect OPNsense firewall?
Title: Re: Enable or disable Windows Firewall from Command Prompt.
Post by: weust on March 24, 2019, 10:18:40 pm
Also, use PowerShell instead of netsh. netsh is, or should be, deprecated.