title: NetworkInterface.getNetworkInterfaces() not listing all interfaces
body: <p>I have three interfaces <code>(eth0,Loopback,wlan0)</code> on my machine and i want to get use Java-API to get the mac address.</p>
  
  <ul>
  <li><p>I use this code.</p>
  
  <pre><code>Enumeration&lt;NetworkInterface&gt; nets = NetworkInterface.getNetworkInterfaces();
      for (NetworkInterface netint : Collections.list(nets))
          displayInterfaceInformation(netint);
  }
  
  static void displayInterfaceInformation(NetworkInterface netint) 
    throws SocketException 
  {
      System.out.println("Display name: " 
         + netint.getDisplayName());
      System.out.println("Hardware address: " 
         + Arrays.toString(netint.getHardwareAddress()));
  }
  </code></pre></li>
  <li><p>But that code print <code>wlan0,loopback</code>, <strong>but missed  eth0</strong> .</p></li>
  <li>My OS Ubuntu, any help.</li>
  </ul>
  
  <p><strong>Update</strong>  </p>
  
  <ul>
  <li><p>The o/p (<code>strace -f java Networks 2&gt;&amp;1| grep ioctl</code>).. <strong>blank(empty)</strong>.</p></li>
  <li><p><code>java -version</code></p></li>
  </ul>
  
  <p>java version "1.7.0_21"
  Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
  Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)</p>
  
  <ul>
  <li><strong>strace ifconfig 2>&amp;1 | grep ioctl</strong></li>
  </ul>
  
  <p><code></p>
  
  <pre><code>ioctl(4, SIOCGIFCONF, {80, {{"lo", {AF_INET, inet_addr("127.0.0.1")}}, {"wlan0", {AF_INET, inet_addr("192.168.1.101")}}}}) = 0
  ioctl(5, SIOCGIFFLAGS, {ifr_name="eth0", ifr_flags=IFF_UP|IFF_BROADCAST|IFF_MULTICAST}) = 0
  ioctl(5, SIOCGIFHWADDR, {ifr_name="eth0", ifr_hwaddr=-----------------}) = 0
  ioctl(5, SIOCGIFMETRIC, {ifr_name="eth0", ifr_metric=0}) = 0
  ioctl(5, SIOCGIFMTU, {ifr_name="eth0", ifr_mtu=1500}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="eth0", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="eth0", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFTXQLEN, {ifr_name="eth0", ifr_qlen=1000}) = 0
  ioctl(4, SIOCGIFADDR, {ifr_name="eth0", ???}) = -1 EADDRNOTAVAIL (Cannot assign requested address)
  ioctl(5, SIOCGIFFLAGS, {ifr_name="lo", ifr_flags=IFF_UP|IFF_LOOPBACK|IFF_RUNNING}) = 0
  ioctl(5, SIOCGIFHWADDR, {ifr_name="lo", ifr_hwaddr=00:00:00:00:00:00}) = 0
  ioctl(5, SIOCGIFMETRIC, {ifr_name="lo", ifr_metric=0}) = 0
  ioctl(5, SIOCGIFMTU, {ifr_name="lo", ifr_mtu=16436}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="lo", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="lo", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFTXQLEN, {ifr_name="lo", ifr_qlen=0}) = 0
  ioctl(4, SIOCGIFADDR, {ifr_name="lo", ifr_addr={AF_INET, inet_addr("127.0.0.1")}}) = 0
  ioctl(4, SIOCGIFDSTADDR, {ifr_name="lo", ifr_dstaddr={AF_INET, inet_addr("127.0.0.1")}}) = 0
  ioctl(4, SIOCGIFBRDADDR, {ifr_name="lo", ifr_broadaddr={AF_INET, inet_addr("0.0.0.0")}}) = 0
  ioctl(4, SIOCGIFNETMASK, {ifr_name="lo", ifr_netmask={AF_INET, inet_addr("255.0.0.0")}}) = 0
  ioctl(5, SIOCGIFFLAGS, {ifr_name="wlan0", ifr_flags=IFF_UP|IFF_BROADCAST|IFF_RUNNING|IFF_MULTICAST}) = 0
  ioctl(5, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr=---------------}) = 0
  ioctl(5, SIOCGIFMETRIC, {ifr_name="wlan0", ifr_metric=0}) = 0
  ioctl(5, SIOCGIFMTU, {ifr_name="wlan0", ifr_mtu=1500}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="wlan0", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFMAP, {ifr_name="wlan0", ifr_map={mem_start=0, mem_end=0, base_addr=0, irq=0, dma=0, port=0}}) = 0
  ioctl(5, SIOCGIFTXQLEN, {ifr_name="wlan0", ifr_qlen=1000}) = 0
  ioctl(4, SIOCGIFADDR, {ifr_name="wlan0", ifr_addr={AF_INET, inet_addr("192.168.1.101")}}) = 0
  ioctl(4, SIOCGIFDSTADDR, {ifr_name="wlan0", ifr_dstaddr={AF_INET, inet_addr("192.168.1.101")}}) = 0
  ioctl(4, SIOCGIFBRDADDR, {ifr_name="wlan0", ifr_broadaddr={AF_INET, inet_addr("192.168.1.255")}}) = 0
  ioctl(4, SIOCGIFNETMASK, {ifr_name="wlan0", ifr_netmask={AF_INET, inet_addr("255.255.255.0")}}) = 0
  </code></pre>
  
  <p></code></p>
  
  <p><strong>ifconfig</strong></p>
  
  <pre><code>$ ifconfig
  eth0      Link encap:Ethernet  HWaddr -------------  
            UP BROADCAST MULTICAST  MTU:1500  Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  
  lo        Link encap:Local Loopback  
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:16436  Metric:1
            RX packets:1695 errors:0 dropped:0 overruns:0 frame:0
            TX packets:1695 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0 
            RX bytes:129949 (129.9 KB)  TX bytes:129949 (129.9 KB)
  
  wlan0     Link encap:Ethernet  HWaddr -------------------  
            inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
            inet6 addr: fe80::-------------- Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:8396 errors:0 dropped:0 overruns:0 frame:0
            TX packets:5524 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:3959941 (3.9 MB)  TX bytes:1513934 (1.5 MB)
  </code></pre>