On a Linux box, the common interface names look like eth0, eth1, etc. I know how to find at least one IP using gethostbyname
or similar functions, but I don't know any way to specify which named interface I want the IP 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 IPs (and maybe MAC addresses) into a collection? Or at least something along the lines of gethostbyinterface("eth0")
?