Force linux to assume IPv6 unicast connectivity while assigned only IPv6 unique local addresses

2018-12-26 13:07

Problem

You are using linux with an IPv6 unique local address (ULA) but no IPv6 unicast address assigned to the interface but use them e.g. in a VPN context to provide IPv6 unicast connectivity through NAT. The same interface is also set up as the default route. This causes the default configuration of getaddrinfo(3) with ai_flags set to include AI_ADDRCONFIG to prefer IPv4 because missing IPv6 connectivity is assumed.

Solution

You have two options. The first option is assigning a unicast ipv6 (2000::/3) to the interface. This method is preferred because unicast IPv6 addresses are available in plethora and you do not have to route them if you decide not to (i.e. drop them at the gateway into your network), effectively making them private addresses. Second option: modify /etc/gai.conf to have your fc00:/7 range to be of the same label as ::/0. E.g. label fd12:4567:8901::/48 1. More information can be found in the man page gai.conf(5).