Hello ,
1) First of all Use The Following Function to Create List OF IP ADRESSES B GIving range oF IP's fron Web.config.
private static ArrayList GetIpAdressFromRange(string fromIp, string toIp)
{
ArrayList ips = new ArrayList();
IPAddress tmpIP = null;
if (IPAddress.TryParse(fromIp, out tmpIP) == true &&
IPAddress.TryParse(toIp, out tmpIP) == true)
{
string[] fromOct = fromIp.Split('.');
string[] toOct = toIp.Split('.');
string a = null, b = null, c = null, d = null;
int startA = Convert.ToInt32(fromOct[0]);
int startB = Convert.ToInt32(fromOct[1]);
int startC = 1;
int startD = 1;
int endA = Convert.ToInt32(toOct[0]);
int endB = 255;
int endC = 255;
int endD = 255;
for (int intA = startA; intA <= endA; intA++)
{
a = intA.ToString();
startB = intA == Convert.ToInt32(fromOct[0]) ? Convert.ToInt32(fromOct[1]) : 1;
endB = intA == Convert.ToInt32(toOct[0]) ? Convert.ToInt32(toOct[1]) : 255;
for (int intB = startB; intB <= endB; intB++)
{
b = intB.ToString();
startC = (intA == Convert.ToInt32(fromOct[0])) && (intB == Convert.ToInt32(fromOct[1])) ?
Convert.ToInt32(fromOct[2]) : 1;
endC = (intA == Convert.ToInt32(toOct[0])) && (intB == Convert.ToInt32(toOct[1])) ?
Convert.ToInt32(toOct[2]) : 255;
for (int intC = startC; intC <= endC; intC++)
{
c = intC.ToString();
startD = (intA == Convert.ToInt32(fromOct[0])) && (intB == Convert.ToInt32(fromOct[1])) && (intC == Convert.ToInt32(fromOct[2])) ?
Convert.ToInt32(fromOct[3]) : 1;
endD = (intA == Convert.ToInt32(toOct[0])) && (intB == Convert.ToInt32(toOct[1])) && (intC == Convert.ToInt32(toOct[2])) ?
Convert.ToInt32(toOct[3]) : 255;
for (int intD = startD; intD <= endD; intD++)
{
d = intD.ToString();
ips.Add(a + "." + b + "." + c + "." + d);
Console.WriteLine(a + "." + b + "." + c + "." + d);
}
}
}
}
}
return ips;
}
2)Once You Will Get The Arralist OF IP adresseses that Ate Restricted you can Just Search in that list Wheather Provided IP IS restricted.
Refer Following Link For More Info ...
http://www.technosrix.com/2009/05/how-to-generate-ip-addresses-from-given.html[
^]