Something like this?
Save this as blockit.bat
:
@echo off
if "%1"=="list" (
netsh advfirewall firewall show rule Blockit | findstr RemoteIP
exit/b
)
:: Deleting existing block on ips
netsh advfirewall firewall delete rule name="Blockit"
:: Block new ips (while reading them from blockit.txt)
for /f %%i in (blockit.txt) do (
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=%%i
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=%%i
)
:: call this batch again with list to show the blocked IPs
call %0 list
Create a blockit.txt
with your IPs to block and run blockit
.
You can run blockit list
to check which IPs are blocked at the moment.
Note: This needs to be run as Administrator.
Edit: Didn't know if you wanted outgoing or incoming traffic blocked so i added both dir=in
and dir=out
. You can delete one or the other (or leave them both for both directions).