VOOZH about

URL: https://www.nuget.org/packages/IPNetwork2/

โ‡ฑ NuGet Gallery | IPNetwork2 4.3.0


๏ปฟ

๐Ÿ‘ Image
IPNetwork2 4.3.0

dotnet add package IPNetwork2 --version 4.3.0
 
 
NuGet\Install-Package IPNetwork2 -Version 4.3.0
 
 
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="IPNetwork2" Version="4.3.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IPNetwork2" Version="4.3.0" />
 
Directory.Packages.props
<PackageReference Include="IPNetwork2" />
 
Project file
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 IPNetwork2 --version 4.3.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IPNetwork2, 4.3.0"
 
 
#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 IPNetwork2@4.3.0
 
 
#: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=IPNetwork2&version=4.3.0
 
Install as a Cake Addin
#tool nuget:?package=IPNetwork2&version=4.3.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

IPNetwork

๐Ÿ‘ Nuget
๐Ÿ‘ Nuget
๐Ÿ‘ Chocolatey
๐Ÿ‘ Homebrew
๐Ÿ‘ AppVeyor Build Status
๐Ÿ‘ FOSSA Status
๐Ÿ‘ Coverage Status
๐Ÿ‘ GitHub last commit
๐Ÿ‘ CodeFactor
๐Ÿ‘ SonarCloud
๐Ÿ‘ .NET
๐Ÿ‘ Lines of Code
๐Ÿ‘ Maintainability Rating
๐Ÿ‘ Coverage
๐Ÿ‘ Technical Debt
๐Ÿ‘ Quality Gate Status
๐Ÿ‘ Code Smells
๐Ÿ‘ Reliability Rating
๐Ÿ‘ Duplicated Lines (%)
๐Ÿ‘ Vulnerabilities
๐Ÿ‘ Bugs
๐Ÿ‘ Security Rating
๐Ÿ‘ Sponsor

IPNetwork command line and C# library take care of complex network, IP, IPv4, IPv6, netmask, CIDR, subnet, subnetting, supernet, and supernetting calculation for .NET developers. It works with IPv4 as well as IPv6, is written in C#, has a light and clean API, and is fully unit-tested.


IPNetwork utility classes for .Net

IPNetwork utility classes take care of complex network, IP, IPv4, IPv6, netmask, CIDR, subnet, subnetting, supernet, and supernetting calculation for .NET developers. It works with IPv4 as well as IPv6, is written in C#, has a light and clean API, and is fully unit-tested with 100% code coverage.


Installation

CLI (Native AOT binary, no .NET runtime required)

macOS / Linux (Homebrew)

brew install lduchosal/ipnetwork/ipnetwork

Windows (Chocolatey)

choco install ipnetwork

Linux (manual)

# x64
curl -sL https://github.com/lduchosal/ipnetwork/releases/latest/download/ipnetwork-linux-x64.tar.gz | tar xz -C /usr/local/bin

# ARM64
curl -sL https://github.com/lduchosal/ipnetwork/releases/latest/download/ipnetwork-linux-arm64.tar.gz | tar xz -C /usr/local/bin
.NET Library
PM> nuget install IPNetwork2

Example 1 (IPv4)

IPNetwork2 ipnetwork = IPNetwork2.Parse("192.168.168.100/24");

Console.WriteLine("Network : {0}", ipnetwork.Network);
Console.WriteLine("Cidr : {0}", ipnetwork.Cidr);
Console.WriteLine("Netmask : {0}", ipnetwork.Netmask);
Console.WriteLine("Broadcast : {0}", ipnetwork.Broadcast);

Console.WriteLine("FirstUsable : {0}", ipnetwork.FirstUsable);
Console.WriteLine("LastUsable : {0}", ipnetwork.LastUsable);
Console.WriteLine("Usable : {0}", ipnetwork.Usable);

Console.WriteLine("First : {0}", ipnetwork.First);
Console.WriteLine("Last : {0}", ipnetwork.Last);
Console.WriteLine("Total : {0}", ipnetwork.Total);

Output

Network : 192.168.168.0
Cidr : 24
Netmask : 255.255.255.0
Broadcast : 192.168.168.255

FirstUsable : 192.168.168.1
LastUsable : 192.168.168.254
Usable : 254

First : 192.168.168.0
Last : 192.168.168.255
Total : 256

Example 2 (IPv6)

IPNetwork2 ipnetwork = IPNetwork2.Parse("2001:0db8::/64");

