I'd like to specify a virtual network interface such as eth0:1 as
network.host (eth0:1). However, looking in
NetworkUtils.getAllAvailableInterfaces() I can see that the
subinterfaces of the available NetworkInterfaces aren't enumerated. I
think something like the following would fix this:
public static List<NetworkInterface> getAllAvailableInterfaces()
throws SocketException {
List allInterfaces = new
ArrayList(10);
NetworkInterface intf;
for (Enumeration en = NetworkInterface.getNetworkInterfaces();
en.hasMoreElements(); ) {
intf = (NetworkInterface) en.nextElement();
allInterfaces.add(intf);
for (Enumeration en2 = intf.getSubInterfaces();
en2.hasMoreElements(); ) {
NetworkInterface subintf = (NetworkInterface)
en2.nextElement();
allInterfaces.add(subintf);
}
}
return allInterfaces;
}
On Saturday, February 4, 2012 at 7:18 PM, Niklas Therning wrote:
Hi,
I'd like to specify a virtual network interface such as eth0:1 as
network.host (eth0:1). However, looking in
NetworkUtils.getAllAvailableInterfaces() I can see that the
subinterfaces of the available NetworkInterfaces aren't enumerated. I
think something like the following would fix this:
public static List getAllAvailableInterfaces()
throws SocketException {
List allInterfaces = new
ArrayList(10);
NetworkInterface intf;
for (Enumeration en = NetworkInterface.getNetworkInterfaces();
en.hasMoreElements(); ) {
intf = (NetworkInterface) en.nextElement();
allInterfaces.add(intf);
for (Enumeration en2 = intf.getSubInterfaces();
en2.hasMoreElements(); ) {
NetworkInterface subintf = (NetworkInterface)
en2.nextElement();
allInterfaces.add(subintf);
}
}
return allInterfaces;
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.