合法IP地址的判断

cndeath 2008-04-09 02:00:36
如IP段
10.22.130.1-10.22.130.255
10.22.125.0-10.22.125.255

只有公网IP在上面两个IP段中的IP才可以访问页面.

<%
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
'获得公网IP后.下面应该来写代码?help!
%>
...全文
349 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lsf5921 2008-04-09
  • 打赏
  • 举报
回复
(?i:http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
正则
fq7870 2008-04-09
  • 打赏
  • 举报
回复
正则表达式((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
文盲老顾 2008-04-09
  • 打赏
  • 举报
回复
10.22.130.1-10.22.130.255
10.22.125.0-10.22.125.255

<%
dim IPList(1,1)
IPList(0,0) = "10.22.130.1"
IPList(0,1) = "10.22.130.255"
IPList(1,0) = "10.22.125.0"
IPList(1,1) = "10.22.125.255"

dim IPFlag
IPFlag = false

for i = 0 to ubound(IPList)
if IP2N(yourIP) >= IP2N(IPList(i,0)) and IP2N(yourIP) <= IP2N(IPList(i,1)) then
IPFlag = true
exit for
end if
next

if not IPFlag then
response.write "IP被禁止"
response.end
end if

Function IP2N(vStr)
Dim IP,intLoop
IP2N = 0
IP = Split(vStr,".")
For intLoop = 0 To UBound(IP)
IP2N = 256 ^ (UBound(IP) - intLoop) * CInt(IP(intLoop)) + IP2N
Next
End Function
%>
小逗狗 2008-04-09
  • 打赏
  • 举报
回复
<%
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
'获得公网IP后.下面应该来写代码?help!
end if
ips=split(userip,".")
if cint(ips[0])<>10 or cint(ips[1])<>22 or (cint(ips[2])<>130 and cint(ips[3])<>125) then
response.write("非法的IP")
response.end
end if

%>
littlelam 2008-04-09
  • 打赏
  • 举报
回复

dim userip:userip=Request.ServerVariables("REMOTE_ADDR")
dim arrIp:arrIp=Split(userip,".")
If Cint(arrIp(0))<>10 or Cint(arrIp(1))<>22 or (Cint(arrIp(2))<>130 and Cint(arrIp(2))<>125) Then
Response.Write("Forbidden")
Response.End
end
littlelam 2008-04-09
  • 打赏
  • 举报
回复

dim userip:userip=Request.ServerVariables("REMOTE_ADDR")
dim arrIp:arrIp=Split(userip,".")
If Cint(arrIp(0))<>10 or Cint(arrIp(1))<>22 or (Cint(arrIp(2))<>130 and Cint(arrIp(3))<>125) Then
Response.Write("Forbidden")
Response.End
end

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