[RADIATOR] HTTPClient: prefer IPv6 over IPv4?

Heikki Vatiainen hvn at open.com.au
Tue Aug 23 14:54:08 UTC 2022

On 11.8.2022 17.43, C R wrote:

> I am using AuthBy REST and the REST server resolves to an IPv4 and a
> IPv6 address. Our infra is IPv6 first, so I would like to connect
> through IPv6. However, Radiator prefers the IPv4 address consistently,
> probably because it's returned first.

Currently preference for IPv4, when resolving names, is done by 
Radiator. If a hostname doesn't start with ipv6: prefix, it resolves 
with functions that support only IPv4. This is documented in the 
reference manual under IPv6 support.

However, as you noted earlier on this list, it doesn't work well with 
URL syntax because the hostname is embedded within the URL string.

> I used this in <AuthBy REST> to force IPv6:
> LocalAddress %{GlobalVar:IP}
> LocalPort 18120
> With these results:
> 2022-08-11T16:25:59+02:00: 00000000: HTTPClientConnection
> 'resolvabledomain.fqdn-443' Stream attempting tcp connection to
> resolvabledomain.fqdn ( port 443)
> 2022-08-11T16:25:59+02:00: 00000000: HTTPClientConnection
> 'resolvabledomain.fqdn-443' Stream attempting to use local port 18120,
> local address 2a02:2c40:0:451:70:242:ac11:3
> It looks like it does not work because the hostname is resolved before
> the local address is set. Is there a workaround for this?

At the moment it resolves the both (destination address and local 
address) independently and in this order. In other words, you can't use 
local address to direct name resolution to choose IPv6 address as the 
destination adress.

It might be better, as opposed to using LocalAddress to direct IPv4 vs 
IPv6, to add hinting to AuthBy REST (and HTTP client class in general). 
This could tell to choose IPv4, IPv6 or let getaddrinfo() + 
/etc/gai.conf to decide the preference.


Heikki Vatiainen
OSC, makers of Radiator
Visit radiatorsoftware.com for Radiator AAA server software

More information about the radiator mailing list