public static Map<String, Set<InetAddress>> getNetworkInterfaceAddresses(boolean includeLoopback) {
        //JVM returns interfaces in a non-predictable order, so to make this more predictable
        //let's have them sort by interface name (by using a TreeMap).
        Map<String, Set<InetAddress>> interfaceAddressMap = new TreeMap<>();
        try {
            Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
            while (ifaces.hasMoreElements()) {
                NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
                //We only care about usable interfaces.
                if (!iface.isUp()) {
                    continue;
                }
                if (!includeLoopback && iface.isLoopback()) {
                    continue;
                }
                String name = iface.getName();
                Enumeration<InetAddress> ifaceAdresses = iface.getInetAddresses();
                while (ifaceAdresses.hasMoreElements()) {
                    InetAddress ia = ifaceAdresses.nextElement();
                    if (!includeLoopback && ia.isLoopbackAddress()) {
                        continue;
                    }
                    // We want to filter out mac addresses
                    // Let's filter out docker interfaces too
                    if (!ia.getHostAddress().contains(":") && !(name != null && name.toLowerCase().contains("docker"))) {
                        Set<InetAddress> addresses = interfaceAddressMap.get(name);
                        if (addresses == null) {
                            addresses = new LinkedHashSet<>();
                        }
                        addresses.add(ia);
                        interfaceAddressMap.put(name, addresses);
                    }
                }
            }
        } catch (SocketException ex) {
            //noop
        }
        return interfaceAddressMap;
    }
public static Map < String , Set < InetAddress > > getNetworkInterfaceAddresses ( boolean includeLoopback ) { Map < String , Set < InetAddress > > interfaceAddressMap = new TreeMap < > ( ) ; try { Enumeration ifaces = NetworkInterface . getNetworkInterfaces ( ) ; while ( ifaces . hasMoreElements ( ) ) { NetworkInterface iface = ( NetworkInterface ) ifaces . nextElement ( ) ; if ( ! iface . isUp ( ) ) { continue ; } if ( ! includeLoopback && iface . isLoopback ( ) ) { continue ; } String name = iface . getName ( ) ; Enumeration < InetAddress > ifaceAdresses = iface . getInetAddresses ( ) ; while ( ifaceAdresses . hasMoreElements ( ) ) { InetAddress ia = ifaceAdresses . nextElement ( ) ; if ( ! includeLoopback && ia . isLoopbackAddress ( ) ) { continue ; } if ( ! ia . getHostAddress ( ) . contains ( ":" ) && ! ( name != null && name . toLowerCase ( ) . contains ( "docker" ) ) ) { Set < InetAddress > addresses = interfaceAddressMap . get ( name ) ; if ( addresses == null ) { addresses = new LinkedHashSet < > ( ) ; } addresses . add ( ia ) ; interfaceAddressMap . put ( name , addresses ) ; } } } } catch ( SocketException ex ) { } return interfaceAddressMap ; }
Returns a {@link Set} of {@link InetAddress} per {@link NetworkInterface} as a {@link Map}.

@return