Here you can find the source of isPrivateSubnet(InetAddress address)
public static boolean isPrivateSubnet(InetAddress address)
//package com.java2s; //License from project: Apache License import java.net.InetAddress; public class Main { /**//from ww w. j av a2s . c o m * Check if this is a private address, not exposed on the public Internet. * * For IPV4 addresses this is an RFC1918 subnet address ({code 10.0.0.0/8}, * {@code 172.16.0.0/12} and {@code 192.168.0.0/16}), a link-local address * ({@code 169.254.0.0/16}) or a loopback address ({@code 127.0.0.1/0}). * <p> * For IPV6 addresses this is the RFC3514 link local block ({@code fe80::/10}) * and site local block ({@code feco::/10}) or the loopback block * ({@code ::1/128}). * * @return true if the address is private */ public static boolean isPrivateSubnet(InetAddress address) { return address.isSiteLocalAddress() || address.isLoopbackAddress() || address.isLinkLocalAddress(); } }