Here you can find the source of getInterfaces()
public static List<InterfaceAddress> getInterfaces()
//package com.java2s; //License from project: Creative Commons License import java.net.InterfaceAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; public class Main { public static List<InterfaceAddress> getInterfaces() { List<InterfaceAddress> result = new ArrayList<InterfaceAddress>(); try {/*from w w w . ja va2s . com*/ Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); while (en.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) en.nextElement(); for (InterfaceAddress address : ni.getInterfaceAddresses()) { if (!address.getAddress().getHostAddress().contains(":") && !address.getAddress().getHostAddress().contains("127.0.0.1")) result.add(address); } } } catch (Exception e) { e.printStackTrace(); } return result; } }