asp 는 ip 주소 가 내부 네트워크 나 개인 ip 주소 의 코드 공유 인지 확인 합 니 다.

1535 단어 aspip인 네트사유
asp 는 ip 주소 가 개인/내부 네트워크 ip 주소 소스 코드 인지 확인 합 니 다.
내부 네트워크/개인 IP 주소 네트워크 는 다음 과 같 고 127 로 시작 하 는 순환 주소 도 있 습 니 다.
10.0.0.0-10.255.255.255
172.16.0.0―172.31.255.255
192.168.0.0-192.168.255.255
구현 코드:

<%
function IpToNumber(ip)'IP      
 arr=split(ip,".")
 IpToNumber=256*256*256*clng(arr(0))+256*256*clng(arr(1))+256*clng(arr(2))+clng(arr(3))
end function
function IsPrivateIp(ip)'     IP      /  ip  
 if instr(ip,"127.")=1 then'  IP  
  IsPrivateIp=true:exit function
 end if
 ABegin=IpToNumber("10.0.0.0"):AEnd=IpToNumber("10.255.255.255")'A   IP  
 BBegin=IpToNumber("172.16.0.0"):BEnd=IpToNumber("172.31.255.255")'B   IP  
 CBegin=IpToNumber("192.168.0.0"):CEnd=IpToNumber("192.168.255.255")'C   IP  
 IpNum=IpToNumber(ip)
 IsPrivateIp=(ABegin<=IpNum and IpNum<=AEnd) or (BBegin<=IpNum and IpNum<=BEnd) or (CBegin<=IpNum and IpNum<=CEnd)
end function
Response.Write IsPrivateIp("11.255.255.255")&"<br>"'false
Response.Write IsPrivateIp("182.255.255.255")&"<br>"'false
Response.Write IsPrivateIp("172.30.255.255")&"<br>"'true
Response.Write IsPrivateIp("192.168.205.2")&"<br>"'true
Response.Write IsPrivateIp("127.168.205.2")'true
 %>

좋은 웹페이지 즐겨찾기