Console.WriteLine("Network : {0}", ipnetwork.Network);
Console.WriteLine("Netmask : {0}", ipnetwork.Netmask);
Console.WriteLine("Broadcast : {0}", ipnetwork.Broadcast);
Console.WriteLine("FirstUsable : {0}", ipnetwork.FirstUsable);
Console.WriteLine("LastUsable : {0}", ipnetwork.LastUsable);
Console.WriteLine("Usable : {0}", ipnetwork.Usable);
Console.WriteLine("Cidr : {0}", ipnetwork.Cidr);

Output

Network : 2001:db8::
Netmask : ffff:ffff:ffff:ffff::
Broadcast :
FirstUsable : 2001:db8::
LastUsable : 2001:db8::ffff:ffff:ffff:ffff
Usable : 18446744073709551616
Cidr : 64

Example 3 (IPv6)

IPNetwork2 ipnetwork = IPNetwork2.Parse("2001:0db8::/64");

IPAddress ipaddress = IPAddress.Parse("2001:0db8::1");
IPAddress ipaddress2 = IPAddress.Parse("2001:0db9::1");

IPNetwork2 ipnetwork2 = IPNetwork2.Parse("2001:0db8::1/128");
IPNetwork2 ipnetwork3 = IPNetwork2.Parse("2001:0db9::1/64");

bool contains1 = ipnetwork.Contains(ipaddress);
bool contains2 = ipnetwork.Contains(ipaddress2);
bool contains3 = ipnetwork.Contains(ipnetwork2);
bool contains4 = ipnetwork.Contains(ipnetwork3);

bool overlap1 = ipnetwork.Overlap(ipnetwork2);
bool overlap2 = ipnetwork.Overlap(ipnetwork3);

Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipaddress, contains1);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipaddress2, contains2);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipnetwork2, contains3);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipnetwork3, contains4);


Console.WriteLine("{0} overlap {1} : {2}", ipnetwork, ipnetwork2, overlap1);
Console.WriteLine("{0} overlap {1} : {2}", ipnetwork, ipnetwork3, overlap2);

Output

2001:db8::/64 contains 2001:db8::1 : True
2001:db8::/64 contains 2001:db9::1 : False
2001:db8::/64 contains 2001:db8::1/128 : True
2001:db8::/64 contains 2001:db9::/64 : False
2001:db8::/64 overlap 2001:db8::1/128 : True
2001:db8::/64 overlap 2001:db9::/64 : False

Example 4 (IPv6)

IPNetwork2 wholeInternet = IPNetwork2.Parse("::/0");
byte newCidr = 2;
IPNetworkCollection subneted = wholeInternet.Subnet(newCidr);

Console.WriteLine("{0} was subnetted into {1} subnets", wholeInternet, subneted.Count);
Console.WriteLine("First: {0}", subneted[0]);
Console.WriteLine("Last : {0}", subneted[subneted.Count - 1]);
Console.WriteLine("All :");

foreach (IPNetwork2 ipnetwork in subneted) {
 Console.WriteLine("{0}", ipnetwork);
}

Output

::/0 was subnetted into 4 subnets
First: ::/2
Last : c000::/2
All :
::/2
4000::/2
8000::/2
c000::/2

Example 5 (IPv6)

IPNetwork2 ipnetwork1 = IPNetwork2.Parse("2001:0db8::/32");
IPNetwork2 ipnetwork2 = IPNetwork2.Parse("2001:0db9::/32");
IPNetwork2[] ipnetwork3 = IPNetwork2.Supernet(new[] { ipnetwork1, ipnetwork2 });

Console.WriteLine("{0} + {1} = {2}", ipnetwork1, ipnetwork2, ipnetwork3[0]);

Output

2001:db8::/32 + 2001:db9::/32 = 2001:db8::/31

Example 6

IPNetwork2 ipnetwork = IPNetwork2.Parse("192.168.0.0/24");
IPAddress ipaddress = IPAddress.Parse("192.168.0.100");
IPAddress ipaddress2 = IPAddress.Parse("192.168.1.100");

IPNetwork2 ipnetwork2 = IPNetwork2.Parse("192.168.0.128/25");
IPNetwork2 ipnetwork3 = IPNetwork2.Parse("192.168.1.1/24");

