Penguin

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...)

example
  1. include <linux/sockios.h>
  2. include <sys/ioctl.h>
  3. include <net/route.h>
  4. include <net/if.h>
  5. include <sys/socket.h>
  6. include <stdio.h>
  7. include <unistd.h>
  8. include <errno.h>
  9. include <string.h>

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;

}