Is there a Windows firewall, which I can access the whitelist with C#?

Started by
5 comments, last by Rich76 14 years ago
Without going into detail, I need a Windows firewall, which would allow a local C# application to change allowed incoming remote IPs (whitelist). Is there any thing available (hopefully free)? Thanks
Advertisement
Sorry. I'm realizing that this thread might not be appropriate for this forum.
In C++ and Vista+ there is an easy solution. http://www.codeproject.com/KB/IP/PacketFilter.aspx.
Thank you.

I found this as well:

http://www.codeproject.com/KB/IP/packetfilteringnet.aspx
One last question, is it possible to just run the following command line within the application?:

netsh firewall set portopening protocol = ALL port = 7239 name = "Port7239" mode = ENABLED scope = CUSTOM addresses = [IP addresses separated by commas]


Though, the application would need administrative rights..
You could create a Windows Service that runs with admin or local system credentials and can call netsh (or do anything else on the system). Combine it with the fact that the service can listen to requests from any application on the machine (or the network, if you so desire, but this is poison for security).

This way, you only need admin credentials to install the service, but not necessarily afterwards.

If you go this route, I recommend using WCF (Windows Communication Foundation) for the interprocess communication. It is very easy to establish protocol-independent links with it and you don't have to write any transport logic yourself.

There is also an API available for Windows Firewall, should you want to program it directly instead of via netsh.

Niko Suni

Quote:Original post by Nik02
You could create a Windows Service that runs with admin or local system credentials and can call netsh (or do anything else on the system). Combine it with the fact that the service can listen to requests from any application on the machine (or the network, if you so desire, but this is poison for security).

This way, you only need admin credentials to install the service, but not necessarily afterwards.

If you go this route, I recommend using WCF (Windows Communication Foundation) for the interprocess communication. It is very easy to establish protocol-independent links with it and you don't have to write any transport logic yourself.

There is also an API available for Windows Firewall, should you want to program it directly instead of via netsh.


Excellent. Thank you.

This topic is closed to new replies.

Advertisement