Windows – Block Inbound TCP Traffic For All IPs w/ Exceptions Using netsh

firewallnetshwindows

Trying to figure out a way to do this:

netsh advfirewall firewall add rule name="ES 9500 (Block)" dir=in
action=block protocol=TCP localport=9500

netsh advfirewall firewall
add rule name="ES 9500 (Allow)" dir=in action=allow protocol=TCP
localport=9500 remoteip=207.207.207.207

Doesn't seem that it's possible as "Override block rules" requires specifying specific machines: http://technet.microsoft.com/de-de/library/dd734783(v=ws.10).aspx.

Any way to do this on Windows?

Best Answer

Unless you have another rule in your windows firewall or you have changed the default behavior of the incoming connections, ALL incoming connections will be blocked by default.

So you have to start with the allow rules for incoming connections. Also, try adding the enable argument like so

netsh advfirewall firewall add rule name="ES 9500" dir=in action=allow 
remoteip=207.207.207.207/32 protocol=TCP localport=9500 enable=yes