Bind to virtual network interface (subinterface)


(Niklas Therning) #1

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<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;
}

Any chance this could be incorporated?

Regards,
Niklas Therning


(Shay Banon) #2

Sure, opened an issue: https://github.com/elasticsearch/elasticsearch/issues/1667.

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;
}

Any chance this could be incorporated?

Regards,
Niklas Therning


(system) #3