Skip to content

Latest commit

 

History

7 提交

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

仓库 files navigation

LoopbackNET

Easy way to create and remove loopback network interfaces on Windows (.NET Framework)

Utilizes devcon and netsh.

Privileges

An important note about this library - To use devcon.exe it must be run as an elevated process. This is currently enforced by making a check in LoopbackNET that the current process is elevated when trying to create new loopbacks.

Usage

Create new unnamed/name interface:

LoopbackNET.Loopback.Create();
LoopbackNET.Loopback.Create("myLoopback");

If you want to remove the interface when you are done, keep the result:

LoopbackInterface iface = LoopbackNET.Loopback.Create();
... more code ...
iface.Remove();

Another option is to use the 'using' keyword since LoopbackInterface implements IDisposable:

using(LoopbackInterface iface = LoopbackNET.Loopback.Create())
{
  ... more code ...
}

Working with SharpPcap ( + Npcap )

While SharpPcap is not a requirement for this library, you might want to use your newly created loopback interface with a SharpPcap device object.

You can use the 网络Interface ID of the created loopback to find the right device like so:

LoopbackInterface iface = LoopbackNET.Loopback.Create();
string interfaceId = iface.网络Interface.Id;
ICaptureDevice dev = SharpPcap.CaptureDeviceList.Instance.Single(device => device.Name.Contains(interfaceId));

关于

Easy way to create and remove loopback network interfaces on Windows (.NET Framework)

Topics

Resources

Stars

3 stars

关注者

1 watching

复刻s

发布

Used by

贡献者

Languages