Here you can find the source of getNetworkInterface()
private static String getNetworkInterface()
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; import java.util.regex.Pattern; public class Main { private static String getNetworkInterface() { String networkInterfaceName = ">>>> modify networkInterface in us.codecraft.webmagic.utils.ProxyUtils"; Enumeration<NetworkInterface> enumeration = null; try {//from ww w . j ava 2 s . co m enumeration = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e1) { e1.printStackTrace(); } while (enumeration.hasMoreElements()) { NetworkInterface networkInterface = enumeration.nextElement(); Enumeration<InetAddress> addr = networkInterface.getInetAddresses(); while (addr.hasMoreElements()) { String s = addr.nextElement().getHostAddress(); Pattern IPV4_PATTERN = Pattern .compile("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$"); if (s != null && IPV4_PATTERN.matcher(s).matches()) { networkInterfaceName += networkInterface.toString() + "IP:" + s + "\n\n"; } } } return networkInterfaceName; } }