Here you can find the source of isLocal(InetAddress a)
public static boolean isLocal(InetAddress a)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; public class Main { public static boolean isLocal(InetAddress a) { List<InetAddress> localIPs = getLocalIPs(); if (localIPs == null) { return false; } else {/*from w ww . j av a 2s. c o m*/ return localIPs.contains(a); } } public static List<InetAddress> getLocalIPs() { Enumeration<NetworkInterface> interfaces; try { interfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { return null; } List<InetAddress> ips = new ArrayList<InetAddress>(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); if (current != null) { Enumeration<InetAddress> addresses = current.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); if (addr != null) { ips.add(addr); } } } } return ips; } }