1
echo@
netsh advfirewall firewall add rule name="test" dir=in action=block protocol=TCP remoteip=16.24.0.0/24,**from 157.175.0.0 to 157.175.255.255**,**from 15.184.0.0 to 15.184.255.255**,**from 15.185.0.0 to 15.185.255.255**
netsh advfirewall firewall add rule name="test" dir=out action=block protocol=TCP remoteip=16.24.0.0/24,**from 157.175.0.0 to 157.175.255.255**,**from 15.184.0.0 to 15.184.255.255**,**from 15.185.0.0 to 15.185.255.255**
start wf.msc
pause

I'm trying create a Windows batch file which can block IP addresses in my firewall.

It's working when I use one IP, but I need to block ranges, not only one. For example the range 15.185.0.0 to 15.185.255.255.

Compo
  • 36,585
  • 5
  • 27
  • 39
SPOTENK
  • 11
  • 1
  • I found the syntax for IP range, you can use dash (-) for example 157.175.0.0-157.175.255.255 – SPOTENK Apr 16 '23 at 01:19
  • Your example code showed that you wanted to include multiple ranges, but the comment above shows your solution for just one. Could you please use the answer area to submit a full solution for your shown problem code. _You could even mark it as your accepted answer._ – Compo Apr 16 '23 at 10:59
  • BTW, do you know what `157.175.0.0/16`, `15.184.0.0/16`, and `15.185.0.0/16` mean? Read up on CIDR, _(Classless Inter-Domain Routing)_, notation, to learn more. – Compo Apr 16 '23 at 11:25
  • @Compo thank you so much for let me know what is CIDR, BTW i tried to make all these IP's use /24 but It's didn't work and now I know why, thank you again – SPOTENK Apr 21 '23 at 05:37

1 Answers1

0

this is the answer to my question

echo@
netsh advfirewall firewall add rule name="example" dir=in action=block protocol=TCP remoteip=16.24.0.0/24,157.175.0.0-157.175.255.255,15.184.0.0-15.184.255.255,15.185.0.0-15.185.255.255
netsh advfirewall firewall add rule name="example" dir=out action=block protocol=TCP remoteip=16.24.0.0/24,157.175.0.0-157.175.255.255,15.184.0.0-15.184.255.255,15.185.0.0-15.185.255.255
start wf.msc
pause
Compo
  • 36,585
  • 5
  • 27
  • 39
SPOTENK
  • 11
  • 1