Java getNetworkInterfaces()不适用于Debian 9
下面的java代码用于返回我的所有网络接口Java getNetworkInterfaces()不适用于Debian 9,java,linux,debian,Java,Linux,Debian,下面的java代码用于返回我的所有网络接口 public class InterfaceTest { public static void main(String[] args) throws SocketException { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); int i=0; w
public class InterfaceTest {
public static void main(String[] args) throws SocketException {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
int i=0;
while (networkInterfaces.hasMoreElements()) {
NetworkInterface nextElement = networkInterfaces.nextElement();
System.out.println(nextElement.getName());
i++;
}
System.out.println(i+" interfaces found!");
}
}
但现在它只回来了
wired
lo
2 interfaces found!
注意:通过在/etc/udev/rules.d/70-persistent-net.rules上指定我的网卡,我将网卡重命名为wired(将mac地址替换为真实地址)
但是,我还有两个usb WiFi加密狗,当我键入ifconfig-a时可以看到
那么,是什么导致java看不到其他网络接口(两个USB WiFi加密狗)
提前感谢您的帮助
wired
lo
2 interfaces found!
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="**00:00:00:00:00:00**", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wired"