Adding IPV6 on CentOS

Before we head out to configuring, we need to know what interface the server is using.

Find the active network interface name

First check ifconfig (or IP address) for the "active" network interface,

ifconfig

You'll then find output similar to the following,

[root@vps ~]# ifconfig
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.2  netmask 255.255.255.0  broadcast 1.1.1.1

        inet6 fe80::5652:ff:fe85:9369  prefixlen 64  scopeid 0x20<link>

        ether 54:52:00:85:93:69  txqueuelen 1000  (Ethernet)
        RX packets 28466  bytes 1720640 (1.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 186  bytes 18087 (17.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 176  bytes 14168 (13.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 176  bytes 14168 (13.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

To Find Network details,

To find out the IPv6 Address assigned to you, login to CrownPanel and navigate to Manage Network tab.
For instruction Click here

You will find an IPv6 address similar to 2a0a:51c0:0:1f:4996::/80. If you do not find your IPv6 allocation, please open a Support Ticket.

Configuring the IPv6 Gateway

Next, add the Gateway (can be found from CrownPanel) into /etc/sysconfig/network

nano /etc/sysconfig/network

and then add the following into it,

IPV6INIT=yes
IPV6_DEFAULTGW="GATEWAY"

Replace "GATEWAY" with the actual IPv6 Network Gateway, Information for the GATEWAY can be found from CrownPanel.

Also, If you see the following line in the same file (/etc/sysconfig/network)

NETWORKING_IPV6=no

Change it to,

NETWORKING_IPV6=yes

Save the file and then,

systemctl restart network

To restart the network with the latest configuration changes

Configure the IPv6 Address

In the above output, ens3 is the active network interface, so we use this when building our configuration

Edit the network interface file config file, for example, our NETWORK_INTERFACE is ens3

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

Add the following IPv6 details [update with your network details]

Replace actual value for IPv6_Address and IPv6_Gateway.

IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6ADDR=IPv6_Address
IPV6_DEFAULTGW=IPv6_Gateway

Example,

IPV6INIT="yes"
IPV6_AUTOCONF="no"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6ADDR=2a0a:51c0:0:1f:4996::1
IPV6_DEFAULTGW=2a0a:51c0:0:1f::1

restart the system.

service network restart 

Let's see if we can now Ping google's IPv6,

[root@vps ~]# ping6 -c3 ipv6.google.com
PING ipv6.google.com(fra16s50-in-x0e.1e100.net (2a00:1450:4001:810::200e)) 56 data bytes
64 bytes from fra16s50-in-x0e.1e100.net (2a00:1450:4001:810::200e): icmp_seq=1 ttl=119 time=1.13 ms
64 bytes from fra16s50-in-x0e.1e100.net (2a00:1450:4001:810::200e): icmp_seq=2 ttl=119 time=1.30 ms
64 bytes from fra16s50-in-x0e.1e100.net (2a00:1450:4001:810::200e): icmp_seq=3 ttl=119 time=1.20 ms

--- ipv6.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.134/1.213/1.303/0.074 ms
[root@vps ~]#

Configuring Multiple IPv6 addresses from the same Range

Editing that config file, replacing NETWORK_INTERFACE with the correct network interface,

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

And then add the following to the end of the file,

IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
IPV6ADDR="First_IPV6_ADDRESS"
IPV6ADDR_SECONDARIES="SECOND_IPV6_ADDRESS THIRD_IPV6_ADDRESS"
IPV6_DEFAULTGW=IPv6_Gateway

Example,

IPV6INIT="yes"
IPV6_AUTOCONF="no"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
IPV6ADDR=2a0a:51c0:0:1f:4996::1
IPV6ADDR_SECONDARIES="2a0a:51c0:0:1f:4996::3 2a0a:51c0:0:1f:4996::2 2a0a:51c0:0:1f:4996::4"
IPV6_DEFAULTGW=2a0a:51c0:0:1f::1

And for the IPv6_ADDRESS/NETMASK replace it with generated IPv6 with its netmask.

Note: IPv6 addresses are separated with white space.

Save the file and then,

systemctl restart network

Configuring DNS For IPv6

Last but not least, update the DNS Servers for IPv6 as well in your /etc/resolv.conf

nano /etc/resolv.conf

and then add the following into it,

nameserver 8.8.8.8
nameserver 2001:4860:4860::8888

This will add 1 IPv4 DNS Nameserver and 1 IPv6 DNS Nameserver into your service which should ensure both IPv6 domain resolution and IPv4 domain resolution working perfectly.