Categories
Technical

Using multiple IPv6 addresses on a single interface

I know very little about networking and IPv4 addresses… and even less about IPv6. A while ago I managed to set up this server to support my three IPv4 addresses over the one interface – very useful for websites with multiple/dynamic domain names when you manually edit apache virtualhost config files.

As a point of reference, my network interfaces file looks like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 175.107.146.57
netmask 255.255.255.248
network 175.107.146.56
broadcast 175.107.146.63
gateway 175.107.146.62
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 203.88.112.33 203.88.112.37
dns-search valorin.net

auto eth0:1
iface eth0:1 inet static
address 175.107.146.58
netmask 255.255.255.248

auto eth0:2
iface eth0:2 inet static
address 175.107.146.59
netmask 255.255.255.248

I knew it worked, but didn’t really understand the theory behind it. With this server I was also issued an IPv6 address block to use as I please. From the ifconfig command I knew it was working as set to: 2405:5000:2:22c:250:56ff:fe9a:a0/64. But how do I enable multiple addresses?

It turns out the solution is very simple. Simply set the IPv6 addresses required as static interfaces, in the same way that the IPv4 addresses are done.

My new interfaces config looks like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# IPv4
auto eth0
iface eth0 inet static
address 175.107.146.57
netmask 255.255.255.248
network 175.107.146.56
broadcast 175.107.146.63
gateway 175.107.146.62
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 203.88.112.33 203.88.112.37
dns-search valorin.net

iface eth0 inet6 static
address 2405:5000:2:22c:250:56ff:fe9a:a0
netmask 64

auto eth0:1
iface eth0:1 inet static
address 175.107.146.58
netmask 255.255.255.248

iface eth0:1 inet6 static
address 2405:5000:2:22c::1
netmask 64

auto eth0:2
iface eth0:2 inet static
address 175.107.146.59
netmask 255.255.255.248

Anyone who understands the theory behind this is probably going: well that was obvious, why are you writing about this? But I figure there are other people out there who also don’t know how to do it. If that is you, I hope this post helps you get it working 🙂

Leave a Reply

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