Possible Duplicate:
Linux / C++: Get the IP Address of local computer
I am trying to get my local computer's IP and MAC addresses of all interfaces, but I can not really succeed. I need to get it together, so I know which IP belongs to which MAC.
I went through a lot of searching on google and even here, but I can not really find a C code for this.
Could you please help me?
Thanks in advance! I would really appreciate that!
On relatively recent versions of Linux, you can just read the contents of /sys/class/net/eth0/address
(substituting any network interface name for eth0
) to get the hardware address of an interface.