Determine whether the client is on the Intranet or the internet! ASP

Source: Internet
Author: User

<%
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

Userip = ip2num (request. servervariables ("remote_addr "))


If (userip> ip2num ("192.168.0.0") and userip <ip2num ("192.168.255.255") or (userip> ip2num ("127.0.0.0") and userip <ip2num ("127.255.255.255 ")) or (userip> ip2num ("10.0.0.0") and userip <ip2num ("10.20.255") then
Response. Write "internal IP address"
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.