System.Net.IPNetwork Extension methods to convert instances to hexadecimal, octal, and binary strings. Converts a to a binary string. A . A containing a binary representation of the supplied . Converts a to a hexadecimal string. A . A containing a hexadecimal representation of the supplied . Converts a to a octal string. A . A containing an octal representation of the supplied . Reverse a Positive BigInteger ONLY Bitwise ~ operator Input : FF FF FF FF Width : 4 Result : 00 00 00 00 Input : 00 00 00 00 Width : 4 Result : FF FF FF FF Input : FF FF FF FF Width : 8 Result : FF FF FF FF 00 00 00 00 Input : 00 00 00 00 Width : 8 Result : FF FF FF FF FF FF FF FF. The positive number to bitwise reverse. The width of the parameter. A number representing the input bitwise reversed. Class CidrClassFull tries to guess CIDR in a ClassFull way. IPV4 : Class Leading bits Default netmask A (CIDR /8) 00 255.0.0.0 A (CIDR /8) 01 255.0.0.0 B (CIDR /16) 10 255.255.0.0 C (CIDR /24) 11 255.255.255.0 IPV6 : 64. A string representing the CIDR to convert. A byte representing the netmask in cidr format (/24). true if ip was converted successfully; otherwise, false. Try to guess a CIDR in a ClassLess way ie. ipv4 = 32, ipv6 = 128. IPV4 : 32 IPV6 : 128. A string representing an ipadress that will be used to guess CIDR. A byte representing the netmask in cidr format (/24). true if ip was converted successfully; otherwise, false. A static helper CidrGuess class. Gets classFull guess. Gets classLess guess. An ip adress to guess the ip network CIDR. A byte representing the netmask in cidr format (/24). true if ip was converted successfully; otherwise, false. A collection of IP Adresses A collection of extension functions applied to an IPAddress value. Convert an IPAddress value into a single-address IPNetwork for that address. IPAddress to convert. IPNetwork object covering that IPAddress only. IP Network utility class. Use IPNetwork.Parse to create instances. Gets network address. Gets address Family. Gets netmask. Gets broadcast address. Gets first usable IP adress in Network. Gets last usable IP adress in Network. Gets number of usable IP adress in Network. Gets number of IP adress in Network. Gets the CIDR netmask notation. Initializes a new instance of the class. Creates a new IPNetwork. An ipaddress. A byte representing the netmask in cidr format (/24). ipaddress is null. 192.168.168.100 - 255.255.255.0 ``` Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255 ```. A string containing an ip address to convert. A string representing a netmask in std format (255.255.255.0). An IPNetwork equivalent to the network contained in ipaddress/netmask. 192.168.168.100/24 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. A string containing an ip address to convert. A byte representing the netmask in cidr format (/24). An IPNetwork equivalent to the network contained in ipaddress/cidr. 192.168.168.100 255.255.255.0 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. A string containing an ip address to convert. A netmask to be used to create the IPNetwork. An IPNetwork equivalent to the network contained in ipaddress/netmask. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. An IPNetwork equivalent to the network contained in string network. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. Whether to sanitize network or not. An IPNetwork equivalent to the network contained in string network. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. A ICidrGuess implementation that will be used to guess CIDR during converion. An IPNetwork equivalent to the network contained in string network. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. A ICidrGuess implementation that will be used to guess CIDR during converion. Whether to sanitize network or not. An IPNetwork equivalent to the network contained in string network. 192.168.168.100 - 255.255.255.0 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. A string containing an ip address to convert. A string containing a netmaks to convert (255.255.255.0). When this method returns, contains the IPNetwork value equivalent of the ip adress contained in ipaddress with the netmask corresponding to cidr, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents an invalid ip address. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. true if ipaddress/netmask was converted successfully; otherwise, false.. 192.168.168.100/24 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. A string containing an ip address to convert. A byte representing the netmask in cidr format (/24). When this method returns, contains the IPNetwork value equivalent of the ip adress contained in ipaddress with the netmask corresponding to cidr, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents an invalid ip address. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. true if ipaddress/cidr was converted successfully; otherwise, false.. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. When this method returns, contains the IPNetwork value equivalent of the ip adress contained in ipaddress with the netmask corresponding to cidr, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents an invalid ip address. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. true if network was converted successfully; otherwise, false.. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. A string containing an ip network to convert. Whether to sanitize network or not. When this method returns, contains the IPNetwork value equivalent of the ip adress contained in ipaddress with the netmask corresponding to cidr, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents an invalid ip address. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. true if network was converted successfully; otherwise, false.. 192.168.0.1/24 192.168.0.1 255.255.255.0 Network : 192.168.0.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.0.1 End : 192.168.0.254 Broadcast : 192.168.0.255. An IPAdresse to convert. A IPAdresse to be used as netmaks to convert. When this method returns, contains the IPNetwork value equivalent of the ip adress contained in ipaddress with the netmask corresponding to cidr, if the conversion succeeded, or null if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents an invalid ip address. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. true if network was converted successfully; otherwise, false.. 192.168.168.100 - 255.255.255.0 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. Whether to throw exception or not during conversion. A string containing an ip address to convert. A string containing a netmask to convert (255.255.255.0). The resulting IPNetwork. 192.168.168.100 255.255.255.0 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. Whether to throw exception or not during conversion. An ip address to convert. A netmask to convert (255.255.255.0). The resulting IPNetwork. 192.168.168.100/24 Network : 192.168.168.0 Netmask : 255.255.255.0 Cidr : 24 Start : 192.168.168.1 End : 192.168.168.254 Broadcast : 192.168.168.255. Whether to throw exception or not during conversion. A string containing an ip address to convert. A byte representing the CIDR to be used in conversion (/24). The resulting IPNetwork. Convert an ipadress to decimal 0.0.0.0 -> 0 0.0.1.0 -> 256. A string containing an ip address to convert. A number representing the ipaddress. Convert an ipadress to decimal 0.0.0.0 -> 0 0.0.1.0 -> 256. A string containing an ip address to convert. A number representing the IPAdress. true if ipaddress was converted successfully; otherwise, false. Convert a cidr to BigInteger netmask. A byte representing the netmask in cidr format (/24). Either IPv4 or IPv6. A number representing the netmask exprimed in CIDR. Convert a cidr to uint netmask. A byte representing the netmask in cidr format (/24). Either IPv4 or IPv6. A number representing the netmask. true if cidr was converted successfully; otherwise, false. Convert a cidr to uint netmask. Whether to throw exception or not during conversion. A byte representing the netmask in cidr format (/24). Either IPv4 or IPv6. A number representing the netmask. Convert netmask to CIDR 255.255.255.0 -> 24 255.255.0.0 -> 16 255.0.0.0 -> 8. Whether to throw exception or not during conversion. A number representing the netmask to convert. Either IPv4 or IPv6. A byte representing the netmask in cidr format (/24). Convert netmask to CIDR 255.255.255.0 -> 24 255.255.0.0 -> 16 255.0.0.0 -> 8. An IPAdress representing the CIDR to convert. A byte representing the CIDR converted from the netmask. Convert netmask to CIDR 255.255.255.0 -> 24 255.255.0.0 -> 16 255.0.0.0 -> 8. An IPAdress representing the CIDR to convert. A byte representing the netmask in cidr format (/24). true if netmask was converted successfully; otherwise, false. Convert CIDR to netmask 24 -> 255.255.255.0 16 -> 255.255.0.0 8 -> 255.0.0.0. A byte representing the netmask in cidr format (/24). Either IPv4 or IPv6. An IPAdress representing cidr. Convert CIDR to netmask 24 -> 255.255.255.0 16 -> 255.255.0.0 8 -> 255.0.0.0. A byte representing the netmask in cidr format (/24). Either IPv4 or IPv6. The resulting netmask. true if cidr was converted successfully; otherwise, false. Count bits set to 1 in netmask. A number representing the netmask to count bits from. Either IPv4 or IPv6. The number of bytes set to 1. Count bits set to 1 in netmask. A number representing the netmask to count bits from. The number of bytes set to 1. return true if netmask is a valid netmask 255.255.255.0, 255.0.0.0, 255.255.240.0, ... A number representing the netmask to validate. true if netmask is a valid IP Netmask; otherwise, false. Transform a uint ipaddress into IPAddress object. A number representing an ip address to convert. Either IPv4 or IPv6. An ip adress. return true if ipaddress is contained in network. A string containing an ip address to convert. true if ipaddress is contained into the IP Network; otherwise, false. return true is network2 is fully contained in network. The network to test. It returns the boolean value. If network2 is in IPNetwork then it returns True, otherwise returns False. return true is network2 overlap network. The network to test. true if network2 overlaps into the IP Network; otherwise, false. Gets 172.12.0.0/12. The IANA reserved IPNetwork 172.12.0.0/12. return true if ipaddress is contained in IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1. A string containing an ip address to convert. true if ipaddress is a IANA reserverd IP Netowkr ; otherwise, false. return true if ipnetwork is contained in IANA_ABLK_RESERVED1, IANA_BBLK_RESERVED1, IANA_CBLK_RESERVED1. true if the ipnetwork is a IANA reserverd IP Netowkr ; otherwise, false. Subnet a network into multiple nets of cidr mask Subnet 192.168.0.0/24 into cidr 25 gives 192.168.0.0/25, 192.168.0.128/25 Subnet 10.0.0.0/8 into cidr 9 gives 10.0.0.0/9, 10.128.0.0/9. A byte representing the CIDR to be used to subnet the current IPNetwork. A IPNetworkCollection splitted by CIDR. Subnet a network into multiple nets of cidr mask Subnet 192.168.0.0/24 into cidr 25 gives 192.168.0.0/25, 192.168.0.128/25 Subnet 10.0.0.0/8 into cidr 9 gives 10.0.0.0/9, 10.128.0.0/9. A byte representing the CIDR to be used to subnet the current IPNetwork. The resulting subnetted IPNetwork. true if network was split successfully; otherwise, false. Supernet two consecutive cidr equal subnet into a single one 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24. The network to supernet with. A supernetted IP Network. Try to supernet two consecutive cidr equal subnet into a single one 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 10.1.0.0/16 + 10.0.0.0/16 = 10.0.0.0/15 192.168.0.0/24 + 192.168.0.0/25 = 192.168.0.0/24. The network to supernet with. The resulting IPNetwork. true if network2 was supernetted successfully; otherwise, false. 20221105 : ldvhcosal GetHashCode uses mutable attributes. That introduce undefined behaviour on Hashtable and dictionary. An number representing the hashCode. Supernet a list of subnet 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 192.168.0.0/24 + 192.168.1.0/24 + 192.168.2.0/24 + 192.168.3.0/24 = 192.168.0.0/22. A list of IPNetwork to merge into common supernets. The result of IPNetwork if merges succeed, the first ipnetwork otherwise. Supernet a list of subnet 192.168.0.0/24 + 192.168.1.0/24 = 192.168.0.0/23 192.168.0.0/24 + 192.168.1.0/24 + 192.168.2.0/24 + 192.168.3.0/24 = 192.168.0.0/22. A list of IPNetwork to merge into common supernets. The result of IPNetwork merges. true if ipnetworks was supernetted successfully; otherwise, false. Print an ipnetwork in a clear representation string. Dump an IPNetwork representation as string. Delegate to CidrGuess ClassFull guessing of cidr. A string representing an IPAdress that will be used to guess the corresponding CIDR. The resulting CIDR as byte. true if cidr was guessed successfully; otherwise, false. Try to parse cidr. Have to be >= 0 and <= 32 or 128. A string representing a byte CIRD (/24). Either IPv4 or IPv6. The resulting CIDR as byte. true if cidr was converted successfully; otherwise, false. List all ip addresses in a subnet. The network to list IPAdresses. All the IPAdresses contained in ipnetwork. List all ip addresses in a subnet. Filter IPAdresses from IPNetwork. The filterted IPAdresses contained in ipnetwork. Compare two ipnetworks. The other network to compare to. A signed number indicating the relative values of this instance and value.. Compare two ipnetworks. The other object to compare to. A signed number indicating the relative values of this instance and value.. Compare two ipnetworks. An IPNetwork to compare. An other IPNetwork to compare to. true if obj has the same value as this instance; otherwise, false. Compare two ipnetworks. An IPNetwork to compare to this instance. true if obj has the same value as this instance; otherwise, false. Compare two ipnetworks. An object value to compare to this instance. true if obj has the same value as this instance; otherwise, false. Compares two IPNetwork. left instance. Right instance. true if left equals right; otherwise, false. Compares two IPNetwork. left instance. Right instance. true if left does not equals right; otherwise, false. Compares two IPNetwork. left instance. Right instance. true if left is less than right; otherwise, false. Compares two IPNetwork. left instance. Right instance. true if left is greater than right; otherwise, false. Initializes a new instance of the class. Created for DataContractSerialization. Better use static methods IPNetwork.Parse() to create IPNetworks. Gets netmask Inverse https://en.wikipedia.org/wiki/Wildcard_mask A wildcard mask is a mask of bits that indicates which parts of an IP address are available for examination. In the Cisco IOS,[1] they are used in several places, for example: To indicate the size of a network or subnet for some routing protocols, such as OSPF. To indicate what IP addresses should be permitted or denied in access control lists(ACLs). A wildcard mask can be thought of as an inverted subnet mask.For example, a subnet mask of 255.255.255.0 (binary equivalent = 11111111.11111111.11111111.00000000) inverts to a wildcard mask of 0.0.0.255 (binary equivalent = 00000000.00000000.00000000.11111111). A wild card mask is a matching rule.[2] The rule for a wildcard mask is: 0 means that the equivalent bit must match 1 means that the equivalent bit does not matter Any wildcard bit-pattern can be masked for examination.For example, a wildcard mask of 0.0.0.254 (binary equivalent = 00000000.00000000.00000000.11111110) applied to IP address 10.10.10.2 (00001010.00001010.00001010.00000010) will match even-numbered IP addresses 10.10.10.0, 10.10.10.2, 10.10.10.4, 10.10.10.6 etc. Same mask applied to 10.10.10.1 (00001010.00001010.00001010.00000001) will match odd-numbered IP addresses 10.10.10.1, 10.10.10.3, 10.10.10.5 etc. A network and wildcard mask combination of 1.1.1.1 0.0.0.0 would match an interface configured exactly with 1.1.1.1 only, and nothing else. Wildcard masks are used in situations where subnet masks may not apply.For example, when two affected hosts fall in different subnets, the use of a wildcard mask will group them together. List of wildcard masks Slash Netmask Wildcard mask /32 255.255.255.255 0.0.0.0 /31 255.255.255.254 0.0.0.1 /30 255.255.255.252 0.0.0.3 /29 255.255.255.248 0.0.0.7 /28 255.255.255.240 0.0.0.15 /27 255.255.255.224 0.0.0.31 /26 255.255.255.192 0.0.0.63 /25 255.255.255.128 0.0.0.127 /24 255.255.255.0 0.0.0.255 /23 255.255.254.0 0.0.1.255 /22 255.255.252.0 0.0.3.255 /21 255.255.248.0 0.0.7.255 /20 255.255.240.0 0.0.15.255 /19 255.255.224.0 0.0.31.255 /18 255.255.192.0 0.0.63.255 /17 255.255.128.0 0.0.127.255 /16 255.255.0.0 0.0.255.255 /15 255.254.0.0 0.1.255.255 /14 255.252.0.0 0.3.255.255 /13 255.248.0.0 0.7.255.255 /12 255.240.0.0 0.15.255.255 /11 255.224.0.0 0.31.255.255 /10 255.192.0.0 0.63.255.255 /9 255.128.0.0 0.127.255.255 /8 255.0.0.0 0.255.255.255 /7 254.0.0.0 1.255.255.255 /6 252.0.0.0 3.255.255.255 /5 248.0.0.0 7.255.255.255 /4 240.0.0.0 15.255.255.255 /3 224.0.0.0 31.255.255.255 /2 192.0.0.0 63.255.255.255 /1 128.0.0.0 127.255.255.255 /0 0.0.0.0 255.255.255.255.