Replace all IP addresses of A record in all domains within the account

Hello everyone and have a nice day!
Gentlemen, how to massively change all IP addresses of all type A records in all domains within an account?

Change IP addresses in all sites - this topic offers a script that replaces the IP address of records of type A only within one zone_id, within one domain.
But what if I have 100+ domains on my account and all of them have the same IP address of the A record, which needs to be replaced with another one in all domains?

You can just add another loop to go through all zones in your account.

To solve my question, it was enough to “glue” two scripts:

  1. replacement of IP addresses for all records of type A within one zone_id: Change IP addresses in all sites
  2. view all zone_id in the account we need How to get zone id for all domains - #3 by gnirola

And as result is a working script:

auth_email="[email protected]"

zone_id_list=( $(curl -s -X GET "" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json"| jq -r '.result[].id') )

for zone_id in "${zone_id_list[@]}"
 record_list=( $(curl -s -X GET "${zone_id}/dns_records?per_page=500&type=A&content=" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" | jq -r '.result[].id') )

 for id in "${record_list[@]}"
  curl -s -X PATCH "${zone_id}/dns_records/${id}" -H "X-Auth-Email: $auth_email" -H "X-Auth-Key: $auth_key" -H "Content-Type: application/json" --data '{"content":""}'

Tested and works on fedora-33/centOS. With a high degree of probability, it will be necessary to deliver the package:

sudo dnf install jq -y

and :man_dancing: