Determine whether it is a domestic IP Address

Source: Internet
Author: User
I recently wrote a small program to determine whether it is a domestic IP address. The Chinese version will automatically jump to the Chinese version, and the foreign version will automatically jump to the English version.

It is not ideal to search many materials. In addition, many IP address libraries can identify specific regions. And there is no domestic or foreign division.
It is hard to find IP segments in China, but there is no ready-made IP address library.
There is no way, so you have to export the txt text to the database.

Now I will share the simple judgment code and SQL Server Ip address library with you. I hope you will not have to worry about it in the future! <%
'Bijia Compilation
'Blog: http://bijia.anyflex.cn/
'Judge the domestic IP Address

Dim DBC, Conn
Set DBC = New DataBaseClass
Set Conn = DBC. OpenConnection ()
Set DBC = Nothing
Dim Rs, SQL


Dim Ip, ip1, ipitem1
 
Ip1 = Request. ServerVariables ("REMOTE_ADDR ")

Ipitem1 = split (ip1 ,".")
Ip = ipitem1 (0) * 256*256*256 + ipitem1 (1) * 256*256 + ipitem1 (2) * 256 + ipitem1 (3) 'convert the Ip address to 256 in hexadecimal format

Set Rs = Server. CreateObject (G_FS_RS)
SQL = "Select * from ChinaIP where IpMin <" & Ip & "and IpMax>" & Ip
Rs. open SQL, conn, 1, 3
If Rs. EOF then
Response. redirect ("index_en.html") 'foreign address
Else
Response. redirect ("index_cn.html") 'domestic address
End if

%>

Click here to download

The original IP library is incomplete. Please update it again now!
Click here to download

Author: Bijia, at 20:23:57

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.