Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I’ve just learned that the firewall was stopping my application from communication to the internet.

Now that I know I have to set a hole in the NAT with “translation traversal” for the program and open specific UDP port. I would like to this through code if possible.

Do anyone know have do this in code(C#)?

Thanks again to everyone.

Update

I should make my self clear. Sorry about that.
I want to make a hole in the firewall to be able let my program communicate through that hole. That includes communication through a specific UDP port and a NAT Traversal.

Now. When I looked in windows security, I can see all programs that dos this. These programs must have made that change to the firewall under installation. In my mind that’s done in code.

Isn’t there some assembly that gives this ability.

Update 2

Ex
Windows 7
Start/Control Panel/System Security/Windows Firewall/Advanced settings/Allow programs to communicate through Windows Firewall/Allow programs and features/iTunes
It has public networking enabled. I didn’t do this changes?


Can anybody help me her.
Posted
Updated 22-Mar-11 5:29am
v3

You can't do this through code. Imagine the security implications that would arise if it was possible.
 
Share this answer
 
Comments
pluss400 22-Mar-11 10:02am    
When I install communication program like dropbox it dos the changes by it self. I dos have a client, server configuration. That has to be done in code. Right.
It really depends on what kind of firewall you have. I found this great article "Programmatically Controlling a UPnP-Capable Firewall"[^] that shows a way to do what you want. It has a couple of vb scripts utilizing CreateObject, so if you have a firewall that is UPnP enabled the examples should also be translateable to C#.

I hope this helps you gather some ideas.

Cheers and happy coding!

Modification:
Another great starter is this CP article: Programmatically disable/enable Windows firewall[^]. The interesting bit is right on top of said article:
"Click Browse tab -> Add C:\windows\system32\Hnetcfg.dll & Click COM tab -> Add NetFwTypeLib."
This allows you to gain access to these DLLs from your C# project. The CP article is in VB, but that should be a reasonable task for an accomplished programmer to port to C#.
 
Share this answer
 
v2
Comments
#realJSOP 22-Mar-11 8:12am    
And everybody and their brother that knows what they're doing security-wise recommends turning off PnP oin a router for that very reason.
Manfred Rudolf Bihy 22-Mar-11 8:22am    
It's his firewall and his security risk. He asked if there is a way so here it is.
#realJSOP 22-Mar-11 10:39am    
Maybe, but then again, maybe not... BTW, I am not the person that voted your answer with a 1.
Manfred Rudolf Bihy 22-Mar-11 10:45am    
No problem, I don't get excited over that anymore. :)
pluss400 22-Mar-11 10:23am    
When I install communication program like dropbox it dos the changes by it self. It dos have a client, server configuration ofcourse. That has to be done in code.

I want to WCF P2P that uses PNRP to be able communicate wold wide.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900