日期:2014-05-17  浏览次数:21146 次

获取本地ip信息为::1
<%
dim fs,f,input(1000),m
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("ip.txt"),1,true)
n=0
do While Not f.AtEndOfStream
n=n+1
fileline=f.readline
input(i)=fileline
if Request.ServerVariables("remote_addr")<>input(i) then
response.redirect("http://loalhost/test1") 
end if
loop
f.Close
set f=Nothing
set fs=Nothing
%>
新建一个ip.txt文件每行存一个ip,如果用户ip在文件中则允许继续访问 否则跳转
发现获取到的本机ip(localhost)为"::1"不知道咋回事?这个程序能不能完成任务?

------解决方案--------------------
::1是ipv6格式的本地地址。
你禁用本地连接着的ipv6就可以显示127.0.0.1