Using ASP code to achieve access restrictions on IP code _ common Tools

Source: Internet
Author: User
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.
Copy Code code as follows:

' 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 3657903103
' 218.7.45.253 3657903612
'
' 61.180.240.0 1035268095
' 61.180.240.253 1035268348
'
' 202.118.208.0 3396784127
' 202.118.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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.