Hello Lucius,
This seems to be a pure ip calculation question
So far what I can get is using the bit operation(such as bit shift) to
calculate subnet addresses based on the base network address e.g.
static void RunIPTest()
{
int imask = 20;
int isubmask = 24;
IPAddress ip = IPAddress.Parse("66.179.96.0");
byte[] ipbytes = ip.GetAddressBytes();
//reverse the bytes due to little endian
Array.Reverse(ipbytes);
int baseIP = BitConverter.ToInt32(ipbytes, 0);
int ideltamask = isubmask - imask;
int isubnets = (int)Math.Pow((double)2, (double)ideltamask);
int ioffset = 32 - isubmask;
Console.WriteLine("offset: {0}", 1 << ioffset);
int tempIP;
byte[] tempbytes;
for (int i = 1; i < isubnets; i++)
{
tempIP = baseIP + (i << ioffset);
tempbytes = BitConverter.GetBytes(tempIP);
Array.Reverse(tempbytes);
//Console.WriteLine("tempbytes: {0}.{1}.{2}.{3}----int:{4}
", tempbytes[0], tempbytes[1], tempbytes[2], tempbytes[3], tempIP);
IPAddress subip = new IPAddress(tempbytes);
Console.WriteLine("subnet ipaddress: {0}", subip);
}
}
Hope this helps some.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.