bool contains1 = ipnetwork.Contains(ipaddress);
bool contains2 = ipnetwork.Contains(ipaddress2);
bool contains3 = ipnetwork.Contains(ipnetwork2);
bool contains4 = ipnetwork.Contains(ipnetwork3);

bool overlap1 = ipnetwork.Overlap(ipnetwork2);
bool overlap2 = ipnetwork.Overlap(ipnetwork3);

Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipaddress, contains1);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipaddress2, contains2);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipnetwork2, contains3);
Console.WriteLine("{0} contains {1} : {2}", ipnetwork, ipnetwork3, contains4);

Console.WriteLine("{0} overlap {1} : {2}", ipnetwork, ipnetwork2, overlap1);
Console.WriteLine("{0} overlap {1} : {2}", ipnetwork, ipnetwork3, overlap2); A

Output

192.168.0.0/24 contains 192.168.0.100 : True
192.168.0.0/24 contains 192.168.1.100 : False
192.168.0.0/24 contains 192.168.0.128/25 : True
192.168.0.0/24 contains 192.168.1.0/24 : False
192.168.0.0/24 overlap 192.168.0.128/25 : True
192.168.0.0/24 overlap 192.168.1.0/24 : False

Example 7

IPNetwork2 iana_a_block = IPNetwork2.IANA_ABLK_RESERVED1;
IPNetwork2 iana_b_block = IPNetwork2.IANA_BBLK_RESERVED1;
IPNetwork2 iana_c_block = IPNetwork2.IANA_CBLK_RESERVED1;

Console.WriteLine("IANA_ABLK_RESERVED1 is {0}", iana_a_block);
Console.WriteLine("IANA_BBLK_RESERVED1 is {0}", iana_b_block);
Console.WriteLine("IANA_CBLK_RESERVED1 is {0}", iana_c_block);

Output

IANA_ABLK_RESERVED1 is 10.0.0.0/8
IANA_BBLK_RESERVED1 is 172.16.0.0/12
IANA_CBLK_RESERVED1 is 192.168.0.0/16

Example 8

IPNetwork2 wholeInternet = IPNetwork2.Parse("0.0.0.0/0");
byte newCidr = 2;
IPNetworkCollection subneted = wholeInternet.Subnet(newCidr);

Console.WriteLine("{0} was subnetted into {1} subnets", wholeInternet, subneted.Count);
Console.WriteLine("First: {0}", subneted[0]);
Console.WriteLine("Last : {0}", subneted[subneted.Count - 1]);
Console.WriteLine("All :");

foreach (IPNetwork2 ipnetwork in subneted)
{
 Console.WriteLine("{0}", ipnetwork);
}

Output

0.0.0.0/0 was subnetted into 4 subnets
First: 0.0.0.0/2
Last : 192.0.0.0/2
All :
0.0.0.0/2
64.0.0.0/2
128.0.0.0/2
192.0.0.0/2

Example 9 Supernet

IPNetwork2 ipnetwork1 = IPNetwork2.Parse("192.168.0.0/24");
IPNetwork2 ipnetwork2 = IPNetwork2.Parse("192.168.1.0/24");
IPNetwork2[] ipnetwork3 = IPNetwork2.Supernet(new[]{ipnetwork1, ipnetwork2});

Console.WriteLine("{0} + {1} = {2}", ipnetwork1, ipnetwork2, ipnetwork3[0]);

Output

192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23

Example 9 Operator +

IPNetwork2 ipnetwork1 = IPNetwork2.Parse("192.168.0.0/24");
IPNetwork2 ipnetwork2 = IPNetwork2.Parse("192.168.1.0/24");
IPNetwork2[] ipnetwork3 = ipnetwork1 + ipnetwork2;

Console.WriteLine("{0} + {1} = {2}", ipnetwork1, ipnetwork2, ipnetwork3[0]);

Output

192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23

Example 10 - ClassLess network parse

If you don't specify the network cidr, IPNetwork will try to guess the CIDR for you. There are two strategies to guess ClassFull (default) and ClassLess.

ClassFull (default strategy)

is based on the default Class A, B or C networks. IPV4 :

  • Class A: 0 - 127 with a mask of 255.0.0.0 (/8)
  • Class B: 128 - 191 with a mask of 255.255.0.0 (/16)
  • Class C: 192 - 223 with a mask of 255.255.255.0 (/24)

IPV6 : /64

ClassLess

IPV4 : /32 IPV6 : /128

NetworkAware

IPV4 :

