How do I add an additional IPv6 address to /etc/network/interfaces?
Solution 1
In the question you reference, the second answer shows the equivalent solution for IPv4. In the case of IPv6, the /etc/network/interfaces
file should contain something like this:
iface eth0 inet6 static
address 2001:db8:1:2::2
netmask 64
# Add additional IPv6 addresses when $IFACE goes up
up ip -6 addr add 2001:db8:1:2::3/64 dev $IFACE
up ip -6 addr add 2001:db8:1:2::4/64 dev $IFACE
# Remove them when $IFACE goes down
down ip -6 addr del 2001:db8:1:2::3/64 dev $IFACE
down ip -6 addr del 2001:db8:1:2::4/64 dev $IFACE
You will need the iproute2
package installed, but you should use ip
instead of ifconfig
anyway.
For adding a whole /64 to an interface: There are some Q&As in serverfault.se, like "Adding a whole IPv6 /64 block to an network interface on debian" or "Can I bind a (large) block of addresses to an interface?". Maybe they can help you.
Solution 2
It would appear (tested with ifupdown version 0.7.53.1) that we can add several iface eth0 inet6
stanzas to the interfaces
file, which is more declarative than the accepted answer. The following code instructs the ifupdown suite to use stateless autoconfiguration and two additional static IPv6 addresses for the eth0
network interface:
iface eth0 inet6 auto
iface eth0 inet6 static
address 3ffe:ffff::dead:beef
netmask 32
iface eth0 inet6 static
address 3ffe:ffff::c0de:d00d
netmask 32
Solution 3
Here is what I did for multiple v6 addresses in interfaces file. First thing to consider is there cannot be two gateways, so you add a route below the second address.
iface ens802f0 inet6 static
address 1154::1154
netmask 64
gateway 1154::130
iface ens802f0 inet6 static
address 1063::105
netmask 64
up ip -6 route add 1063::/64 via 1063::254 || true
Related videos on Youtube
Skaperen
Updated on September 18, 2022Comments
-
Skaperen almost 2 years
this question How do I add an additional IP address to /etc/network/interfaces? mostly asks what i want except that i want to add more IPv6 addresses in the same interface
eth0
without incrementing toeth0.1
and so on. theifconfig
command does IPv6 likeifconfig eth0 add ...
so ... how can i add more IPv6 addresses toeth0
?-
Skaperen about 9 yearsit would be nice if there was a practical way to do a whole /64
-
kasperd about 9 yearsYou can find some information about using a full /64 block on a single host here: serverfault.com/questions/590038/…
-
-
Skaperen about 9 yearsthat local block route feature works so all i need to do now is get that added so it puts it back on reboot
-
Michael Hampton almost 8 yearsThis is the "proper" answer - for IPv6 and IPv4!
-
Sverre over 6 yearsin my case your answer did not work, but the approved one above did work. I am not sure why it might since it is a virtual machine (xen)?
-
Witiko over 6 yearsIt would be useful to know what version of ifupdown you use. Can you look into the manpage of ifconfig?
-
AngerClown over 4 yearsWhile this works, it may not do what you want with respect to private addressing and router advertisements. See salsa.debian.org/debian/ifupdown/blob/master/inet6.defn for what actually happens. It seems like the order matters here for each of the
inet6
statements. It may make sense to have a singleauto
declaration and then usepost-up
to add the addresses viaip -6 add
andpre-down
to remove it. -
Markus Zeller almost 3 yearsProps for the
dead:beef
andc0de:d00d
.