How to configure IPv6 on CentOS
First, open the network configuration file using your favorite text editor. For example, you can use the nano text editor to open the file by running the following command:
$ sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
Add the following lines to the file, replacing IPv6_ADDRESS with the static IPv6 address you want to use, PREFIX with the prefix length of your IPv6 address, and IPv6_GATEWAY with the static IPv6 gateway address:
IPV6INIT=yes
IPV6ADDR=IPv6_ADDRESS/PREFIX
IPV6_AUTOCONF=no
IPV6_DEFAULTGW=IPv6_GATEWAY
Save the file and exit the text editor.
Restart the network service by running the following command:
$ sudo systemctl restart network
To verify that the static IPv6 address and gateway have been successfully configured, run the ip addr and ip route commands and look for the IPv6 address and gateway in the output.
Here is an example of what the output of the ip addr command might look like:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.100/24 brd 192.168.0.255 scope global dynamic noprefixroute eth0
valid_lft 85893sec preferred_lft 85893sec
inet6 2001:db8:1234:5678::/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::211:22ff:fe33:4455/64 scope link
valid_lft forever preferred_lft forever
In this example, the static IPv6 address 2001:db8:1234:5678::/64 is configured on the eth0 interface.
Here is an example of what the output of the ip route command might look like:
default via 192.168.0.1 dev eth0 proto dhcp
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.100
2001:db8:1234:5678::/64 dev eth0 proto kernel metric 256
In this example, the static IPv6 gateway 2001:db8:1234:5678::/64 is configured on the eth0 interface.