IPv6 with gateway in a different subnet

I’ve run across this peculiar problem. I was trying to set up IPv6 on a Centos 6 machine. I thought that it would be a simple task – a couple of minutes at most – as I had done that on other Centos 6 machines before. But I was wrong.

My initial configuration steps were:

# cat /etc/sysconfig/network | grep IPV6
NETWORKING_IPV6=yes
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
...
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
NAME="System eth0"
IPV6ADDR=2a01:xxxx:xxxx:xxxx::1/64
IPV6_DEFAULTGW=2a01:xxxx:xxxx:yyyy::1

Take note of the two (obfuscated) IP addresses, the machine IP address 2a01:xxxx:xxxx:xxxx::1 is in a different subnet than the IP address 2a01:xxxx:xxxx:yyyy::1 of the default gateway given to me by the ISP.

On other machines I had configured in the past, IPV6_DEFAULTGW was 2a01:xxxx:xxxx::1, in other words – my own machine’s IP address 2a01:xxxx:xxxx:xxxx::1 was in a subnet that was a part of the bigger 2a01:xxxx:xxxx:: subnet in which the ISP’s gateway machine was located. In those cases, IPv6 worked without any problems when I used the above mentioned simple configuration. But here, it didn’t work, I was getting the following warning and wasn’t able to connect/ping anywhere:

WARN : [ipv6_add_route] 'No route to host' adding route '::/0' via gateway '2a01:xxxx:xxxx:yyyy::1'

I tried specifying the interface, like this:

IPV6_DEFAULTGW=2a01:xxxx:xxxx:yyyy::1%eth0

but that didn’t help either.

Eventually, I got an advice from a friend who’s far more IPv6 savvy than I am. I had thought that it was not possible to have default gateway in a completely different subnet and that this was the reason why I was running into this problem, but I was told that IPv6, unlike IPv4, did actually allow for a gateway to be in a different subnet, but in those cases, addtional network script has to be configured like this:

# cat /etc/sysconfig/network-scripts/route6-eth0 
2a01:xxxx:xxxx:yyyy::1 dev eth0
default via 2a01:xxxx:xxxx:yyyy::1

Having set the gateway this way, I had to remove it from the interface configuration file, of course:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
...
IPV6ADDR=2a01:xxxx:xxxx:xxxx::1/64
#IPV6_DEFAULTGW=2a01:xxxx:xxxx:yyyy::1

After restarting network, this machine was finally IPv6 ready.

Tagged with: ,