Rule of thumb โ€ข Ends with .0 โ†’ /24 โ€ข Ends with .0.0 or .255.255 โ†’ /16 โ€ข Ends with .0.0.0 or .255.255.255 โ†’ /8 โ€ข Else โ†’ /32

IPV6 :

Rule of thumb โ€ข Ends with :0000 โ†’ /112 โ€ข Ends with :0000:0000 โ†’ /96 โ€ข Ends with three trailing :0000 โ†’ /80 โ€ข โ€ฆ โ€ข Ends with four trailing :0000 โ†’ /64 โ€ข Else โ†’ /128

IPv4
IPNetwork2 defaultParse= IPNetwork2.Parse("192.168.0.0"); // default to ClassFull
IPNetwork2 classFullParse = IPNetwork2.Parse("192.168.0.0", CidrGuess.ClassFull);
IPNetwork2 classLessParse = IPNetwork2.Parse("192.168.0.0", CidrGuess.ClassLess);
IPNetwork2 networkAwareParse = IPNetwork2.Parse("192.168.0.0", CidrGuess.NetworkAware);

Console.WriteLine("IPV4 Default Parse : {0}", defaultStrategy);
Console.WriteLine("IPV4 ClassFull Parse : {0}", classFullParse);
Console.WriteLine("IPV4 ClassLess Parse : {0}", classLessParse);
Console.WriteLine("IPV4 NetworkAware Parse : {0}", networkAwareParse);

Output

IPV4 Default Parse : 192.168.0.0/24
IPV4 ClassFull Parse : 192.168.0.0/24
IPV4 ClassLess Parse : 192.168.0.0/32
IPV4 NetworkAware Parse : 192.168.0.0/16
IPv6
IPNetwork2 defaultParse = IPNetwork2.Parse("::1"); // default to ClassFull
IPNetwork2 classFullParse = IPNetwork2.Parse("::1", CidrGuess.ClassFull);
IPNetwork2 classLessParse = IPNetwork2.Parse("::1", CidrGuess.ClassLess);
IPNetwork2 networkAwareParse = IPNetwork2.Parse("::1", CidrGuess.NetworkAware);

Console.WriteLine("IPV6 Default Parse : {0}", defaultParse);
Console.WriteLine("IPV6 ClassFull Parse : {0}", classFullParse);
Console.WriteLine("IPV6 ClassLess Parse : {0}", classLessParse);
Console.WriteLine("IPV6 NetworkAware Parse : {0}", networkAwareParse);

Output

IPV6 Default Parse : ::/64
IPV6 ClassFull Parse : ::/64
IPV6 ClassLess Parse : ::1/128
IPV6 ClassLess Parse : ::1/128

Example 11 - Subtract network class

Here's a C# implementation for IP network symmetric difference (subtraction)

IPv4
// Prepare
var network1 = IPNetwork2.Parse("0.0.0.0", 0);
var network2 = IPNetwork2.Parse("10.0.0.1", 32);

// Act
var result = network1.Subtract(network2);

// Assert
string ips = string.Join(", ", result);
Console.WriteLine("{0}", ips);

Resut:

 0.0.0.0/5, 8.0.0.0/7, 10.0.0.0/32, 10.0.0.2/31, 10.0.0.4/30, 10.0.0.8/29,
 10.0.0.16/28, 10.0.0.32/27, 10.0.0.64/26, 10.0.0.128/25, 10.0.1.0/24,
 10.0.2.0/23, 10.0.4.0/22, 10.0.8.0/21, 10.0.16.0/20, 10.0.32.0/19, 10.0.64.0/18,
 10.0.128.0/17, 10.1.0.0/16, 10.2.0.0/15, 10.4.0.0/14, 10.8.0.0/13, 10.16.0.0/12,
 10.32.0.0/11, 10.64.0.0/10, 10.128.0.0/9, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4,
 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/1

IPv6
// Prepare
var network1 = IPNetwork2.Parse("::", 0);
var network2 = IPNetwork2.Parse("::", 1);

// Act
var result = network1.Subtract(network2);

// Assert
string ips = string.Join(", ", result);
Console.WriteLine("{0}", ips);

Resut:

8000::/1

operator -
// Prepare
var network1 = IPNetwork2.Parse("0.0.0.0", 0);
var network2 = IPNetwork2.Parse("10.0.0.1", 32);

// Act
var result = network1 - network2;

// Assert
string ips = string.Join(", ", result);
Console.WriteLine("{0}", ips);

