Catalogue:
Delete enabled programs or ports
How to open Windows Firewall in Windows 11/10
Display current IP address:
\>netsh interface ip show address
Configuration for interface "Ethernet"
DHCP enabled: No
IP Address: 192.168.0.25
Subnet Prefix: 192.168.0.0/24 (mask 255.255.255.0)
Default Gateway: 192.168.0.1
Gateway Metric: 32
InterfaceMetric: 35
Configuration for interface "Loopback Pseudo-Interface 1"
DHCP enabled: No
IP Address: 127.0.0.1
Subnet Prefix: 127.0.0.0/8 (mask 255.0.0.0)
InterfaceMetric: 75
Change IP address:
\>netsh interface ip set addr Ethernet static 192.168.1.25 255.255.255.0 192.168.1.1
\>ipconfig
Windows IP Configuration
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : XXXX::XXXX:XXXX:XXXX:XXXX%N
IPv4 Address. . . . . . . . . . . : 192.168.1.25
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
Set DNS:
\>netsh interface ip set dns Ethernet static 202.96.69.38
\>netsh interface ip add dns Ethernet 219.148.204.66
\>netsh interface ip show dns
Configuration for interface "Ethernet"
Statically Configured DNS Servers: 202.96.69.38
219.148.204.66
Register with which suffix: Primary only
Configuration for interface "Loopback Pseudo-Interface 1"
Statically Configured DNS Servers: None
Register with which suffix: Primary only
About Firewall:
\>netsh advfirewall firewall add rule name=RULENAME dir=in program="C:\ProgramPath\AppName.exe" action=allow
Ok.
\>netsh advfirewall firewall show rule name=RULENAME
Rule Name: RULENAME
----------------------------------------------------------------------
Enabled: Yes
Direction: In
Profiles: Domain,Private,Public
Grouping:
LocalIP: Any
RemoteIP: Any
Protocol: Any
Edge traversal: No
Action: Allow
Enable a Port
\>netsh advfirewall firewall add rule name="Requirst to open inbound TCP/80" dir=in action=allow protocol=TCP localport=80
Delete enabled programs or ports
\>netsh advfirewall firewall delete rule name=RULENAME program="C:\ProgramPath\AppName.exe"
\>netsh advfirewall firewall delete rule name=RULENAME protocol=udp localport=500
Enable specific services
\>netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
\>netsh advfirewall firewall set rule group="Remote Desktop" new enable=Yes
Enable Windows firewall
\>netsh advfirewall set currentprofile state on
Restore policy defaults
\>netsh advfirewall reset
How to open Windows Firewall in Windows 11/10
- Click the Search icon or bar on the extreme left of the taskbar (Windows 10) OR press <Win><S> on the keyboard.
- Search for keywords 'Windows Defender Firewall'.
- Select Windows Defender Firewall from the result or click Open on the right pane.
Reference Links:
https://www.thewindowsclub.com/netsh-command-to-manage-windows-firewall
https://www.thewindowsclub.com/how-to-open-windows-firewall-using-different-methods