Recommended VPS Complete list of best VPS hosting providers.

How to Configure IPv6 on Ubuntu and CentOS

IPv6 Configuration Wallpaper

When we purchase a virtual machine (VM) or virtual private server (VPS) from a provider, there are times whereby we have to configure the IPv6 address manually on the server. This may be due to the fact that IPv6 is not enabled by default on the server, even if the provider already supports it on the network level. Your provider might be giving you a static IPv6 address for you to configure manually on the server.

Below article contains step-by-step instructions on how to set up a static IPv6 address on servers running Ubuntu and CentOS operating systems. The command examples here were done on Ubuntu and CentOS virtual machines hosted in SimplerCloud. Since a root account was used, the sudo command was omitted on most of the steps. If you are using a non-root user with sudo access on an Ubuntu environment, please append sudo in front of each command (e.g. sudo ifconfig -a instead of ifconfig -a).

What We Need To Prepare

We need to get a static IPv6 address to be assigned to our server. This assignment is normally done by the service provider. Similar to IPv4, the information required for IPv6 settings consists of the IPv6 address itself, the subnet mask (for example, /64) and the default gateway. Note that your provider might be assigning a whole /64 subnet to you, if that’s the case, you can just select one IPv6 address within the /64 subnet to be used for your server.

On below examples, we will use below IPv6 addresses to be configured on the servers.

For the Ubuntu test server :

IPv6 address: 2400:c980:0000:0002::180
Subnet mask: /64
Default gateway: 2400:c980:0000:0002::1

For the CentOS test server :

IPv6 address: 2400:c980:0000:0002::190
Subnet mask: /64
Default gateway: 2400:c980:0000:0002::1

Configure IPv6 on Ubuntu

To configure static IPv6 address on a server or virtual machine running Ubuntu Linux operating system, we need to login to the server using SSH as root. The file that we need to modify is “/etc/network/interfaces”.

Firstly, let us make a backup copy of the “/etc/network/interfaces” file first by issuing this command :

cp /etc/network/interfaces /etc/network/interfaces.bak

001-CopyInterfacesFile

We can verify that the file has been backed up by going to the /etc/network folder and then type "ls -la".

002-CheckIfBackupCreated

We can then open the /etc/network/interfaces file using our favourite text editor, either “nano” or “vi”. For most users, using the “nano” text editor would be much easier.

nano /etc/network/interfaces

Below is the typical content of /etc/network/interfaces on an Ubuntu server, depending on the current network setup of the server. As you might have noticed, only IPv4 is being configured there, while the IPv6 is not yet configured

003-EtcNetworkInterfacesBefore

What we can do is to add below lines at the end of the file

# IPv6 for eth0
iface eth0 inet6 static
pre-up modprobe ipv6
address 2400:c980:0000:0002::180
netmask 64
gateway 2400:c980:0000:0002::1

004-EtcNetworkInterfacesAfter

Kindly noted that 2400:c980:0000:0002::180 is the static IPv6 address that we want to configure on the server.

Save the file. If you are using nano, press “Ctrl-X” to exit, and then press “Y” to save the changes.

005-SaveTheChanges

For Ubuntu 12.04, you can issue below command to activate the changes:

/etc/init.d/networking restart

006-NetworkingRestart

For Ubuntu 14.04, you would need to restart your server for the changes to take effect.

You can then verify if the correct IPv6 address has been installed on your server by issuing below command:

ifconfig eth0

007-IfconfigResult

inet6 addr: 2400:c980:0:2::180/64 Scope:Global

and verify that the correct IPv6 address is being shown.

Configure IPv6 on CentOS

To configure static IPv6 address on a server or virtual machine running CentOS Linux operating system, we need to login to the server using SSH as root. There are two files that we need to modify:

  1. /etc/sysconfig/network: Turn on IPv6 networking and disable IPv6 auto-configuration.
  2. /etc/sysconfig/network-scripts/ifcfg-eth0: Set static IPv6 address and the default gateway.

First, let us make a backup copy of the files first.

cp /etc/sysconfig/network /etc/sysconfig/network.bak
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak

008-BackupFiles

After which, we can use our favourite text editor (e.g. “nano”) to modify the /etc/sysconfig/network file.

nano /etc/sysconfig/network

009-EditEtcSysconfigNetworkFile

Default configuration would be like this :

NETWORKING=yes
HOSTNAME=your.server.hostname

010-DefaultEtcSysconfigNetworkFile

Add these following lines after the second line:

NETWORKING_IPV6=yes IPV6_AUTOCONF=no

So it will become like this:

NETWORKING=yes
NETWORKING_IPV6=yes
IPV6_AUTOCONF=no
HOSTNAME=your.server.hostname

011-EtcSysconfigNetworkFileAfterChange

Open the /etc/sysconfig/network-scripts/ifcfg-eth0 file using your favourite text editor (e.g. nano):

nano /etc/sysconfig/network-scripts/ifcfg-eth0

The typical normal network configuration would usually be as per below screenshot:

012-Ifcfg-Eth0

The typical normal network configuration would usually be as per below screenshot:

IPV6ADDR=2400:c980:0000:0002::190
IPV6_DEFAULTGW=2400:c980:0000:0002::1

Note that 2400:c980:0000:0002::190 is the static IPv6 address which we have assigned to the server.

The whole file after the changes should be similar to this:

013-Ifcfg-Eth0-After

Save the file, and then issue below command to make the changes to take effect:

service network restart

014-ServiceNetworkRestart

We can then verify if the correct IPv6 address has been installed on the server by issuing below command:

ifconfig eth0

015-IfconfigEth0

Note the line:

inet6 addr: 2400:c980:0:2::190/64 Scope:Global

and verify that the correct IPv6 address is being shown.

Verify the IPv6 Connectivity

To verify that you have IPv6 connectivity and your static IPv6 address is working, you can perform some ping and traceroute tests to some IPv6-enabled sites. In Linux operating systems, take note to use “ping6” and “traceroute6” commands for IPv6 network, as opposed to the normal “ping” and “traceroute” commands for IPv4 network.

ping6 google.com
traceroute6 google.com

016-Ping6Traceroute6Results

That’s it and enjoy.

Disclaimer : This is another great guest post article by Indra Pramana from SimplerCloud.com, a cloud servers provider from Singapore with solutions built from the ground up to provide truly real-time, scalable and easily managed cloud infrastructure for start-ups, developers and business throughout Asia.

Add a Comment

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

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.