A python script solution to whitelist an IP address in iptables resolved with Mikrotik DDNS service (or any other).
In this example I have whitelisted Mikrotik DDNS IP to allow access to SSH and OpenVPN ports.
The script is scheduled in crontab to run every minute. It will resolve Mikrotik DDNS domain, flush the iptables WHITELIST chain and add the IP address if it changed.