Dynamic DNS and IPv6 breaking scripts

Just noting, if you have self-made scripts to perform Dynamic DNS with a Nameserver/Provider of your choosing, the following sequence of events happens:

  • Curl or WGET a page such as https://ifconfig.io/ip to get your external WAN IP.
  • Parse the response (if needed)
  • Shunt it up to the Nameserver with an HTTP Push API Call.

However, if the host which was running this script is suddenly given a full IPv6 stack, this breaks. The external IP address (at least for ifconfig.io) now resolves to your 2a00::** IPv6 address rather than IPv4.

Getting the IPv4 response is still easy with a dual stack. Just add '-4' to the curl command, or similar with other commands. E.g.

curl -4 ifconfig.io/ip

I was wondering for half an hour why my dynamic DNS was failing, and stepping through the script, noticed an error from my Nameserver provider saying I was trying to push an IPv6 address into an IPv4 field. The rest was simple.