Adding IPV6 on CentOS

Find the active network interface name

First check ifconfig (or ip addr) 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

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

File Should contains. [update with your network details]

DEVICE="eth0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
UUID="6cb644dd-f731-4b74-9e51-735e6bfdac9f"
ARPCHECK="no"
IPV6_DEFAULTDEV="eth0"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
GATEWAY="GATEWAY"
IPADDR="IP-ADDRESS"
NETMASK="NETMASK"
IPV6INIT="yes"
IPV6ADDR="IPV6ADDRESS/NETMASK"
IPV6_AUTOCONF=yes
NM_CONTROLLED="no"

restart the system.

service network restart 

If your network interface isn't ens3, you can find it by checking,

ifconfig

Configuring the IPv6 Range

and then editing that config, 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
IPV6ADDR="IPv6_RANGE/NETMASK"
IPV6_AUTOCONF=yes
NM_CONTROLLED="no"

Information for the IPv6_RANGE/NETMASK can be found from CrownPanel.

Save the file and then,

systemctl restart network

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

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 perfect.