title: Unable to get all network interfaces with NetworkInterface.getNetworkInterfaces on Linux
body: <p>I need to print all the mac addresses of my machine. The recommended way is to use NetworkInterface.getNetworkInterfaces() and iterate on the enumeration returned. However when some devices are down ( NO Ip is configured ) then the above method will not return the interfaces.</p>
  
  <h3>Running "ip addr" will return the following</h3>
  
  <ol>
  <li>lo:  mtu 16436 qdisc noqueue 
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
  inet6 ::1/128 scope host 
     valid_lft forever preferred_lft forever</li>
  <li>G2:  mtu 1500 qdisc pfifo_fast qlen 1000
  link/ether 00:03:b2:75:99:c2 brd ff:ff:ff:ff:ff:ff</li>
  <li>G1:  mtu 1500 qdisc pfifo_fast qlen 1000
  link/ether <strong><em>00:03:b2:75:99:c3</em></strong> brd ff:ff:ff:ff:ff:ff
  inet 10.205.191.123/16 brd 10.205.255.255 scope global G1
  inet6 fe80::203:b2ff:fe75:99c3/64 scope link 
     valid_lft forever preferred_lft forever</li>
  <li>eth2:  mtu 1500 qdisc noop qlen 1000
  link/ether 00:03:b2:75:99:c4 brd ff:ff:ff:ff:ff:ff</li>
  <li>eth3:  mtu 1500 qdisc noop qlen 1000
  link/ether 00:03:b2:75:99:c5 brd ff:ff:ff:ff:ff:ff</li>
  </ol>
  
  <h3>However when I run Java code (even as root or with network privileges) I only get the loopback and G1 interfaces.</h3>
  
  <p>Here is the code I wrote for testing purposes :</p>
  
  <pre><code>Enumeration&lt;NetworkInterface&gt; ni = NetworkInterface.getNetworkInterfaces();
  while(ni.hasMoreElements()){
  NetworkInterface nextElement = ni.nextElement();
  byte[] mac = nextElement.getHardwareAddress();
  if (mac != null) {
           StringBuffer macAddress = new StringBuffer();
           for (int i = 0; i &lt; mac.length; i++) {
                macAddress.append(String.format("%02X%s", mac[i], (i &lt; mac.length - 1) ? ":" : ""));
           }
           System.out.println(macAddress.toString());
  }
  }
  </code></pre>
  
  <p>The output is: <strong><em>00:03:B2:75:99:C3</em></strong> (of G1) only.</p>
  
  <p>I do want a pure java solution if possible.
  <br>Any thoughts ? </p>