Here you can find the source of isLocalAddress(InetAddress addr)
static boolean isLocalAddress(InetAddress addr)
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; public class Main { static boolean isLocalAddress(InetAddress addr) { // check if the address is a valid special local or loop back if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) return true; // check if the address is defined on any interface try {/*from www .jav a 2 s. c o m*/ return NetworkInterface.getByInetAddress(addr) != null; } catch (SocketException e) { return false; } } }