穿越防火墙 [英] Get through the firewall

查看:126
本文介绍了穿越防火墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我刚刚了解到防火墙阻止了我的应用程序与互联网的通信.

现在,我知道我必须在NAT中为该程序设置一个转换遍历"漏洞,并打开特定的UDP端口.我希望通过代码来做到这一点.

有人知道在代码(C#)中这样做吗?

再次感谢大家.

更新

我应该说清楚.抱歉.
我想在防火墙上打一个洞,以使我的程序能够通过该漏洞进行通信.其中包括通过特定UDP端口和NAT遍历的通信.

现在.当我查看Windows安全性时,可以看到执行此操作的所有程序.这些程序必须已对正在安装的防火墙进行了更改.在我看来,这是通过代码完成的.

没有可以提供这种功能的组件.

更新2


Windows 7
开始/控制面板/系统安全性/Windows防火墙/高级设置/允许程序通过Windows防火墙进行通信/允许程序和功能/iTunes
它启用了公共网络.我没有进行此更改吗?


有人可以帮我吗.

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.

推荐答案

您无法通过代码来完成此操作.想象一下,如果可能的话,会带来安全隐患.
You can''t do this through code. Imagine the security implications that would arise if it was possible.


这实际上取决于您使用的是哪种防火墙.我找到了这篇很棒的文章以编程方式控制支持UPnP的防火墙" [以编程方式禁用/启用Windows防火墙 [
这使您可以从C#项目中访问这些DLL.有关CP的文章位于VB中,但对于有经验的程序员来说,移植到C#应该是一项合理的任务.
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#.


这篇关于穿越防火墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