Here you can find the source of getInternalIp()
public static String getInternalIp() throws SocketException
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.Inet4Address; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class Main { public static String getInternalIp() throws SocketException { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) { return addr.getHostAddress(); }/*from w ww . j av a2 s.c om*/ } } return null; } }