Get name and ip-address for each interface

From: grimson
Date: Sun Apr 12 2009 - 12:55:07 EST

Hello out there,
I got an interesting but challenging problem.
I want to create a daemon-process, which runs on a host with several
NICs. If the daemon gets a request from one of the interfaces, it
should, amongst others, send back the IP-address and/or MAC-address,
interface-name... of the interface from which the request came. And only
of that interface. No infos about local-interfaces and so on.

My approach so far was to invoke ioctl with the SIOCGIFCONF-request and
collect all informations about every active interface on the host. But I
need at least one unique identifier of the interface from which the
request came. With the interface-name for exeample I can call the/
/SIOCGIFADDR-request to get the IP-address. How can I achive this.

Has anybody an idea.

Thanks in advance.

To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at