Resut:

 0.0.0.0/5, 8.0.0.0/7, 10.0.0.0/32, 10.0.0.2/31, 10.0.0.4/30, 10.0.0.8/29,
 10.0.0.16/28, 10.0.0.32/27, 10.0.0.64/26, 10.0.0.128/25, 10.0.1.0/24,
 10.0.2.0/23, 10.0.4.0/22, 10.0.8.0/21, 10.0.16.0/20, 10.0.32.0/19, 10.0.64.0/18,
 10.0.128.0/17, 10.1.0.0/16, 10.2.0.0/15, 10.4.0.0/14, 10.8.0.0/13, 10.16.0.0/12,
 10.32.0.0/11, 10.64.0.0/10, 10.128.0.0/9, 11.0.0.0/8, 12.0.0.0/6, 16.0.0.0/4,
 32.0.0.0/3, 64.0.0.0/2, 128.0.0.0/1

IPv6 Unique Local Address (ULA)

Unique Local Addresses are IPv6 addresses in the range fc00::/7 that are not routed on the public Internet. They are the IPv6 equivalent of private IPv4 addresses (e.g. 10.0.0.0/8, 192.168.0.0/16).

// Generate a random ULA prefix
var randomUla = UniqueLocalAddress.GenerateUlaPrefix();
Console.WriteLine($"Random ULA: {randomUla}"); // e.g., fd12:3456:789a::/48

// Create subnets with int subnet IDs (CLS-compliant)
var subnet1 = UniqueLocalAddress.CreateUlaSubnet(randomUla, 1);
var subnet2 = UniqueLocalAddress.CreateUlaSubnet(randomUla, 2);
var maxSubnet = UniqueLocalAddress.CreateUlaSubnet(randomUla, UniqueLocalAddress.MaxSubnetId);

Console.WriteLine($"Subnet 1: {subnet1}"); // e.g., fd12:3456:

ParseRange and TryParseRange

A C# utility for converting IP address ranges into optimal CIDR blocks, supporting both IPv4 and IPv6 addresses. Both IPv4 and IPv6 ranges are supported The algorithm generates the minimal set of CIDR blocks that exactly cover the specified range Input format must be "startIP-endIP" with a single hyphen separator Whitespace around IP addresses is automatically trimmed Mixed IPv4/IPv6 ranges are not supported (both addresses must be the same family)

IPv4 Example

string ipv4Range = "192.168.1.45 - 192.168.1.65";
var ipv4Blocks = IPNetwork2.ParseRange(ipv4Range);

Console.WriteLine($"CIDR blocks for {ipv4Range}:");
foreach (var block in ipv4Blocks)
{
Console.WriteLine($" {block}");
}

Output

CIDR blocks for 192.168.1.45 - 192.168.1.65:
 192.168.1.45/32
 192.168.1.46/31
 192.168.1.48/28
 192.168.1.64/31

IPv6 Example

string ipv6Range = "2001:db8::1000 - 2001:db8::1fff";
var ipv6Blocks = IPNetwork2.ParseRange(ipv6Range);

Console.WriteLine($"CIDR blocks for {ipv6Range}:");
foreach (var block in ipv6Blocks)
{
Console.WriteLine($" {block}");
}

Ouput

CIDR blocks for 2001:db8::1000 - 2001:db8::1fff:
 2001:db8::1000/116

IPNetwork utility command line

IPNetwork utility command line take care of complex network, ip, netmask, subnet, cidr calculation for command line. It works with IPv4, it is written in C# and has a light and clean API and is fully unit tested.

Installation

choco install ipnetwork

Below some examples :


Provide at least one ipnetwork
Usage: ipnetwork [-inmcbflu] [-d cidr|-D] [-h|-s cidr|-S|-w|-W|-x|-C network|-o network] networks ..
Version: 3.2.0

Print options
 -i : network
 -n : network address
 -m : netmask
 -c : cidr
 -b : broadcast
 -f : first usable ip address
 -l : last usable ip address
 -u : number of usable ip addresses
 -t : total number of ip addresses

Parse options
 -d cidr : use cidr if not provided (default /32)
 -D : IPv4 only - use default cidr (ClassA/8, ClassB/16, ClassC/24)

Actions
 -h : help message
 -s cidr : split network into cidr subnets
 -w : supernet networks into smallest possible subnets
 -W : supernet networks into one single subnet
 -x : list all ipadresses in networks
 -C network : network contain networks
 -o network : network overlap networks
 -S network : substract network from subnet

