2

I wanted to block all in/out connections to a remote IP using netsh:

netsh advfirewall firewall add rule name="OUT RULE" dir=out interface=any action=block remoteip=<remoteIP>/32
netsh advfirewall firewall add rule name="IN RULE" dir=in interface=any action=block remoteip=<remoteIP>/32

But now the ping <remoteIP> still works.

I want to achieve something similar to the following Linux commands:

iptables -A OUTPUT -d <remoteIP> -j DROP
iptables -A INPUT -d <remoteIP> -j DROP

How can block that IP in Windows?

4
  • Do you know in which order your firewall rules apply? If the "allow ping" rule applies before the "block" one, the ping will still work. This is the same as having -p icmp -j ACCEPT before -s badip -j DROP in your iptables. Aug 2, 2017 at 11:44
  • I don't know in which order they are applied, but they are the first one based on the alphabetical order. Can I increase somehow their priority to overwrite all other rules? Aug 2, 2017 at 12:56
  • What type of traffic are you blocking? TCP, UDP or ICMP? A ping is an ICMP Aug 2, 2017 at 16:34
  • If I don't specify a protocol, I'm expecting to block everything. Aug 2, 2017 at 16:50

1 Answer 1

2

A command to block ICMP protocol:

netsh advfirewall firewall add rule name="Disable Ping" dir=out action=block protocol=icmpv4

and the same thing but for icmpv6.  Reply shall be “OK”.  And when you try to ping again, reply shall be “General Failure”.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .