NetNsCore 0.2.1
dotnet add package NetNsCore --version 0.2.1
NuGet\Install-Package NetNsCore -Version 0.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetNsCore" Version="0.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetNsCore" Version="0.2.1" />
<PackageReference Include="NetNsCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetNsCore --version 0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetNsCore, 0.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetNsCore@0.2.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetNsCore&version=0.2.1
#tool nuget:?package=NetNsCore&version=0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NetNsCore
A lightweight C# library for managing Linux network namespaces. Wraps unshare, setns, mount, and umount2 syscalls with a clean, disposable API. AOT-compatible, Linux-only, .NET 10+.
Usage
using NetNsCore;
// Create and enter a namespace — automatically restored on dispose
NetNs.Create("my_ns");
using (NetNs.Enter("my_ns"))
{
// code runs inside "my_ns"
}
NetNs.Delete("my_ns");
API
| Member | Description |
|---|---|
Create(name) |
Create a named network namespace |
Delete(name) |
Delete a named network namespace |
Exists(name) |
Check whether a named namespace exists |
List() |
List all namespace paths under /run/netns/ |
Open(name) |
Open a handle to a named namespace |
OpenCurrent() |
Open a handle to the current thread's namespace |
OpenRoot() |
Open a handle to the root (PID 1) namespace |
Enter(name) |
Enter a namespace; returns a Scope that restores the original on dispose |
EnterRoot() |
Enter the root namespace |
ns.Enter() |
Enter via handle |
ns.Clone() |
Clone handle (duplicates the file descriptor) |
ns.CreateSocket(af, type, proto) |
Create a Socket inside this namespace |
ns.CreateSocket(type, proto) |
Create a dual-mode Socket inside this namespace |
CreateSocket(name, af, type, proto) |
Create a Socket inside a named namespace |
CreateSocket(name, type, proto) |
Create a dual-mode Socket inside a named namespace |
ns.Id |
Unique UInt128 identifier |
ns.Descriptor |
Underlying FileDescriptor |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- LinuxCore (>= 0.1.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NetNsCore:
| Package | Downloads |
|---|---|
|
LibNlCore
NETLINK .NET wrappers |
GitHub repositories
This package is not used by any popular GitHub repositories.