IpUtils { protected static List<InetAddress> getAllServerAddress() { List<InetAddress> result = new LinkedList<>(); try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); if (interfaces == null) { return null; } while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); List<InterfaceAddress> addresses = current.getInterfaceAddresses(); if (addresses.size() == 0) { continue; } for (InterfaceAddress interfaceAddress : addresses) { InetAddress address = interfaceAddress.getAddress(); result.add(address); } } } catch (SocketException e) { } return result; }  static String getIp(SocketAddress socketAddress); static boolean isValidIpFormat(String ip); static boolean isPort(String str); static InetAddress getFistNonLocalIpv4ServerAddress(); static InetAddress getFistNonLocalIpv4ServerAddress(String ipPrefixPrefer); static boolean isLocal(String host); static List<HostPort> parseAsHostPorts(String addressDesc); static List<InetSocketAddress> parse(String addressDesc); static InetSocketAddress parseSingle(String singleAddress); static Pair<String, Integer> parseSingleAsPair(String singleAddress); static String[] splitIpAddr(String ip);  }
@Test public void test(){ IpUtils.getAllServerAddress().forEach((address) -> { if(address instanceof Inet6Address){ logger.info("{}", address); logger.info("{}", address.getHostAddress()); System.out.println(); } }); }