我自己用的方法是把IP分成4个段,循环判断.
很早以前写的
<%
cus_ip=getip()
iptest = Split(cus_ip, ".")
sql="select * from ip where first='"&iptest(0)&"'"        '如果IP地址的第一位验证存在,则开始验证第二位
set rs=conn.execute(sql)
if not rs.eof and not rs.bof then
    do while not rs.eof
        if rs("second")="*" then                       '如果IP地址的第二位为*,则转向
            session("ip_error")="程序拒绝您现在所用的IP访问管理页面,请您更换IP后重新访问!"
            Response.Redirect("../ip/ip_error.asp")
        else                                                        '如果IP地址的第二位不为*,则还需要验证第三位
            if rs("second")=iptest(1)  then
                if rs("third")="*" then            '如果IP地址的第三位为*,则转向
                    session("ip_error")="程序拒绝您现在所用的IP访问管理页面,请您更换IP后重新访问!"
                    Response.Redirect("../ip/ip_error.asp")
                else                         '如果IP地址的第三位不为*,则还需要验证第四位                                            
                    if rs("third")=iptest(2) then
                        if rs("forth")="*" or rs("forth")=iptest(3) then
                            session("ip_error")="程序拒绝您现在所用的IP访问管理页面,请您更换IP后重新访问!"
                            Response.Redirect("../ip/ip_error.asp")
                        end if
                    end if
                end if
            end if
        end if
    rs.movenext
    loop
end if    
rs.close
set rs=nothing                    
%>