We all have to worry about this one, IPv6 is coming this way, the best thing to do is grab the bull by the horns and get used to this change.
This guide gives a CentOS 5/6 server a static IPv6 address and default gateway using the classic network-scripts files, then shows how to check it and how the same thing is done with NetworkManager on current RHEL, AlmaLinux and Rocky Linux.
Prerequisites
- Root access to the server (log in as root or use su/sudo).
- An IPv6 address with its prefix length (usually /64) and the IPv6 gateway, from your ISP, hosting provider or network team. The examples below use the documentation range
2001:db8::/32; replace it with your real values. - Console access is a good idea, in case a typo takes the interface down while you are connected over SSH.
1) Enable IPv6 networking
let’s get started, open a terminal window, and issue the following command:
vi /etc/sysconfig/network

edit the config file and add the “NETWORKING_IPV6=yes” line to the config file.
This switch turns on IPv6 for the network initscripts as a whole. The line only needs to appear once; the screenshot happens to have it twice, which does no harm.
2) Configure the interface
Save and quit, now edit the next file:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
(or whatever interface you may be using; ip link lists them)
add these 3 lines to the config file:
IPV6INIT=yes
IPV6ADDR=(add your IPv6 Address Here)
IPV6_DEFAULTGW=(add you IPv6 Gateway Here)
For example:
IPV6INIT=yes
IPV6ADDR=2001:db8:10::25/64
IPV6_DEFAULTGW=2001:db8:10::1
- IPV6INIT=yes enables IPv6 on this interface.
- IPV6ADDR is the static address. Include the prefix length.
- IPV6_DEFAULTGW is the IPv6 default route. If the gateway is a link-local address (fe80::…), add the interface name:
IPV6_DEFAULTGW=fe80::1%eth0.
from there do a save+quit
3) Restart networking
restart network connections using the following:
service network restart
from there you are set, you can now use IPv6 for the Internet on CentOS
Verify
ip -6 addr show eth0
ip -6 route show
ping6 -c 4 2001:db8:10::1
ping6 -c 4 ipv6.google.com
You should see your address with scope global, a default via route pointing at your gateway, and replies from both pings. ifconfig eth0 also shows an inet6 addr line on CentOS 6.
Troubleshooting
- No inet6 address at all, not even fe80::: IPv6 is disabled in the kernel. Look for
options ipv6 disable=1orinstall ipv6 /bin/trueunder/etc/modprobe.d/, and fornet.ipv6.conf.all.disable_ipv6 = 1in/etc/sysctl.conf. Remove it and reboot. - Address is there but nothing beyond the gateway answers: check the default route with
ip -6 route, and check the IPv6 firewall. IPv6 has its own rules inip6tables(/etc/sysconfig/ip6tables), separate from iptables, and ICMPv6 must be allowed or neighbor discovery breaks. - Ping by name fails but ping by address works: DNS. Test with
dig AAAA ipv6.google.com. - Duplicate address:
ip -6 addrshowsdadfailedwhen another host already uses the address.
RHEL, AlmaLinux and Rocky 9/10
The ifcfg files and the network service are gone; NetworkManager owns the interfaces and stores profiles in /etc/NetworkManager/system-connections/. Use nmcli instead (the connection name is often the interface name, check with nmcli con show):
nmcli con mod eth0 ipv6.method manual ipv6.addresses 2001:db8:10::25/64 ipv6.gateway 2001:db8:10::1
nmcli con up eth0
ip -6 addr show eth0
Test with ping -6 (or ping6 where it is installed). Remember to allow the services you need in firewalld, which applies its zones to IPv4 and IPv6 alike.
That’s it, your server is now reachable over IPv6. For the IPv4 side of the same files see the related guides below.
Related guides: Configuring Network CentOS 6 | Remove Old eth0 or eth1 from CentOS Linux

1 Comment