#include <net/if.h>
char *if_indextoname(unsigned ifindex, char *ifname);
int main(int argc, char* argv[])
{
char* ethx = "eth0";
if (argc > 1)
ethx = argv[1];
printf("%d->%s\n", if_nametoindex(ethx), ethx);
}
转载于:https://www.cnblogs.com/mull/archive/2013/05/13/4477824.html