Windows Firewall can be managed using the Command Prompt with the netsh
utility. Here is a comprehensive list of commands to configure and manage Windows Firewall:
Basic Commands
1.View the status of Windows Firewall:
netsh advfirewall show allprofiles
2.Enable Windows Firewall:
netsh advfirewall set allprofiles state on
3.Disable Windows Firewall:
netsh advfirewall set allprofiles state off
Profile-Specific Commands
1.Enable Firewall for a specific profile (domain/private/public):
netsh advfirewall set domainprofile state on
netsh advfirewall set privateprofile state on
netsh advfirewall set publicprofile state on
2.Disable Firewall for a specific profile (domain/private/public):
netsh advfirewall set domainprofile state off
netsh advfirewall set privateprofile state off
netsh advfirewall set publicprofile state off
Configuring Inbound and Outbound Rules
1.Add a new inbound rule:
netsh advfirewall firewall add rule name="RuleName" dir=in action=allow protocol=TCP localport=PortNumber
2.Add a new outbound rule:
netsh advfirewall firewall add rule name="RuleName" dir=out action=allow protocol=TCP remoteport=PortNumber
3.Delete an existing rule:
netsh advfirewall firewall delete rule name="RuleName"
Enabling/Disabling Rules
1.Enable a Rule
netsh advfirewall firewall set rule name="RuleName" new enable=yes
2.Disable a rule:
netsh advfirewall firewall set rule name="RuleName" new enable=no
Configuring Notifications and Logging
1.Enable notifications for blocked connections:
netsh advfirewall set allprofiles settings inboundusernotification enable
2.Disable notifications for blocked connections:
netsh advfirewall set allprofiles settings inboundusernotification disable
3.Enable logging:
netsh advfirewall set allprofiles logging filename "C:\Path\To\Log\pfirewall.log" maxfilesize=4096
4.Disable logging:
netsh advfirewall set allprofiles logging disabled
Resetting Firewall Settings
1.Reset all firewall settings to default:
netsh advfirewall reset
Configuring Specific Programs
1.Allow a program through the firewall:
netsh advfirewall firewall add rule name="AllowProgram" dir=in action=allow program="C:\Path\To\Program.exe"
2.Block a program through the firewall:
netsh advfirewall firewall add rule name="BlockProgram" dir=in action=block program="C:\Path\To\Program.exe"
Configuring Ports
1.Allow a specific port:
netsh advfirewall firewall add rule name="AllowPort" dir=in action=allow protocol=TCP localport=PortNumber
2.Block a specific port:
netsh advfirewall firewall add rule name="BlockPort" dir=in action=block protocol=TCP localport=PortNumber
Additional Commands
View all firewall rules:
netsh advfirewall firewall show rule name=all
2.Export firewall configuration to a file:
netsh advfirewall export "C:\Path\To\File\firewall-config.wfw"
3.Import firewall configuration from a file:
netsh advfirewall import "C:\Path\To\File\firewall-config.wfw"
Comments
Post a Comment