[CentOS/Linux] WARN : [ipv6_add_route] ‘No route to host’ adding route ‘::/0’ via gateway ‘XXXX:YYYY:ZZZZ::1’ through device ”

When trying to add an IPv6 address to a server via the ifcfg-eth0 file resulted in the following error (redacted) upon restarting networking:

RTNETLINK answers: Permission denied

WARN     : [ipv6_add_route] ‘No route to host’ adding route ‘::/0’ via gateway ‘XXXX:YYYY:ZZZZ::1’ through device ”

This was further confirmed by trying to add the IP manually:

# ip -6 addr add XXXX:YYYY:ZZZZ:10::/48 dev eth0

RTNETLINK answers: Permission denied

This is from IPv6 being disabled on the interface.  Multiple solutions can make fix this permanently but here’s what I used:

1. Change the following line in /etc/sysctl.conf from

net.ipv6.conf.eth0.disable_ipv6 = 1

to

net.ipv6.conf.eth0.disable_ipv6 = 0

In this case it was disabled on the interface but it can also be set defaultly with:

net.ipv6.conf.default.disable_ipv6 = 0

2. Change the current setting:

echo 0 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6

echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6