ipaddr-linux
Wrap ip -s addr and parse result to json format (work on linux, not work on mac).
Command-line Example
lo:device: 'lo'link: state: 'UNKNOWN'inet: addr: '127.0.0.1/8'inet6: addr: '::1/128' scope: 'host'rx:bytes: 1154563packets: 16185errors: 0dropped: 0overrun: 0tx:bytes: 1154563packets: 16185errors: 0dropped: 0overrun: 0eth0:device: 'eth0'link: state: 'DOWN' hwaddr: '50:7b:9d:68:02:a3'rx: bytes: 0 packets: 0 errors: 0 dropped: 0 overrun: 0tx: bytes: 0 packets: 0 errors: 0 dropped: 0 overrun: 0wlan0:device: 'wlan0'link: state: 'UP' hwaddr: 'dc:53:60:6b:32:bc'inet: addr: '192.168.1.42/24'inet6: addr: 'fe80::de53:60ff:fe6b:32bc/64' scope: 'link'rx:bytes: 184690386packets: 361847errors: 0dropped: 0overrun: 0tx:bytes: 125560762packets: 209219errors: 0dropped: 0overrun: 0docker0:device: 'docker0'link: state: 'DOWN' hwaddr: '02:42:20:91:4e:d1'inet: addr: '172.17.0.1/16'rx: bytes: 0 packets: 0 errors: 0 dropped: 0 overrun: 0tx: bytes: 0 packets: 0 errors: 0 dropped: 0 overrun: 0
API Example
In addition to ipaddr-linux shell command-line, you can also require('ipaddr-linux')
from your node.js application as you wish.
var promise = ; // this return a promisepromise;
How it works
This module is based on ip -s addr
linux command. It's tested and works on Ubuntu 17.04
install
With npm do:
npm install ipaddr-linux -g
license
MIT