Configuring a Static IPv6 Address in Linux
Debian Based (Debian & Ubuntu)
Use your favourite text editor to edit the network interfaces file
An example of a IPv6 network configuration would be as follows, ensure to adjust it accordingly (device name and IP address settings)
auto eth0 #Not necessary if this has already been defined for an IPv4 address
iface eth0 inet6 static
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
Multiple IP addresses would have to be added via aliases. (eth0:0, eth0,1 etc.)
Adding IPv6 DNS nameservers is only required if the server does not have any IPv4 connectivity, as AAAA-records (the IPv6 equivalent of a A-record) may also be resolved via IPv4.
Keep in mind most systems are only able to keep track of three DNS servers at the same time, regardless of IPv4/IPv6
RHEL Based (CentOS)
First of all, IPv6 networking has to be enabled in the 'network' file.
Edit this file using your favourite text editor
Make sure to append the following to this file
Now the IPv6 networking has been enabled the IPv6 addresses can be added to the relevant network configuration file.
The following lines would have to be added to the already present file.
Multiple IPv6 addresses may be easily added by defining them as secondaries and adding them to same file.
IPV6_SECONDARIES="2a00:1768:2001:2a00::4 2a00:1768:2001:2a00::5 2a00:1768:2001:2a00::6"
IPv6 DNS servers may be added to the /etc/resolv.conf file. This is only required if the server does not have any IPv4 connectivity, as AAAA-records (the IPv6 equivalent of a A-record) may also be resolved via IPv4.
Simply add the following lines.
Netplan (Ubuntu 17.10+)
Use your favourite text editor the edit the relevant network configuration file.
Assuming you already have a working IPv4 configuration, you may simply add two lines to the existing netplan configuration. These lines being the IPv6 address under 'addresses', and the 'gateway6' line for your IPv6 gateway.
For changes to take effect, the configuration will have to be applied. Appending --debug may help you troubleshoot if you're running into any issues.