Well, Friday afternoon, and I had a long week, so I would really like to help! I currently have a list of IP ranges, as shown below:
List<IPRange> ipRanges = new List<IPRange>(); ipRanges.Add(new IPRange { From = "145.36.0.0", To = "145.36.255.255" }); ipRanges.Add(new IPRange { From = "194.183.227.184", To = "194.183.227.191" }); ipRanges.Add(new IPRange { From = "193.131.192.0", To = "193.131.223.255" });
After receiving the IP address of the client, if it is somewhere between these sets of ranges, they need to be redirected to another location.
For instance,
If someone visited the site with IP 192.168.0.1 , they will be allowed access. If they are visited using 145.36.1.0 , they will not be allowed access, since it falls between the first range in this list.
I could divide each IP into a period and determine where the range starts to change, and then perform a comparison, but it will be hard on the server.
I know that IPs are just decimal numbers, but I'm not sure how this works.
Has anyone come across this before?
Greetings, Sean.
source share