急求: 限制 ip 段 访问的asp代码 (在线,马上给分,大家帮忙顶啊)

只允许固定的 ip 段可以访问,例如只允许 218.33.33.0 --218.33.33.255

期于的都不许访问~~,,自动返回到不许访问的指示页面,,

谢谢,,快啊,,
---------------------------------------------------------------

strip=客户端的ip
strip1=split(strip,".")
sip1=strip1(0)
sip2=strip1(1)
sip3=strip1(2)
strip=sip1&"."&sip2"."&sip3
if str<>218.33.33
then
…………………………
else
……………………
end if

---------------------------------------------------------------

clientip=Request.ServerVariables("REMOTE_ADDR")
ipstart="218.33.33.0"
ipend="218.33.33.255"
array_ipstart=split(ipstart,",")
array_ipend=split(ipend,",")
array_clientip=split(clientip,",")
dim inthesector
inthesector=1
for i=0 to 3
if array_clientip(i)>array_ipend or array_clientip(i)<array_ipstart then
inthesector=inthesector*0
end if
next
最后用inthesector判断。
---------------------------------------------------------------

站点属性=》目录安全性=》编辑(IP地址及域名限制)=》选择【拒绝访问】单选按钮=》添加=》选择【一组计算机】,在网络标识中填入218.33.33.0,子网掩码:255.255.255.0。

若要限制某个ASP文件,则查看该文件的属性=》文件安全性,其余同上。

若其余网段得IP访问该站点或ASP文件,则自动跳转到拒绝访问页面(自己可定制)

Published At
Categories with Web编程
comments powered by Disqus