Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

require('os').networkInterfaces() is not listing eth0 (nodejs v0.10.33) #9029

Closed
ricardomat opened this issue Jan 14, 2015 · 3 comments
Closed
Labels

Comments

@ricardomat
Copy link

node v0.10.33 is not listing eth0 when require('os').networkInterfaces is called.

$ node
> x = require('os').networkInterfaces();
{ lo: 
   [ { address: '127.0.0.1',
       family: 'IPv4',
       internal: true } ],
  eth2: 
   [ { address: '192.168.166.105',
       family: 'IPv4',
       internal: false } ],
  eth1: 
   [ { address: '192.168.177.100',
       family: 'IPv4',
       internal: false } ] }

If I check the network interface list from command line in linux, eth0 is listed as a valid and active interface:
$ ifconfig
eth0      Link encap:Ethernet  Endere�o de HW 14:D6:4D:47:C6:E9  
          inet end.: 192.168.176.100  Bcast:192.168.176.255  Masc:255.255.255.0
          UP BROADCASTMULTICAST  MTU:1500  M�trica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colis�es:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          IRQ:225 Endere�o de E/S:0xec00 

eth1      Link encap:Ethernet  Endere�o de HW 14:D6:4D:47:C9:42  
          inet end.: 192.168.177.100  Bcast:192.168.177.255  Masc:255.255.255.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  M�trica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
          colis�es:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:350 (350.0 b)
          IRQ:233 Endere�o de E/S:0x2800 

eth2      Link encap:Ethernet  Endere�o de HW 6C:62:6D:ED:B5:C5  
          inet end.: 192.168.166.105  Bcast:192.168.175.255  Masc:255.255.240.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  M�trica:1
          RX packets:1745 errors:0 dropped:0 overruns:0 frame:0
          TX packets:333 errors:0 dropped:0 overruns:0 carrier:0
          colis�es:0 txqueuelen:1000 
          RX bytes:139275 (136.0 KiB)  TX bytes:55578 (54.2 KiB)
          IRQ:217 Endere�o de E/S:0xc000 

lo        Link encap:Loopback Local  
          inet end.: 127.0.0.1  Masc:255.0.0.0
          UP LOOPBACKRUNNING  MTU:16436  M�trica:1
          RX packets:1003 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1003 errors:0 dropped:0 overruns:0 carrier:0
          colis�es:0 txqueuelen:0 
          RX bytes:101305 (98.9 KiB)  TX bytes:101305 (98.9 KiB)

More details:

$ node -v
v0.10.33
$ uname -a
Linux ecgdgt00 2.6.18-53.1.13.el5 #5 SMP Fri Jan 23 16:29:01 BRST 2009 i686 athlon i386 GNU/Linux

It works ok if eth0 is the only interface in the machine.

@ricardomat
Copy link
Author

I made some tests and noticed that "x = require('os').networkInterfaces();" won't list interfaces that never had network traffic since machine boot. When a cable is plugged into that network interface, it is listed back again.

Shouldn't network interfaces be listed in networkInterfaces() regardless network traffic ?

@ricardomat
Copy link
Author

Actually the problem is not caused because the network interface has never had network traffic since boot. The problem happens if the network interface does not have network carrier (network cable plugged).

But I still understand that network interfaces should be listed regardless it has network carrier or not.

@piranna
Copy link

piranna commented May 20, 2015

I think it makes sense to only show "active" network interfaces, but in some cases it would be needed to list all available ones, so networkInterfaces() would accept a boolean argument to show all of them and it could still be backward compatible...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants