Restrict a segment of IP address

Source: Internet
Author: User
IP Address |IP Address

function Ip2num (SIP)
Dim str1,str2,str3,str4
Dim num
Ip2num=0
If IsNumeric (left (sip,2)) Then
Str1=left (Sip,instr (SIP, ".") -1)
Sip=mid (Sip,instr (SIP, ".") +1)
Str2=left (Sip,instr (SIP, ".") -1)
Sip=mid (Sip,instr (SIP, ".") +1)
Str3=left (Sip,instr (SIP, ".") -1)
Str4=mid (Sip,instr (SIP, ".") +1)
Num=cint (STR1) *256*256*256+cint (str2) *256*256+cint (STR3) *256+cint (STR4)-1
Ip2num = num
End If
End Function

function Num2ip (NIP)
iip1 = Int (nip/256/256/256)
iip2 = Int ((nip-iip1*256*256*256)/256/256)
IIP3 = Int ((nip-iip1*256*256*256-iip2*256*256)/256)
IIP4 = Int ((nip-iip1*256*256*256-iip2*256*256-iip3*256) mod 256)
Iip0 = Iip1 & "." & Iip2 & "." &iip3 & "." & IIP4
Num2ip = Iip0
End Function

Useripnum = Ip2num (Request.ServerVariables ("REMOTE_ADDR"))

If Useripnum > Ip2num ("192.168.0.0") and Useripnum < Ip2num ("192.168.0.255") Then
Response.Write ("<center> your IP is banned </center>")
Response.End
End If



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.