开发者

How to Create a Virtual Network Adapter in .NET?

开发者 https://www.devze.com 2022-12-19 13:23 出处:网络
I would like to create/add a virtual network adapter to a client operating system at runtime (via code), preferably in C#. Something similar to that of what VirtualBox/VMware/Himachi creates when you

I would like to create/add a virtual network adapter to a client operating system at runtime (via code), preferably in C#. Something similar to that of what VirtualBox/VMware/Himachi creates when you install their software. I am guessing this will require some C/C++ shenanigans for the driver integration, but if it is doable with only C#, all the better.

I am aware of OpenVPN, their stuff is primarily in C, and I am also aware of the TUN/TAP drivers floating around, I just didn't know if these were the only solutions not requiring me creating a开发者_如何学C fully loaded network driver for Windows.


If you need simple funcionality then you can use Microsoft Loopback Adapter. To install it use devcon tool. Here is some info about it http://support.microsoft.com/kb/311272. devcon -r install %WINDIR%\Inf\Netloop.inf *MSLOOP After that you can use WMI query with C# to obtain new connection name and then netsh to configure it (ie. netsh int ip set address name="Local Area Connection 2" static 192.168.0.3 255.0.0.0)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号