Here's a script I'm using to look up DNS and extract the IP address on OpenWRT:

showdns.sh


#!/bin/sh
registered_ip=$(nslookup $domain 2>/dev/null | sed -n 5p | awk '{print $3}')
echo $registered_ip


Include in /usr/lib/ddns/dynamic_dns_updater.sh after installing ddns-scripts