Windows 7 Use new-netFireWallRule to block a specific IP from connecting to any port

  • Thread starter Thread starter AlanMar20
  • Start date Start date
A

AlanMar20

I am running a java script as a Service on W10,2016,2012 machines using port 49999. I want to block a specific IP (say a.b.c.d) to connect to this service on the $SERVER.

Using PowerShell, I ran the following on the W2016 $SERVER:

PS C:> new-netfirewallrule -DisplayName "Block_Spam" -Direction Inbound -Protocol any -remoteAddress a.b.c.d -Action Block

Name : {b62c3d33-7871-4faa-896a-66a25327b64b}
DisplayName : Block_Spam
Description :
DisplayGroup :
Group :
Enabled : True
Profile : Any
Platform : {}
Direction : Inbound
Action : Block
......​


To test, 1) using machine $MyMachine (IP=a.b.c.d) I am still able to connect to service at 49999 using socket call, and

2) test-Netconnection from $MyMachine (a.b.c.d) also works:

PS C:> test-Netconnection $SERVER -port 49999

ComputerName : $SERVER

RemoteAddress : $SERVER-IP

RemotePort : 49999

InterfaceAlias : Ethernet

SourceAddress : $MyMachine(a.b.c.d)

TcpTestSucceeded : True

Why didn't it block the connection? Thanks.

Continue reading...
 
Back
Top