Block an IP Address with a Windows Firewall Rule

Create a deny rule for an IP or subnet with one PowerShell command — no GUI digging required.

WindowssecuritypowershellfirewallLow risk
Run `New-NetFirewallRule -DisplayName "Block Bad Host" -Direction Inbound -RemoteAddress 203.0.113.55 -Action Block` to ban that IP from inbound traffic.

01Command

Command
$ New-NetFirewallRule -DisplayName "Block Bad Host" -Direction Inbound -RemoteAddress 203.0.113.55 -Action Block

02What it does

-RemoteAddress accepts a single IP, an IP range like 203.0.113.0-203.0.113.255, or a CIDR subnet such as 10.0.0.0/8, so you can block a whole misbehaving network. Rules created this way appear in Windows Security > Firewall & network protection > Advanced settings and persist across reboots. Add a second rule with -Direction Outbound if you also want to stop your PC from talking to that host.

03Risk

RiskLow risk
RequirementsAdministrator PowerShell; supports single IPs, ranges, and CIDR subnets in -RemoteAddress.
!Warning: Blocking your router's or NAS's IP will break local services — verify the address before applying.

04Undo

Undo
$ Remove-NetFirewallRule -DisplayName "Block Bad Host"

05Sources

  • New-NetFirewallRule (NetSecurity)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents -DisplayName, -Direction, -RemoteAddress and -Action (Allow/Block) parameters with firewall rule examples.
  • NetSecurity module reference
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Module reference lists New-NetFirewallRule and Remove-NetFirewallRule for managing firewall rules.

Last verified: 2026-09-19 · Category: Security & Privacy

06Related solutions