Bind to virtual network interface (subinterface)

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

Sure, opened an issue: Network: Allow to specify sub interfaces (virtual) in network configuration · Issue #1667 · elastic/elasticsearch · GitHub.

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