Package: ifupdown Version: 0.6.5
When I put the IPv4 style network interface aliases (e.g. eth0:10) in the config file and try to assign an IPv6 address to it, # /etc/network/interfaces iface eth0:10 inet static address 3ffe::01 netmask 64 The command # ifup eth0:10 gives the error "SIOCSIFFLAGS: Cannot assign requested address." Although, 'aliases' are IPv4 style labels for interfaces, and IPv6 specification already allows an interface to have more than one address, it would be useful sometimes to bring up only certain IPv6 address on an interface. Attached herewith is the patch for ifupdown-0.6.5 that allows addition of IPv6 addresses based on an IPv4 style virtual interface 'alias' supplied to the 'ifup' command. I am using Debian stable ifupdown_0.6.7 package from http://packages.debian.org/stable/base/ifupdown
Index: ifupdown-0.6.5/ifupdown.nw =================================================================== --- ifupdown-0.6.5.orig/ifupdown.nw +++ ifupdown-0.6.5/ifupdown.nw @@ -2799,9 +2799,12 @@ char *get_var(char *id, size_t idlen, in <<execute functions>>= char *get_var(char *id, size_t idlen, interface_defn *ifd) { int i; + static char valid_iface[20]; + char* position; + extern address_family addr_inet6; if (strncmpz(id, "iface", idlen) == 0) { - return ifd->real_iface; + <<return the valid interface>> } else { for (i = 0; i < ifd->n_options; i++) { if (strncmpz(id, ifd->option[i].name, idlen) == 0) { @@ -2814,6 +2817,30 @@ char *get_var(char *id, size_t idlen, in } @ +For IPv6, logical interfaces are not needed and are not +supported. But there might the /etc/network/interfaces +files that are configured with such interfaces for IPv6 +and for the sake of compatability, support such interfaces +but strip off the logical offset if present for IPv6 + +<<return the valid interface>>= + position = strchr(ifd->real_iface, ':'); + if (!strncmp(ifd->address_family->name, addr_inet6.name,strlen(addr_inet6.name)) && + (position)) { + i = 0; + while ((strlen(valid_iface) < 20) && + (ifd->real_iface+i != position)) { + *(valid_iface+i) = *(ifd->real_iface+i); + i++; + } + valid_iface[i] = '\0'; + return (valid_iface); + } + else { + return (ifd->real_iface); + } +@ + Which means we can finish of the chunk, thus: <<get [[varvalue]]>>= Index: ifupdown-0.6.5/inet6.defn =================================================================== --- ifupdown-0.6.5.orig/inet6.defn +++ ifupdown-0.6.5/inet6.defn @@ -5,14 +5,16 @@ method loopback description This method may be used to define the IPv6 loopback interface. up - ifconfig %iface% add ::1 + ip addr add ::1 dev %iface% down - ifconfig %iface% del ::1 + ip addr del ::1 dev %iface% method static description This method may be used to define interfaces with statically assigned - IPv6 addresses. + IPv6 addresses. With IPv6 the link is not brought down upon deleting + the IPv6 address, as it seems like a safe bet to presently assume that + the interface will continue to have one or more IPv4 address. options address address -- Address (colon delimited) *required* @@ -24,12 +26,12 @@ method static /address/ is dependent on this choice. mtu size -- MTU size up - ifconfig %iface% [[media %media%]] [[hw %hwaddress%]] [[mtu %mtu%]] up - ifconfig %iface% add %address%/%netmask% - [[ route -A inet6 add ::/0 gw %gateway% ]] + ip link set %iface% [[media %media%]] [[hw %hwaddress%]] [[mtu %mtu%]] up + ip -6 addr add %address%/%netmask% dev %iface% + [[ ip -6 route add ::/0 gw %gateway% ]] down - ifconfig %iface% down + ip -6 addr del %address%/%netmask% dev %iface% method v4tunnel description