Here you can find the source of getLocalIPs()
public static List<InetAddress> getLocalIPs()
//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 List<InetAddress> getLocalIPs() { Enumeration<NetworkInterface> interfaces; try {/* ww w . j a v a 2 s.c om*/ 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; } }