The netsh ipsec
and netsh firewall
contexts are provided for backwards-compatibility with Windows 2000/XP/2003. Both were good for working remotely with older versions of Windows, and for configuring policies for mixed environments. Now that all these versions of Windows are EOL, both these contexts have become deprecated.
For these features in all current versions of Windows, use the netsh advfirewall
context instead.
(Even before, you would have used netsh firewall
instead of netsh ipsec
for blocking an IP address. Secondly, netsh ipsec
doesn't have command add
(including add policy
), but only static add filter|filter(action|list)|policy|rule
and dynamic add (q|m)mpolicy|rule
.)
For blocking a single IP (198.51.100.108
from RFC 5737 TEST-NET-2
):
netsh advfirewall firewall add rule name="IP Block" ^
dir=in interface=any action=block remoteip=198.51.100.108/32
You can now see your rule with netsh advfirewall firewall show rule name="IP Block"
:
Rule Name: IP Block
----------------------------------------------------------------------
Enabled: Yes
Direction: In
Profiles: Domain,Private,Public
Grouping:
LocalIP: Any
RemoteIP: 198.51.100.108/32
Protocol: Any
Edge traversal: No
Action: Block
Ok.
And delete it with a matching delete rule
criteria; in this case name
and remoteip
are sufficient:
netsh advfirewall firewall delete rule name="IP Block" remoteip=198.51.100.108/32`
For detailed information, see Netsh AdvFirewall
Firewall Commands or netsh advfirewall ?