.NET 8 C# IP Address enumerators.
- Enumerate IPv4 addresses in a sequential / staggered fashion
- More to come ...
PM> Install-Package Toimik.IpAddressEnumeration
> dotnet add package Toimik.IpAddressEnumeration
// Creates an enumerator of public IPv4 addresses that adopts a sequential approach
var enumerator = new SequentialV4IpAddressEnumerator();
// Creates an enumerator of public IPv4 addresses that adopts a staggered approach */
// var enumerator = new StaggeredV4IpAddressEnumerator();
var isForward = true;
var initialIpAddress = IPAddress.Parse("1.2.3.4");
var ipAddresses = enumerator.Enumerate(isForward, initialIpAddress);
foreach (IPAddress ipAddress in ipAddresses)
{
Console.WriteLine(ipAddress);
}
1.2.3.4
1.2.3.5
1.2.3.6
...
The output is the decimal representation of the reversed binary representation of the incremented binary.
IP address Incremented binary
1.2.3.4 00100000.11000000.01000000.10000000 <- Original
129.2.3.4 00100000.11000000.01000000.10000001 <- Incremented by 1 bit
65.2.3.4 00100000.11000000.01000000.10000010 <- Incremented by another bit
... ...