Access
This is previously written in ASP, I would like to change into asp.net to everyone, and then think we can read the algorithm on the line. The key of IP alignment is the linearization of IP address, the following is the code.
' Access to IP ' 218.7.44.0-218.7.45.253 ' 61.180.240.0-61.180.240.253 ' 202.118.208.0-202.118.223.253 ' 218.7.44.0 365 7903103 ' 218.7.45.253 3657903612 ' 61.180.240.0 1035268095 ' 61.180.240.253 1035268348 ' 202.118.208.0 3396784127 ' 202.1 18.223.253 3396788220 ip=request.servervariables ("REMOTE_ADDR") sip=split (IP, ".") Num=cint (SIP (0)) *256*256*256+cint (SIP (1)) *256*256+cint (SIP (2)) *256+cint (SIP (3))-1 Response.Write (IP) Response.Write ("<br>") if (num>=3657903103 and num<=3657903612) or (num>=1035268095 and num<= 1035268348) or (num>=3396784127 and num<=3396788220)) then Response.Write ("Sorry, your IP is not legal!") ") Response. End () Else Response.Write ("Your IP is legitimate") End If