Binding multiple IPv6 addresses automatically

Most servers get a IPv6 range (/64) by default. That means that you have millions of IP addresses to use for whatever you feel like. However, assigning them manually to your interfaces can be a bit painful.

Assigning all /64 IPv6 addresses with 1 command

However, there is a trick with the ip route command that allows you to link your /64 to the local interface and cover all of them automatically:

ip route add local IPV6RANGE::/64 dev lo

You just have to substitute IPV6RANGE for the address you got. Let’s say you received a 2a0d:xxxx:yyyy:zzzz::/64, that’s how you would do it:

ip route add local 2a0d:xxxx:yyyy:zzzz::/64 dev lo

And than you are able to ping all addresses within that range:

ping6 2a0d:xxxx:yyyy:zzzz:ffff:ffff:ffff:ffff
PING 2a0d:xxxx:yyyy:zzzz:ffff:ffff:ffff:ffff(2a0d:xxxx:yyyy:zzzz:ffff:ffff:ffff:ffff) 56 data bytes
64 bytes from 2a0d:xxxx:yyyy:zzzz:ffff:ffff:ffff:ffff: icmp_seq=1 ttl=64 time=0.076 ms
..

That saves you a lot of time and gives you millions of addresses to use.

Sharing is caring!

Leave a Reply

Your email address will not be published. Required fields are marked *