This more of a self.note here, about programmatically accessing network interface.
Well, nothing can really beat ip addr show but here we go with few programming languages I like to paw at.
In Ruby 2.1:
1 2 3 4 5 | |
In python:
Here I played with sockets but many python veterans suggest to use something like netifaces so did a pip install netifaces and then...
1 2 3 4 | |
In perl:
Similarly had to use Net::Interface package.
1 2 3 4 5 6 7 8 | |
In nodejs:
Last but not the least, my current fav!
1 2 | |
Well, there might always be better ways to do this, do share your way.