node-modules/utility

get mac address

Closed this issue · 3 comments

getmac is suck

osx

$ ifconfig 
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=2b<RXCSUM,TXCSUM,VLAN_HWTAGGING,TSO4>
    ether c4:2c:03:32:d5:3d 
    media: autoselect (none)
    status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 78:ca:39:b0:e6:7d 
    inet6 fe80::7aca:39ff:feb0:e67d%en1 prefixlen 64 scopeid 0x5 
    inet 192.168.2.104 netmask 0xffffff00 broadcast 192.168.2.255
    media: autoselect
    status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0a:ca:39:b0:e6:7d 
    media: autoselect
    status: inactive
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
    lladdr 60:33:4b:ff:fe:93:2a:62 
    media: autoselect <full-duplex>
    status: inactive
vnic0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:1c:42:00:00:08 
    inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255
    media: autoselect
    status: active
vnic1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:1c:42:00:00:09 
    inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
    media: autoselect
    status: active
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 0a:00:27:00:00:00 
    inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255

linux

$ /sbin/ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:16:3E:00:0A:29  
          inet addr:10.125.5.202  Bcast:10.125.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4034645 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1877492 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:926626551 (883.6 MiB)  TX bytes:284125548 (270.9 MiB)
          Interrupt:14 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:17633 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17633 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2496787 (2.3 MiB)  TX bytes:2496787 (2.3 MiB)

test output

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:282 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2909 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:1975 (1.9 KiB)  TX bytes:20083 (19.6 KiB)
          Interrupt:55

eth0      Link encap:Ethernet  HWaddr 00:18:31:8A:41:C6
          inet addr:10.42.193.19  Bcast:10.42.193.255  Mask:255.255.255.0
          inet6 addr: fe80::218:31ff:fe8a:41c6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:305126 errors:0 dropped:12547 overruns:0 frame:0
          TX packets:49447 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:63758575 (60.8 MiB)  TX bytes:4862291 (4.6 MiB)

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:2404 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2404 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:230580 (225.1 KiB)  TX bytes:230580 (225.1 KiB)