ASP implementation to check whether the IP address for the intranet or private IP address code sharing _ Application techniques

Source: Internet
Author: User

The ASP checks whether the IP address is private/intranet IP address source code.

Intranet/Private IP address network segment is as follows, there are 127 loopback address at the beginning:

10.0.0.0-10.255.255.255
172.16.0.0-172.31.255.255
192.168.0.0-192.168.255.255

Implementation code:

<% function Iptonumber (IP) ' IP address to digital arr=split (IP, ".") IPTONUMBER=256*256*256*CLNG (arr (0)) +256*256*clng (arr (1)) +256*CLNG (arr (2)) +CLNG (arr (3)) End Function function ISPRIVATEIP (IP) ' Determines whether the given IP address is intranet/private IP address if InStr (IP, "127.") =1 Then ' loopback IP address isprivateip=true:exit function End If Abegin=iptonumber ("10.0.0.0"): Aend=iptonumber ("10.255.255.255") ' Class A private IP address bbegin=iptonumber (' 172.16.0.0 '): Bend=iptonumber ("172.31.255.255") ' Class B private IP address Cbegin=iptonumber (" 192.168.0.0 "): Cend=iptonumber (" 192.168.255.255 ") ' Class C Private IP address Ipnum=iptonumber (IP) isprivateip= (Abegin<=ipnum and Ipnum<=aend) or (Bbegin<=ipnum and Ipnum<=bend) or (Cbegin<=ipnum and ipnum<=cend) End Function RESPONSE.W Rite Isprivateip ("11.255.255.255") & "<br>" False Response.Write Isprivateip ("182.255.255.255") & "< Br> ' false Response.Write Isprivateip (' 172.30.255.255 ') & ' <br> ' True Response.Write Isprivateip (" 192.168.205.2 ") &" <br> "True Response.Write Isprivateip (" 127.168.205.2 ") ' True%&Gt
 

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.