Skip to content

Instantly share code, notes, and snippets.

@mariow
Created March 16, 2017 13:36
Show Gist options
  • Save mariow/f6afbd8c6eb689ce839a997f44b6b3eb to your computer and use it in GitHub Desktop.
Save mariow/f6afbd8c6eb689ce839a997f44b6b3eb to your computer and use it in GitHub Desktop.
In case you ever have the need to delete all zones from your account at NS1.net via a script: this will do the job.
#!/bin/bash
#
# WARNING: This script will delete all zones from an account at nsone.net via the API, USE WITH CARE
#
NSONEKEY="YOURKEYHERE"
curl -X GET -H "X-NSONE-Key: $NSONEKEY" https://api.nsone.net/v1/zones > zones.json
perl -ane 'while (/zone":"([^"]+?)"/g) { print $1."\n" }' < zones.json > zones-left.txt
wc -l zones-left.txt
for i in `cat zones-left.txt `;do curl -X DELETE -H "X-NSONE-Key: $NSONEKEY" https://api.nsone.net/v1/zones/$i; sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment