How To Add Additional IPv6 Addresses to your Droplet
DigitalOcean now offers IPv6 addresses.
IPv6 is the most recent version of the IP protocol that the entire internet relies on to connect to other locations (IP protocol is a bit redundant because IP stands for internet protocol, but we will use it because it is easy). While IPv4 is still in use in many areas of the world, the IPv4 address space is being consumed at a rapid rate and it is not large enough to sustain the rapid deployment of internet-ready devices.
IPv6 looks to solve these problems. As well as making general improvements on the protocol, the most obvious benefit of utilizing IPv6 addresses is that it has a much larger address space. While IPv4 allowed for 2^32 addresses (with some of those reserved for special purposes), the IPv6 address space allows for 2^128 addresses, which is an incredible increase. To find out how to enable IPv6 on your Droplets follow the linked guide.
In this tutorial, we will discuss how to add additional IPv6 addresses to your Droplets.
Find the IPv6 Address Range for your Droplet
By default, the each Droplet with IPv6 enabled will be configured with a single IPv6 address. This is the address that will be used for any PTR records that will be generated for domains pointing at your server.
However, a broader range of addresses is also available for your Droplet. The available range is given in the networking section of your Droplet's configuration page.
To find this value, click on your Droplet's name in the "Droplets" page of your DigitalOcean control panel:
In the configuration page, click on the "Settings" tab and then select the "Networking" sub-navigation item:
If you have enabled IPv6, you will have a section of that identifies the IPv6 networking details. Among this information, you will have a range of addresses labeled "Configurable address range":
This represents the IPv6 addresses you have available to allocate to your Droplet.
Temporarily Add Additional IPv6 Addresses to your Droplet
The DigitalOcean backend is already set up to serve requests for these addresses to your Droplet. However, you will need to configure the network within the Droplet so that it knows about the additional addresses.
To do so, you need to add each of the addresses that you wish to configure to the Droplet's interface. Log into the Droplet using SSH or the control panel console.
To configure the Droplet's networking interface, select the address you want to configure out of your address range and adding it like this:
ip -6 addr add new_IPv6_address_in_range/64 dev eth0
The new address will immediately be available in your session. You should be able to see it in the list here:
ip -6 addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000 inet6 first_ipv6_address/64 scope global valid_lft forever preferred_lft forever inet6 second_ipv6_address/64 scope global valid_lft forever preferred_lft forever
The new address will be available for the duration of your current session. If you wish to add the additional IP address permanently, you will need to add some information to your configuration files.
Permanently Add Additional IPv6 Addresses in Debian and Ubuntu
On Debian or Ubuntu, you need to add the additional IPv6 addresses to the file that configures your network at boot. The file that is responsible for this is
Open this file with root privileges with your text editor:
sudo nano /etc/network/interfaces
You will find a section in this file for each of the different networks that you have configured. These may be public IPv4, public IPv6, private IPv4, etc. The public IPv6 interface is defined by the section that looks like this:
. . . iface eth0 inet6 static address primary_ipv6_address netmask 64 gateway ipv6_gateway autoconf 0 dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888 22.214.171.124 . . .
We want to add an additional IPv6 address that will be also be available publicly.
To do this, you need to add an additional section that mirrors the specification you currently have. This will only need to include the new address you are adding and a netmask specification:
. . . iface eth0 inet6 static address primary_ipv6_address netmask 64 gateway ipv6_gateway autoconf 0 dns-nameservers 2001:4860:4860::8844 2001:4860:4860::8888 126.96.36.199 iface eth0 inet6 static address new_ipv6_address netmask 64 . . .
Save and close the file when you are finished.
On the next boot, your Droplet will automatically add the additional IPv6 addresses that you configured. If you need the additional addresses to be available now, you can use the temporary method given above.
Permanently Add Additional IPv6 Addresses in CentOS and Fedora
On CentOS or Fedora, a similar configuration change needs to be made. The file that controls the interfaces we are concerned with is
Open this file in your text editor with root privileges:
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
The portion of this file that deals with IPv6 addresses should look something like this:
. . . IPV6INIT=yes IPV6ADDR=primary_ipv6_address/64 IPV6_DEFAULTGW=ipv6_gateway IPV6_AUTOCONF=no . . .
To add additional IPv6 addresses, we will use a parameter called
IPV6ADDR_SECONDARIES. This will be set to a string which defines any other IPv6 addresses that we may want to add.
This will look something like this:
. . . IPV6INIT=yes IPV6ADDR=primary_ipv6_address/64 IPV6_DEFAULTGW=ipv6_gateway IPV6ADDR_SECONDARIES="second_ipv6_address/64 third_ipv6_address/64 .../64" IPV6_AUTOCONF=no . . .
When you are finished adding the additional IPv6 addresses, you can save and close the file.
On the next boot, these addresses will be automatically configured. If you need the additional addresses prior to rebooting, you should follow the directions in the temporary solution as well.
You should now be able to add as many addresses within your Droplet's addressable range as you would like. This can give you flexibility in your configuration and allows you to use different addresses for specific purposes.
You can follow this link to find out more about how to use tools and common applications with IPv6. If you wish to turn IPv4 off completely and only have IPv6 available, you can do so by following our guide on configuring your Droplet to use IPv6 only.
By Justin Ellingwood