How to handle multiple DNS addresses

I rarely create a post, but this time I would like to hear your valued insights.

Background: my ISP gives me 3 DNS addresses, they get stored in the router. My FreeRTOS devices get their DNS addresses from the router, using DHCP. That always worked nice, until today.

Today the first DNS server does not respond. Now I know why it gives me more than one address. The second and third servers work well. But FreeRTOS+TCP doesn’t yet use them though.

Now I want to make sure that up to N DNS-addresses will be stored and used, maybe like this:

BaseType_t xDNSIndex = 0;
uint32_t ulDNSAddresses[ N ];

My question is, how do I determine which DNS to use, i.e. xDNSIndex? Just let it turn around from 0 to N-1? Or change xDNSIndex as soon as a time-out has been reached?

#define ipconfigDNS_USE_CALLBACKS    1

To make it more complicated, there are also asynchronous look-ups: FreeRTOS_gethostbyname_a(). This will install an application hook which will be called as soon as a host-name has been found, or when a time-out has been reached.

Any simple suggestion for this? Thanks

Making assumptions: I imagine the normal process would be to try the first DNS address, then if that times out, move onto the second. A simpler implementation though might be to use each DNS in turn - so remember which index was used last time a lookup was performed, then use the next index the next time a DNS is performed, obviously wrapping back to index 0. That way if one DNS didn’t respond you would time out, try again, and just use the next in the list the next time.