调用方式:
getIpAddrForInterfaces("eth0");
getIpAddrMaskForInterfaces("eth0");
getGateWay();
etDns(context);
/**
* ip
*/
public static String getIpAddrForInterfaces(String interfaceName) {
try {
Enumeration<NetworkInterface> enNetworkInterface = NetworkInterface.getNetworkInterfaces(); //获取本机所有的网络接口
while (enNetworkInterface.hasMoreElements()) { //判断 Enumeration 对象中是否还有数据
NetworkInterface networkInterface = enNetworkInterface.nextElement(); //获取 Enumeration 对象中的下一个数据
if (!networkInterface.isUp()) { // 判断网口是否在使用
continue;
}
if (!interfaceName.equals(netw