Resolve DNS on R410M

Hi!

I was wondering how I can create a TCP call on a Sodaq R410M to a server without configuring the remote IPv4 address.

When I enter the IP in AT+USOCO it works fine. The data is transferred succesfully.
However, I want to use a DNS A-record to resolve the domain to the right IP, in case it switches (before I have to upload the new config to all devices).

What is the best way to resolve this issue? I’ve tried the following, but it didn’t work: I have entered a fallback IP, but want to use the IP that is entered in the DNS settings if available.

MODEM_STREAM.println("AT+UDNSRN=0,\"sample-domain.com\"");
String remote_ip = "199.199.199.199";
String response = MODEM_STREAM.readString();
if(response.startsWith("+UDNSRN:") && response.length() > 9) {
String remote_ip = response.substring(9);
}

write("AT+USOCO=0,\"" + remote_ip + "\",9999");

The idea is to resolve the IP (which works, because it then returns "+UDNSRN: “199.199.199.199"”), and use the hardcoded IP as a fallback. I’ve stripped the first 9 characters, because the +UDN… is in the response as well.

What is the best way to accomplish this? Thanks in advance!