Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
SIOCSIFNAME
Edit
PageHistory
Diff
Info
LikePages
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: #include <linux/sockios.h> #include <sys/ioctl.h> #include <net/route.h> #include <net/if.h> #include <sys/socket.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #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; }
One page links to
SIOCSIFNAME
:
ioctl_list(2)