This allows you to rename an interface. Beware that a renamed interface will keep it's new name even after it's downed, the interface must be destroyed (by for example removing the module) to "undo" this. (of course you can just rename it back...)
int main(int argc,char **argv) {
int fd; struct ifreq ifr;
if (argc<3) {
fprintf(stderr,"Usage: ifmv oldname newname\n"); return 1;
}
if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket(PF_INET, SOCK_DGRAM, 0)"); return -1;
}
strncpy(ifr.ifr_name,argv[1?,sizeof(ifr.ifr_name)); strncpy(ifr.ifr_newname,argv[2?,sizeof(ifr.ifr_newname));
if (ioctl(fd, SIOCSIFNAME, &ifr)==-1) {
perror("ioctl(SIOCSIFNAME)"); return 1;
}
return 0;
}
One page links to SIOCSIFNAME: