On a Linux box, the common interface names look like eth0, eth1, etc. I know how to find at least one IP address using gethostbyname or similar functions, but I don’t know any way to specify which named interface I want the IP address of. I could use ifconfig and parse the output, but shelling out for this information seems… inelegant.
Is there a way to, say, enumerate all the interfaces and their IP addresses (and maybe MAC addresses) into a collection? Or at least something along the lines of gethostbyinterface('eth0')?
Update: Moved dead link to a comment (for posterity) (thanks @obayhan), and added syntax highlighting.