# Bind to virtual network interface (subinterface)

**URL:** <https://discuss.elastic.co/t/bind-to-virtual-network-interface-subinterface/6594>\
**Category:** Elasticsearch\
**Created:** [February 4, 2012, 5:18pm UTC](https://discuss.elastic.co/t/bind-to-virtual-network-interface-subinterface/6594 "2012-02-04T17:18:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niklas\_Therning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niklas_therning/32/2847_2.png) [@Niklas\_Therning](https://discuss.elastic.co/u/Niklas_Therning)\
**Post date:** [February 4, 2012, 5:18pm UTC](https://discuss.elastic.co/t/bind-to-virtual-network-interface-subinterface/6594/1 "2012-02-04T17:18:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 5, 2012, 5:07pm UTC](https://discuss.elastic.co/t/bind-to-virtual-network-interface-subinterface/6594/2 "2012-02-05T17:07:22Z")

</div>

Sure, opened an issue: [Network: Allow to specify sub interfaces (virtual) in network configuration · Issue #1667 · elastic/elasticsearch · GitHub](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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:40am UTC](https://discuss.elastic.co/t/bind-to-virtual-network-interface-subinterface/6594/3 "2017-07-06T03:40:31Z")

</div>


