如何禁止特定IP访问自己网站?

http://blog.sina.com.cn/s/blog_551ca6960100a0yv.html

网站的在线留言这个板块,每天晚上都有个无聊的人,在在线留言这上面发些乱起八糟的广告,那个乱发广告的人的IP:218.81.147.40,在线留言是asp语言编写的,有什么办法才能禁止这个搞乱的人继续乱发无聊的广告。希望高手指点,被弄的都快崩溃了,每天要删除好多无聊的广告,全黄的。

答案一:

Asp限制IP访问  
  <%  
  ''获取访问者的地址  
  ip=Request.ServerVariables("REMOTE_ADDR")    
   
  ''允许的IP地址段为10.0.0.0~10.68.63.255  
  allowip1="10.0.0.0"  
  allowip2="10.68.10.71"  
  response.write   checkip(ip,allowip1,allowip2)  
  function   checkip(ip,allowip1,allowip2)  
  dim   check(4)  
  checkip=false  
  ipstr=split(ip,".")  
  allow1=split(allowip1,".")  
  allow2=split(allowip2,".")  
  if   cint(allow1(0))>cint(allow2(0))   then   ''判断IP地址段是否合法  
  response.write   "禁止访问"  
  exit   function  
  end   if  
  for   i=0   to   ubound(ipstr)  
  if   cint(allow1(i))<cint(allow2(i))   then  
  if   cint(allow1(i))=cint(ipstr(i))   then  
  check(i)=true  
  checkip=true  
  exit   for  
  else  
  if   cint(ipstr(i))<cint(allow2(i))   then  
  check(i)=true  
  checkip=true  
  exit   for  
  else  
  if   cint(ipstr(i))>cint(allow2(i))   then  
  check(i)=false  
  checkip=false  
  exit   for  
  else  
  check(i)=true  
  checkip=true  
  end   if  
  end   if  
  end   if  
  else  
  if   cint(allow1(i))>cint(ipstr(i))   or   cint(allow1(i))<cint(ipstr(i))   then  
  check(i)=false  
  checkip=false  
  if   i<>ubound(ipstr)   then  
  exit   for  
  end   if  
  else  
  check(i)=true  
  end   if  
  end   if  
  next  
  if   (check(0)=true   and   check(1)=true   and   check(2)=true   and   check(3)=false)   and   (cint(allow2(2))>cint(ipstr(2)))   then  
  checkip=true  
  end   if  
  end   function  
  %>  
答案二:

 其实你直接跳转就可以  
  <%  
  ''获取访问者的地址  
  ip=Request.ServerVariables("REMOTE_ADDR")    
  if   ip   =   你要屏蔽的ip   then    
  msgbox   "你被禁止访问"  
  Response.Redirect   跳转到你警告页面  
  Response.end  
  end   if  
  %>  

答案三:

在IIS里进行设置即可,过程如下:
打开IIS管理器,选择你的域名,点右键-属性,选择”目录安全性“,看到第二栏的”IP地址和域名限制“了吗?点编辑,添加,加入你想限制的IP即可,不要忘了选中“拒绝访问”。

 

如果某个IP地址的客人(如201.23.1.23)老往我的个人论坛上面贴一些无聊的帖子,我想把这个IP地址屏蔽掉,请问该如何做?

答案一:

<%  
      if   Request.ServerVariables("REMOTE_ADDR")   =   "201.23.1.23"   then  
              Response.End  
      end   if  
  %>

答案二:

在你不希望他能够访问的页面加入  
  <%  
  if   Request.ServerVariables("REMOTE_ADDR")="201.23.1.23"   Then  
  Response.Write   "你的IP地址被禁止浏览网页"  
  Response.End  
  End   If  
  %>

答案三:

在IIS中设置站点属性中的   目录安全性\IP地址和域名限制

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值