In the TCP/IP protocol, three IP address zones are reserved for private addresses with the following address ranges:
10.0.0.0/8:10.0.0.0~10.255.255.255
172.16.0.0/12:172.16.0.0~172.31.255.255
192.168.0.0/16:192.168.0.0~192.168.255.255
So, go directly to the code:
Public Static BooleanInternalip(String IP) {byte[]Addr= Ipaddressutil.textToNumericFormatV4(IP);returnInternalip(Addr);}Public Static BooleanInternalip(byte[] addr) {Final byteB0= addr[0];Final byteB1= addr[1]; //10.X.X.X/8 Final bytesection_1=0x0A; //172.16.X.X/12 Final bytesection_2= (byte)0xAC;Final byteSection_3= (byte)0x10;Final byteSection_4= (byte)0x1F; //192.168.X.X/16 Final bytesection_5= (byte)0xC0;Final byteSection_6= (byte)0xa8;Switch(B0) { Casesection_1:return true; Casesection_2:if(B1>=Section_3&&B1<=Section_4) {return true; } Casesection_5:Switch(B1) { CaseSection_6:return true; }default:return false; }}
Java to determine whether the IP address is intranet IP or public network IP