jsakamoto / ipaddressrange

.NET Class Library for range of IP address, both IPv4 and IPv6.
Mozilla Public License 2.0
370 stars 71 forks source link

[Question] How to find usable IPs? #67

Open scorpio1441 opened 3 years ago

scorpio1441 commented 3 years ago
                var range = IPAddressRange.Parse("192.168.1.100/255.255.255.0");
                IPStartBox.Text = range.Begin.ToString(); // returns 192.168.1.0
                IPEndBox.Text = range.End.ToString(); // 192.168.1.255

I need to return first and last usable IP, which should be 192.168.1.1 and 192.168.1.254. Is this possible?

jsakamoto commented 3 years ago

Unfortunately, it is impossible with the IPAddressRange object only. To determine useable addresses, it requires not only range information and also subnets information such as subnet mask. IPAddressRange knows just a range, so IPAddressRange can not do it.

If you want to resolve this issue, here is not suitable for discussion about this issue. I recommend that you ask anybody in stackoverflow.com or elsewhere like it.