Some days ago I need on multiple windows 10 systems add rule to allow rule on firewall which will allow ping application server. Instead of do it by clicking I prepared simple command which is adding rule on PC. I only needed ping so my command will look like that:
1 |
New-NetFirewallRule -DisplayName "Allow ping from server" -Direction Inbound -RemoteAddress 192.168.0.20 -Action Allow -Protocol ICMPv4 |
Also we can use this command to block some outbound traffic on specific port.
1 |
New-NetFirewallRule -DisplayName "Block outbound port" -Direction Outbound -LocalPort 1234 -Protocol TCP -Action Block |
And allow traffic for specific application:
1 |
New-NetFirewallRule -DisplayName "Allow App traffic" -Direction Outbound -Program "C:\app\app.exe" -Action Allow |