{"id":15412253,"url":"https://github.com/robthree/ipnetworkhelper","last_synced_at":"2025-12-25T15:37:44.451Z","repository":{"id":65650091,"uuid":"405924653","full_name":"RobThree/IPNetworkHelper","owner":"RobThree","description":"Provides helper (extension)methods for working with IPNetworks","archived":false,"fork":false,"pushed_at":"2024-03-29T09:45:27.000Z","size":87,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-06T10:19:18.610Z","etag":null,"topics":["cidr","cidr-notation","cidr-subnet","csharp","dotnet","dotnet-standard","extension-methods","ip","ipv4","ipv4-network","ipv4-subnetting","ipv6","ipv6-network","ipv6-subnetting","network","networking"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobThree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["RobThree"],"custom":["https://paypal.me/robiii"]}},"created_at":"2021-09-13T10:16:29.000Z","updated_at":"2024-05-02T07:26:14.000Z","dependencies_parsed_at":"2024-03-07T14:00:36.168Z","dependency_job_id":"684e873e-f237-4315-9f4c-3562203789f0","html_url":"https://github.com/RobThree/IPNetworkHelper","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FIPNetworkHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FIPNetworkHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FIPNetworkHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FIPNetworkHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobThree","download_url":"https://codeload.github.com/RobThree/IPNetworkHelper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":220097480,"owners_count":16594160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","cidr-notation","cidr-subnet","csharp","dotnet","dotnet-standard","extension-methods","ip","ipv4","ipv4-network","ipv4-subnetting","ipv6","ipv6-network","ipv6-subnetting","network","networking"],"created_at":"2024-10-01T16:51:58.775Z","updated_at":"2025-12-25T15:37:44.398Z","avatar_url":"https://github.com/RobThree.png","language":"C#","readme":"# ![logo](https://raw.githubusercontent.com/RobThree/IPNetworkHelper/master/logo_24x24.png) IPNetworkHelper\n\nProvides helper (extension)methods for working with (IPv4 and/or IPv6) [IPNetworks](https://learn.microsoft.com/en-us/dotnet/api/system.net.ipnetwork). These include splitting and extracting networks from larger networks. Available as [NuGet package](https://www.nuget.org/packages/IPNetworkHelper/).\n\nNote that since version 2.0 we use the [`System.Net.IPNetwork`](https://learn.microsoft.com/en-us/dotnet/api/system.net.ipnetwork) struct, which, unfortunately, is only available in .NET 8.0 and later. If you need support for earlier versions of .NET, use version 1.0 of this library.\n\nVersion 3.0 has a breaking change where `Contains()` now does the more intuitive thing and checks if the network is entirely contained within another network. If you want to check if two networks overlap, use the `Overlaps()` method.\n\n## Quickstart\n\nAll of the below examples use IPv4 but IPv6 works just as well.\n\n```c#\n// Parse a network\nvar network = IPNetwork.Parse(\"192.168.0.0/16\");\n\n// Tries to parse network, returns true when succeeded, false otherwise and the parsed network\nif (IPNetwork.TryParse(\"192.168.0.0/16\", out var othernetwork))\n{\n    // ...\n}\n\n// Get last IP from network\nvar first = network.GetFirstIP();   // Network      (192.168.0.0)\nvar last = network.GetLastIP();     // Broadcast    (192.168.255.255)\n\n// Splits a network into two halves\nvar (left, right) = network.Split();    // Returns 192.168.0.0/17 and 192.168.128.0/17\n\n// Extract a subnet from a network\nvar desired = IPNetwork.Parse(\"192.168.10.16/28\");\nvar result = network.Extract(desired);\n\n// Result:\n// 192.168.0.0/21\n// 192.168.8.0/23\n// 192.168.10.0/28\n// 192.168.10.16/28 \u003c- desired\n// 192.168.10.32/27\n// 192.168.10.64/26\n// 192.168.10.128/25\n// 192.168.11.0/24\n// 192.168.12.0/22\n// 192.168.16.0/20\n// 192.168.32.0/19\n// 192.168.64.0/18\n// 192.168.128.0/17\n```\n\nThe `Contains(IPNetwork)` method can be used to check if a network is contained (entirely) within another network and the `Overlaps(IPNetwork)` method can be used to check if two networks overlap.\n\nThis library also includes an `IPAddressComparer` and `IPNetworkComparer` to be used when sorting IPAddresses or networks:\n\n```c#\nvar ips = new[] { \"192.168.64.0\", \"192.168.10.32\", \"192.168.0.0\", \"192.168.10.16\", \"192.168.10.0\" }\n    .Select(IPAddress.Parse)\n    .OrderBy(n =\u003e n, IPAddressComparer.Default);\n\nvar networks = new[] { \"192.168.64.0/18\", \"192.168.10.32/27\", \"192.168.0.0/16\", \"192.168.10.16/28\", \"192.168.10.0/28\" }\n    .Select(IPNetwork.Parse)\n    .OrderBy(n =\u003e n, IPNetworkComparer.Default);\n```\n\n---\n\nIcon made by [prettycons](http://www.flaticon.com/authors/prettycons) from [www.flaticon.com](http://www.flaticon.com) is licensed by [CC 3.0](http://creativecommons.org/licenses/by/3.0/).\n","funding_links":["https://github.com/sponsors/RobThree","https://paypal.me/robiii"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fipnetworkhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobthree%2Fipnetworkhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Fipnetworkhelper/lists"}