Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
Enable or disable Windows Firewall from Command Prompt.
« previous
next »
Print
Pages: [
1
]
Author
Topic: Enable or disable Windows Firewall from Command Prompt. (Read 4872 times)
ืnut43150tier2
Newbie
Posts: 5
Karma: 0
Enable or disable Windows Firewall from Command Prompt.
«
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. :
สล็อตฝากไม่มีขั้นต่ำ
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:
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
Logged
hbc
Hero Member
Posts: 501
Karma: 47
Re: Enable or disable Windows Firewall from Command Prompt.
«
Reply #1 on:
March 24, 2019, 07:03:27 pm »
Wrong forum? Or how does this affect OPNsense firewall?
Logged
Intel(R) Xeon(R) Silver 4116 CPU @ 2.10GHz (24 cores)
256 GB RAM, 300GB RAID1, 3x4 10G Chelsio T540-CO-SR
weust
Hero Member
Posts: 650
Karma: 57
Re: Enable or disable Windows Firewall from Command Prompt.
«
Reply #2 on:
March 24, 2019, 10:18:40 pm »
Also, use PowerShell instead of netsh. netsh is, or should be, deprecated.
Logged
Hobbyist at home, sysadmin at work. Sometimes the first is mixed with the second.
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
Enable or disable Windows Firewall from Command Prompt.