node-modules / address

Get current machine IP and MAC address.
Other
233 stars 32 forks source link

How to get all the infomation of interafces ? #36

Open liaodalin19903 opened 1 year ago

liaodalin19903 commented 1 year ago

Hello, I use the default method to get the addresses of my PC:

address((err: any, addrs: { ip: any; ipv6: any; mac: any; }) => {
  console.log(addrs.ip, addrs.ipv6, addrs.mac);
  // '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});

it can get the IP & IPv6 address and MAC. but it do not get the name of interface, how to get the all infomation of the interface like below?

en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=460<TSO4,TSO6,CHANNEL_IO>
    ether 36:2d:55:6a:38:80 
    media: autoselect <full-duplex>
    status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=460<TSO4,TSO6,CHANNEL_IO>
    ether 36:2d:55:6a:38:84 
    media: autoselect <full-duplex>
    status: inactive
ap1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=400<CHANNEL_IO>
    ether 3e:a6:f6:07:69:27 
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: inactive
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
    ether 3c:a6:f6:07:69:27 
    inet6 fe80::14d9:a19:3b15:1726%en0 prefixlen 64 secured scopeid 0xb 
    inet 192.168.2.7 netmask 0xffffff00 broadcast 192.168.2.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
...