networks : one or more network addresses
 (1.2.3.4 10.0.0.0/8 10.0.0.0/255.0.0.0 2001:db8::/32 2001:db8:1:2:3:4:5:6/128 )

Example 10

Display ipnetwork informations :

c:\> ipnetwork 10.0.0.0/8

IPNetwork : 10.0.0.0/8
Network : 10.0.0.0
Netmask : 255.0.0.0
Cidr : 8
Broadcast : 10.255.255.255
FirstUsable : 10.0.0.1
LastUsable : 10.255.255.254
Usable : 16777214

Example 11

Split network into cidr

c:\> ipnetwork -s 9 10.0.0.0/8

IPNetwork : 10.0.0.0/9
Network : 10.0.0.0
Netmask : 255.128.0.0
Cidr : 9
Broadcast : 10.127.255.255
FirstUsable : 10.0.0.1
LastUsable : 10.127.255.254
Usable : 8388606
--
IPNetwork : 10.128.0.0/9
Network : 10.128.0.0
Netmask : 255.128.0.0
Cidr : 9
Broadcast : 10.255.255.255
FirstUsable : 10.128.0.1
LastUsable : 10.255.255.254
Usable : 8388606

Example 12

supernet networks into smallest possible subnets

C:\>ipnetwork -w 192.168.0.0/24 192.168.1.0/24

IPNetwork : 192.168.0.0/23
Network : 192.168.0.0
Netmask : 255.255.254.0
Cidr : 23
Broadcast : 192.168.1.255
FirstUsable : 192.168.0.1
LastUsable : 192.168.1.254
Usable : 510

Example 13

supernet networks into smallest possible subnets

c:\> ipnetwork -w 192.168.0.0/24 192.168.2.0/24

IPNetwork : 192.168.0.0/24
Network : 192.168.0.0
Netmask : 255.255.255.0
Cidr : 24
Broadcast : 192.168.0.255
FirstUsable : 192.168.0.1
LastUsable : 192.168.0.254
Usable : 254
--
IPNetwork : 192.168.2.0/24
Network : 192.168.2.0
Netmask : 255.255.255.0
Cidr : 24
Broadcast : 192.168.2.255
FirstUsable : 192.168.2.1
LastUsable : 192.168.2.254
Usable : 254

Example 14

supernet networks into smallest possible subnets

C:\>ipnetwork -W 192.168.0.0/24 192.168.129.0/24
IPNetwork : 192.168.0.0/16
Network : 192.168.0.0
Netmask : 255.255.0.0
Cidr : 16
Broadcast : 192.168.255.255
FirstUsable : 192.168.0.1
LastUsable : 192.168.255.254
Usable : 65534

Example 15

Split network into cidr, display full network only

C:\>ipnetwork -i -s 12 10.0.0.0/8 | grep -v \-\-

IPNetwork : 10.0.0.0/12
IPNetwork : 10.16.0.0/12
IPNetwork : 10.32.0.0/12
IPNetwork : 10.48.0.0/12
IPNetwork : 10.64.0.0/12
IPNetwork : 10.80.0.0/12
IPNetwork : 10.96.0.0/12
IPNetwork : 10.112.0.0/12
IPNetwork : 10.128.0.0/12
IPNetwork : 10.144.0.0/12
IPNetwork : 10.160.0.0/12
IPNetwork : 10.176.0.0/12
IPNetwork : 10.192.0.0/12
IPNetwork : 10.208.0.0/12
IPNetwork : 10.224.0.0/12
IPNetwork : 10.240.0.0/12

Example 16

Test if an ip is contained in a network

C:\>ipnetwork -C 10.0.0.1 10.0.0.0/8 10.0.1.0/24

10.0.0.1/32 contains 10.0.0.0/8 : False
10.0.0.1/32 contains 10.0.1.0/24 : False

Example 17

Test if a network overlap another network

C:\>ipnetwork -o 10.0.0.1/24 10.0.0.0/8 10.0.1.0/24

10.0.0.0/24 overlaps 10.0.0.0/8 : True
10.0.0.0/24 overlaps 10.0.1.0/24 : False

Example 18

remove one ip from a class and regroup them into the smallest possible network

C:\> ipnetwork -i -s 32 192.168.0.0/24 \
 | grep -v \-\- \
 | awk "{print $3;}" \
 | grep -v 192.168.0.213/32 \
 | xargs ipnetwork -i -w \
 | grep -v \-\-

IPNetwork : 192.168.0.224/27
IPNetwork : 192.168.0.216/29
IPNetwork : 192.168.0.214/31
IPNetwork : 192.168.0.212/32
IPNetwork : 192.168.0.208/30
IPNetwork : 192.168.0.192/28
IPNetwork : 192.168.0.128/26
IPNetwork : 192.168.0.0/25

Example 18 (IPv6)

IPv6 networks

C:\> ipnetwork.exe 2001:0db8::/128
IPNetwork : 2001:db8::/128
Network : 2001:db8::
Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Cidr : 128
Broadcast : 2001:db8::
FirstUsable : 2001:db8::
LastUsable : 2001:db8::
Usable : 0
Total : 1

Have fun !

Donate

If IPNetwork saves you time, consider . Lightning Network accepted.

License

๐Ÿ‘ FOSSA Status

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 is compatible. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (62)

Showing the top 5 NuGet packages that depend on IPNetwork2:

Package Downloads
Azure.Deployments.Expression

This package contains the logic for Azure Resource Manager template expressions.

Makaretu.Dns.Multicast

A simple Multicast Domain Name Service based on RFC 6762. Can be used as both a client (sending queries) or a server (responding to queries).

Azure.Deployments.Templates

This package contains the logic parsing Azure Resource Manager Templates.

FeatureHub.SDK

.Net SDK implementation for FeatureHub.io - Open source Feature flags management, A/B testing and remote configuration platform.

IPTables.Net

Package Description

GitHub repositories (14)

Showing the top 14 popular GitHub repositories that depend on IPNetwork2:

Repository Stars
BornToBeRoot/NETworkManager
A powerful open-source tool for managing networks and troubleshooting network problems!
Ponderfly/GoogleTranslateIpCheck
ๆ‰ซๆๅ›ฝๅ†…ๅฏ็”จ็š„่ฐทๆญŒ็ฟป่ฏ‘IP
PCL-Community/PCL-CE
PCL ็คพๅŒบ็‰ˆ ็”ฑ็คพๅŒบๅผ€ๅ‘่€…็ปดๆŠคไธŽ็ฎก็†
microsurging/surging
Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming.
micahmo/WgServerforWindows
Wg Server for Windows (WS4W) is a desktop application that allows running and managing a WireGuard server endpoint on Windows
trueai-org/midjourney-proxy
๐Ÿฆ„ The world's largest Midjourney drawing API, generating over 1 million drawings daily, supporting Discord Youchuan Midjourney ๐Ÿ‚๏ผ
punk-security/smbeagle
SMBeagle - Fileshare auditing tool.
sanjusss/aliyun-ddns
้˜ฟ้‡Œไบ‘ๅŠจๆ€ๅŸŸๅๅทฅๅ…ท๏ผŒๆ”ฏๆŒdockerๅ’Œipv6ใ€‚
shiftwinting/FastGithub
githubๅฎšๅˆถ็‰ˆ็š„dnsๆœๅŠก๏ผŒ่งฃๆž่ฎฟ้—ฎgithubๆœ€ๅฟซ็š„ip
fedarovich/qbittorrent-cli
Command line interface for QBittorrent
PluralKit/PluralKit
slowscript/warpinator-windows
An unofficial implementation of Warpinator for Windows
richardschneider/net-mdns
Simple multicast DNS
Aldaviva/Fail2Ban4Win
๐Ÿงฑ Ban subnets using Windows Firewall rules after they make enough incorrect login attempts, as indicated by Windows Event Log records.
Version Downloads Last Updated
4.3.0 60,679 5/17/2026
4.2.0 110,390 4/5/2026
4.1.1 665 4/4/2026
4.1.0 555 4/4/2026
4.0.2 62,171 3/8/2026
4.0.1 2,134 3/7/2026
4.0.0 791 3/7/2026
3.6.0 4,361 4/4/2026
3.5.3 38,683 3/6/2026
3.5.2 633 3/6/2026
3.5.1 635 3/6/2026
3.4.853 103,312 1/29/2026
3.4.851 269,559 1/4/2026
3.4.850 525 1/4/2026
3.4.832 873,498 8/18/2025
3.4.831 5,791 8/17/2025
3.4.830 897 8/17/2025
3.4.829 888 8/17/2025
3.4.828 883 8/17/2025
3.4.827 889 8/17/2025
Loading failed