This will block IP 192.169.0.10
Code:netsh advfirewall firewall add rule name="IP Block" dir=out interface=any action=block remoteip=192.169.0.10/32
Hi guys,
I need to make a patch that when running, will block all requests to a specific URL. Has anyone done that before if so would love a code snippet!
I know I can just add it to the hosts file, or even make a program to add it to add it to the hosts file automatically but there is certain times when access is needed, so I only want to block it when my patch is running and unblock it when the patch is closed.
Any pointers or help?
thanks
This will block IP 192.169.0.10
Code:netsh advfirewall firewall add rule name="IP Block" dir=out interface=any action=block remoteip=192.169.0.10/32
thanks for that code.
After more investigation I think I will write to the hosts file, then delete the entry again when my application is closed. Reason being the above code I suspect will only work for people with windows firewall enabled and I cant find any other way to block packets inside c# or c++
Ok. Now you have me curious. What are you trying to do? What is the real purpose of the app (not just a repeat of what you already described)?
To me it would be easier to grab an old and cheap managed lan switch and create an access list for each port and just move the connection to the port with the corresponding access list you need at the time. Clip. Unclip. You’re done.
i also don't understand it otherwise.
You can of course write an Integerated Proxy or DNS Server to your Application and set the OS Proxy-Settings, but i don't understand myself where is the Problem with Windows Firewall or /etc/hosts file