Here you can find the source of getAllLocalIP()
public static List<?> getAllLocalIP()
//package com.java2s; 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 List<?> getAllLocalIP() { List<String> localServers = new ArrayList<String>(); String regExp = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"; try {// w ww. j a v a 2s. com Enumeration<?> netInterfaces = NetworkInterface.getNetworkInterfaces(); InetAddress ip = null; while (netInterfaces.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement(); Enumeration<?> address = ni.getInetAddresses(); while (address.hasMoreElements()) { ip = (InetAddress) address.nextElement(); if (!ip.isLoopbackAddress() && ip.getHostAddress().matches(regExp)) { localServers.add(ip.getHostAddress()); } } } } catch (SocketException e) { e.printStackTrace(); } return localServers; } }