Adding IPV6 on CentOS
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
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
restart the system.
service network restart
If your network interface isn't ens3, you can find it by checking,
ifconfig
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="IPv6_RANGE/NETMASK"
IPV6ADDR_SECONDARIES="IPv6_ADDRESS/NETMASK"
Information for the IPv6_RANGE/NETMASK can be found from CrownPanel.
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.