I'm setting an alias IP on eth0 by using 'ifconfig eth0:1 192.168.3.1 netmask 255.255.255.0'. But there's an error popup: SIOCSIFFLAGS: Cannot assign requested address SIOCSIFNETMASK: Cannot assign requested address
The version of ifconfig is: net-tools 1.60 ifconfig 1.42 (2001-04-13)
The error is caused by the ioctl() function inside ifconfig source code: /* Set a certain interface flag. */ static int set_flag(char *ifname, short flag) { struct ifreq ifr;
safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) {
fprintf(stderr, _("%s: unknown interface: %s\n"),
ifname, strerror(errno));
return (-1);
}
safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_flags |= flag;
**if (ioctl(skfd, SIOCSIFFLAGS, &ifr) < 0) {
perror("SIOCSIFFLAGS");
return -1;
}**
return (0);
}
My question is, could anyone help explain why ioctl(skfd, SIOCSIFFLAGS, &ifr) returns Cannot assign requested address (errno=99)