当前位置:首页 » 密码管理 » asp指定ip访问

asp指定ip访问

发布时间: 2023-01-06 15:57:25

A. asp怎么限制只允许国内ip访问

http://arthorzhou888.blog.163.com/blog/static/313091532007624112841640/

把这个写入数据库 然后加入到conn.asp文件里面 很简单

ip=Request.ServerVariables("REMOTE_ADDR")

''允许的IP地址段为10.0.0.0~10.50.50.255
allowip1="10.0.0.0"
allowip2="10.50.10.70"
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

B. ASP限制IP访问

1.ASP限制IP访问代码

<%
''获取访问者的地址
ip=Request.ServerVariables("REMOTE_ADDR")

''允许的IP地址段为10.0.0.0~10.50.50.255
allowip1="10.0.0.0"
allowip2="10.50.10.70"
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
%>

2.用户IP限制

<%'用户IP限制
function LockIP(sip)
dim str1,str2,str3,str4
dim num
LockIP=false
if isnumeric(left(sip,2)) then
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
if isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 then

else
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
sql="select count(*) from LockIP where ip1 <="&num&" and ip2 >="&num&""
set rs_ip=conn.execute(sql)
if rs_ip(0)>0 then
LockIP=true
end if
set rs_ip=nothing
end if
end if
end function%>
<%if LockIP(Request.ServerVariables("REMOTE_ADDR")) then
response.write "<script>alert('您的IP:"&request.servervariables("remote_addr")&"已经被限制不能访问,请和管理员联系');location.href='about:blank'</script><script>window.close();</script>"
response.end
end if
%>
<%
noip=Request.Servervariables("HTTP_X_FORWARDED_FOR")
If noip="" Then noip=Request.Servervariables("REMOTE_ADDR")
set rst11=server.createobject("adodb.recordset")
sql="select * from fuck where userip='"&noip&"'"
rst11.open sql,conn,1,1
if not rst11.eof and not rst11.bof then
response.write "<script>alert('您的IP:"&request.servervariables("remote_addr")&"已经被限制不能访问,请和管理员联系');location.href='about:blank'</script><script>window.close();</script>"
response.end
end if
%>

C. 我用asp刚做好一个网页,怎样让别人通过我的ip访问我的网页

第一步:设置你的本机ip,地址为你外网的地址(ip138查询)
第二步:要把你iis里面的默认访问地址改为你的本机(也就是第一步的ip)ip地址(第一步成功后下拉就会出现)
我这里没装iis不能给你截图,不好意思 ~_~!

D. asp页面如何设置只对指定IP段开放权限

可以通过两种方式实现:

1、通过设置IIS的权限来限制外网访问,如图

2、通过在asp中写代码控制,网络一下就有相关代码

E. asp学习:asp如何只允许某些IP访问

先要得到客户端的IP地址,然后进行判断,例: ip=request.servervariables("Remote_Addr") if Left(ip,8)="192.168." then ... else ... end if

满意请采纳

F. 修改asp限制IP访问

参考下面的屏蔽ip段的代码<%
'受屏蔽IP地址(段)集合,星号为通配符,通常保存于配置文件中。
ConstBadIPGroup="192.168.1.*|202.68.*.*|*.12.55.34|185.*.96.24|127.*.0.1|192.168.0.1"
IfIsForbidIP(BadIPGroup)=TrueThen
Response.Write(GetIP&"IP地址禁止访问")
Response.End()
EndIf

'参数vBadIP:要屏蔽的IP段,IP地址集合,用|符号分隔多个IP地址(段)
'返回Bool:True用户IP在被屏蔽范围,False反之
FunctionIsForbidIP(vBadIP)
Dimcounter,arrIPPart,arrBadIP,arrBadIPPart,i,j
arrBadIP=Split(vBadIP,"|")
arrIPPart=Split(GetIP(),".")
Fori=0ToUBound(arrBadIP)
counter=0
arrBadIPPart=Split(arrBadIP(i),".")
Forj=0ToUBound(arrIPPart)
If(arrBadIPPart(j))="*"orCstr(arrIPPart(j))=Cstr(arrBadIPPart(j))Then
counter=counter+1
EndIf
Next
Ifcounter=4Then
IsForbidIP=True
ExitFunction
EndIf
Next
IsForbidIP=False
EndFunction
'返回客户IP地址
FunctionGetIP()
DimIP
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IfIP=""ThenIP=Request.ServerVariables("REMOTE_ADDR")
GetIP=IP
EndFunction
%>

G. ASP如何实现限制区域地区IP访问,定向IP访问

