question: public static synchronized Collection < String > allLocalIps ( ) { List < String > ips = new ArrayList < > ( 4 ) ; try { Enumeration < NetworkInterface > itfs = NetworkInterface . getNetworkInterfaces ( ) ; if ( itfs != null ) { for ( NetworkInterface itf : asIterable ( itfs ) ) { if ( ! itf . isLoopback ( ) ) { Enumeration < InetAddress > addrs = itf . getInetAddresses ( ) ; for ( InetAddress addr : asIterable ( addrs ) ) { String hostAddr = addr . getHostAddress ( ) ; if ( ! addr . isLoopbackAddress ( ) && ! ips . contains ( hostAddr ) ) ips . add ( hostAddr ) ; } } } } } catch ( SocketException ignore ) { return Collections . emptyList ( ) ; } Collections . sort ( ips ) ; return ips ; }
target:  Gets a list of all local non-loopback IPs known to this JVM. Note that this will include both IPv4 and IPv6 addresses (even if one "resolves" into another). Loopbacks will be skipped.