佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 918|回复: 11

请问如何使ASP网站限制某个国家的IP游览?

[复制链接]
发表于 3-3-2006 12:30 AM | 显示全部楼层 |阅读模式
似乎很容易实现,但是自己就一直不会,希望有高手指教!

另外,IP 的头两个数字就是只给一个国家使用而已?
例:马来西亚的是 219.95.*.*
回复

使用道具 举报


ADVERTISEMENT

发表于 3-3-2006 01:02 AM | 显示全部楼层
没什么用..只要用代理服务器..
我就可以看到你的网站了..如果你是要block 219.95..
回复

使用道具 举报

 楼主| 发表于 3-3-2006 01:43 AM | 显示全部楼层
我知道使用代理服务器就可以通过,但还是想要Block。

请问该如何呢?
回复

使用道具 举报

 楼主| 发表于 3-3-2006 01:44 AM | 显示全部楼层
请问这个code 该如何改才能 Block 到 所有的 219.95.*.* 的 IP?

<%
'declare variables
Dim sIP
Dim sIParray(2)
'assign our blocked IP addresses to our array
sIParray(0) = "61.254.32.22"
sIParray(1) = "62.454.32.25"
sIParray(2) = "62.254.32.17"
'retrieve the visitors IP address
sIP = Request.ServerVariables("REMOTE_ADDR")

'loop through the banned IPs using the UBound function
For i = 0 to UBound(sIParray)
'check if IP address matches any of the blocked IPs
If sIP = sIParray(i) Then
Response.Redirect "no_access.asp"
End If
Next
%>
回复

使用道具 举报

发表于 3-3-2006 06:59 AM | 显示全部楼层
原帖由 bpsim 于 3-3-2006 01:44 AM 发表
请问这个code 该如何改才能 Block 到 所有的 219.95.*.* 的 IP?

<%
'declare variables
Dim sIP
Dim sIParray(2)
'assign our blocked IP addresses to our array
sIParray(0) = "61.254.32. ...

并非Block 219.95.*.*就是Malaysia的, 你必须Download IP Table. 有Fomular算的. 
回复

使用道具 举报

发表于 3-3-2006 11:48 AM | 显示全部楼层
原帖由 bpsim 于 3-3-2006 01:44 发表
请问这个code 该如何改才能 Block 到 所有的 219.95.*.* 的 IP?

<%
'declare variables
Dim sIP
Dim sIParray(2)
'assign our blocked IP addresses to our array
sIParray(0) = "61.254.32. ...


你可以用很多方法。。或者算 dot。。
sIParray(0).substring(sIParray(0).indexof(".")

然后
sIParray(0).substring(***) 或者 sIParray(0).split(***

懒惰写。。自己想。。
回复

使用道具 举报

Follow Us
 楼主| 发表于 3-3-2006 12:52 PM | 显示全部楼层
这个呢?自己下载到,然后改的,好像还是不能 block 到,我自己的 IP 还是可以进入。

<%
Dim shortIP, mySplit, LongIP

shortIP = Request.ServerVariables("REMOTE_HOST")
mySplit = Split(shortIP, ".")
LongIP = (mySplit(0)*(256*256*256)) + (mySplit(1)*(256*256)) + (mySplit(2)*256) + (mySplit(3))

'Create Array
Dim myArray(132,2)
Randomize

'Array Definition is (Country Name ,Begin Range, End Range)
myArray(0,0) = "MALAYSIA"
myArray(0,1) = "1023803392"
myArray(0,2) = "1023852543"
myArray(1,0) = "MALAYSIA"
myArray(1,1) = "2428960768"
myArray(1,2) = "2429026303"
myArray(2,0) = "MALAYSIA"
myArray(2,1) = "2710241280"
myArray(2,2) = "2710306815"
myArray(3,0) = "MALAYSIA"
myArray(3,1) = "2710437888"
myArray(3,2) = "2710503423"
myArray(4,0) = "MALAYSIA"
myArray(4,1) = "2854617088"
myArray(4,2) = "2854682623"
myArray(5,0) = "MALAYSIA"
myArray(5,1) = "3236200448"
myArray(5,2) = "3236233215"
myArray(6,0) = "MALAYSIA"
myArray(6,1) = "3262473996"
myArray(6,2) = "3262473996"
(省略其他120个……)

For i = LBound(myArray) to UBound(myArray)

        If LongIP > myArray(i,2) And LongIP < myArray(i,1) Then
                Response.Redirect("no_access.asp")
        End If

Next
%>
回复

使用道具 举报

 楼主| 发表于 3-3-2006 12:54 PM | 显示全部楼层
大家如果有个即时可以使用的 code ,希望可以给我,昨晚研究到5点还是没成,太没气了。
回复

使用道具 举报


ADVERTISEMENT

发表于 3-3-2006 08:51 PM | 显示全部楼层
原帖由 belon_cfy 于 3-3-2006 06:59 AM 发表

并非Block 219.95.*.*就是Malaysia的, 你必须Download IP Table. 有Fomular算的. 

什么是IP Table啊?那里有的download?有Fomular可以算出来自哪里的?请提供更多详情,谢谢!
回复

使用道具 举报

 楼主| 发表于 3-3-2006 09:45 PM | 显示全部楼层
刚刚使用了 精点IP管理器 的插件。
http://www.google.com/search?num ... 86%E5%99%A8&lr=

看似一切顺利,可是要增加 IP 段或选择操作时,却出现 HTTP 500 - 内部服务器错误 。

请问应该如何解决这个呢?
回复

使用道具 举报

发表于 4-3-2006 06:28 PM | 显示全部楼层
原帖由 bpsim 于 3-3-2006 01:43 AM 发表
我知道使用代理服务器就可以通过,但还是想要Block。

请问该如何呢?


Request.ServerVariables("HTTP_X_FORWARDED_FOR")
回复

使用道具 举报

 楼主| 发表于 4-3-2006 08:17 PM | 显示全部楼层
原帖由 quantum^_^ 于 4-3-2006 06:28 PM 发表


Request.ServerVariables("HTTP_X_FORWARDED_FOR")

这个也不能保证所有的Proxy 可以阻止,还是有很大部分的Proxy 可以通过。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-9-2024 03:59 AM , Processed in 0.105232 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表