Here you can find the source of isPrivateIP(InetAddress ip)
public static boolean isPrivateIP(InetAddress ip)
//package com.java2s; //License from project: Open Source License import java.net.*; public class Main { private static final byte IP6_PRIVATE_PREFIX = (byte) 0xfd; /**//from w w w.j a v a2s. c o m * Determines if the supplied IP Address is a private non-routed IP * Address. RFC 1918 dictates the private IP space for IPv4 * <p/> * <pre> * 10/8 - 10.0.0.0 through 10.255.255.255 (class A) * 172.16/12 - 172.16.0.0 through 172.31.255.255 (class B) * 192.168/16 - 192.168.0.0 through 192.168.255.255 (class C) * </pre> * <p/> * For IPv6 there are unique local addresses in the FD00::/8 space * as well as a deprecated site local addresses in the FEC0::/10 * space which will both result in this returning {@code true}. */ public static boolean isPrivateIP(InetAddress ip) { if (ip.isSiteLocalAddress()) return true; else if (ip instanceof Inet6Address) return ip.getAddress()[0] == IP6_PRIVATE_PREFIX; return false; } }