要使用request对象
的ServerVariables属性,通过它来获得环境变量的值。使用的语法为:Request.ServerVariables(variable),variable表示环境变量的名称,如服务器主机名称、Web服务器软件名等等,若variable为REMOTE_ADDR则表示访问者的IP地址,通过它就可以实现IP地址的过滤。
源程序如下:(文件名:demo.ASP)<html><head>
<metahttp-equiv=Content-Typecontent=text/html;charset=gb_2312-80><metaname=GENERATORcontent=MicrosoftFrontPageExpress2.0>
<style>
<!--
.as{line-height:15px;font-size:9pt}
a:hover{color:rgb(0,51,240);text-decoration:underline}
.p9{font-family:宋体;font-size:9pt;line-height:15pt}
.p12{font-family:宋体;font-size:12pt;line-height:18pt}
a:link{text-decoration:none;}
a:visited{text-decoration:none;}
a:hover{text-decoration:underline;font-size:125%;color:blue}--></style>
<title>ASP页面防火墙功能演示</title>
</head><bodybackground=back.jpg><%′使用Request.ServerVariables(REMOTE_ADDR)得到IP地址并保存在变量rip中rip=Request
.ServerVariables(REMOTE_ADDR)strip=cstr(rip)′取得IP地址第三个段的值并保存到strip中fori=1to2strip=right(strip,len(strip)-instr(1,strip,.))nextstrip=left(strip,instr(1,strip,.)-1)
′IP地址有效性检验及密码验证,包括两方面的内容:
′如果IP地址符合则通过验证;如果IP地址不符合则检验输入的密码是否正确(此处密码为asp)
if(left(rip,5)<>127.1orstrip<1orstrip>50)andrequest(Passwd)<>aspthen%><p><fontcolor=#FF0000>对不起,你的IP是<%=rip%>,本页面可以访问的IP是127.1.1.*到127.1.50.*之间,如果你是本单位内部网的用户,请确认你的浏览器没有使用代理!<BR></font></p><formaction=demo.aspmethod=POSTid=form1name=form1><p>请输入访问密码:<inputtype=passwordname=Passwd><inputtype=submitvalue=确认name=B1>;</p></form>
<%else%>
′合法用户可以访问的页面,在此可以加入任何信息
祝贺您,您已经顺利通过了页面的安全认证,可以直接使用本站点的资源!
<%endif%>
</body>

H. asp允许数据库内IP访问

If Not (IpRS.bof or IpRS.eof) Then
WhyIpLock=split(IpRS("iplock"),"|")
Response.Write"<BR><ol>你使用的IP段或IP地址已被封锁"
Response.Write"<Li>封锁原因:"&WhyIpLock(1)
Response.Write"<LI>封锁时间:"&WhyIpLock(0)
Response.Write"<LI>请与管理员联系</ol>"
Response.End
End If

====》
If IpRS.eof Then
Response.Write"<BR><ol>你使用的IP段或IP地址未被授权访问!"
Response.Write"<LI>请与管理员联系</ol>"
Response.End
End If

后台管理处小心些,如果你是固定ip的话好说,如果是动态上网别哪天自己也无法登陆就必须手动修改数据库了。

I. asp如何在网页中通过识别IP地址限制访问网页的部分页面

先获取来访者的IP,经判断后转向页面地址,IP判断一般有两个方向:
1、是以区域IP判断,禁止某一区域的IP地址访问,这个要用到IP库
2、是以特定的IP列表禁止访问,这个要在你的数据库中添加有指定的IP列表。
符合上面2个条件的来访者将被转向到其他页面,原理大概是这样,代码自己想想吧。

J. 如何指定某几个IP可以访问特定目录下的ASP的问题

弄个表来存下IP,那些文件里引用一段代码是判定有没有这些IP的,没有就跳到别的页面,有才可以访问不就行了....很简单的.

热点内容
安卓和鸿蒙系统哪个好一些 发布:2025-08-20 21:41:28 浏览:851
红米note扩展存储卡 发布:2025-08-20 21:27:10 浏览:862
验证你的电子邮件地址不能连接服务器 发布:2025-08-20 21:27:09 浏览:63
存储区是什么意思 发布:2025-08-20 21:26:31 浏览:53
压缩袋是什么 发布:2025-08-20 20:48:27 浏览:618
服务器减容会有什么影响 发布:2025-08-20 20:40:23 浏览:150
我的世界怎么联服务器 发布:2025-08-20 20:34:31 浏览:498
c语言编译或解释 发布:2025-08-20 20:27:17 浏览:601
vsm编程 发布:2025-08-20 20:16:31 浏览:913
脚本刷黑石塔 发布:2025-08-20 19:50:08 浏览:984