问题描述:修改过网卡原始的MAC地址,现在想恢复网卡出厂时原始的MAC地址
问题解决:编译执行下面的C程序即可。
#include #include #include #include #include #include #include
int main() { int fd; struct ifreq ifr; fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1); ioctl(fd, SIOCGIFHWADDR, &ifr); close(fd);
printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", (unsigned char)ifr.ifr_hwaddr.sa_data[0], (unsigned char)ifr.ifr_hwaddr.sa_data[1], (unsigned char)ifr.ifr_hwaddr.sa_data[2], (unsigned char)ifr.ifr_hwaddr.sa_data[3], (unsigned char)ifr.ifr_hwaddr.sa_data[4], (unsigned char)ifr.ifr_hwaddr.sa_data[5]);
return 0; } |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17013648/viewspace-1151904/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/17013648/viewspace-1151904/