从 C# 转发端口 [英] Port forwarding from C#

查看:62
本文介绍了从 C# 转发端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 C# 编写一个程序,将特定端口从路由器转发到计算机.这可能吗?

I would like to make a program in C# that would port forward a specific port from the router to the computer. Is this possible?

推荐答案

使用 NATUPnP 1.0 类型库 (NATUPNP.DLL) 可以使用 UPNP(假设您的设备支持该技术)转发端口) 或第三方库,如 Mono.Nat.

It is possible to forward a port using UPNP (assuming your device supports the technology) using NATUPnP 1.0 Type Library (NATUPNP.DLL) or a third party library like Mono.Nat.

如果您想在没有 UPNP 的情况下执行此操作,则难度会很大,因为您需要找到需要发送到设备(路由器)的消息类型以模拟用户添加端口.

If you want to do it without UPNP then it will be considerably harder since you will need to find what kind of message you will need to send to the device (router) to simulate a user adding a port.

对于 Mono.Nat,您可以在 UPNP 端口转发——简单的方法对于 NATUPnP.NET Framework:通过 UPnP(通用即插即用)通过 NAT 路由器进行通信

For Mono.Nat you can find an example at UPNP port forwarding – The easy way and for NATUPnP there is an example at .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)

这篇关于从 C# 转发端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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