Last active
February 22, 2023 22:03
-
-
Save gentam/874852602e0380af4c2a4eb1f3dc68cc to your computer and use it in GitHub Desktop.
iwantmyname DNS API wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## iwantmyname DNS API wrapper | |
## see <https://iwantmyname.com/developer/domain-dns-api> | |
usage() { | |
echo "Usage: `basename $0` <RECORD_TYPE> <HOSTNAME> <RECORD_VALUE> | |
RECORD_TYPE := A|AAAA|TXT|MX|CNAME|NAPTR|SRV | |
e.g. `basename $0` A blog.example.com 123.456.78.90 | |
`basename $0` CNAME www.example.com example.com | |
`basename $0` TXT _acme-challenge.example.com DmCKygRUkCIApIfHtpELeHy3f5JXcm_WNQccuADh1Do" | |
} | |
[ $# -ne 3 ] && usage && exit 1 | |
read -p 'Email: ' USER | |
read -p 'Password: ' -s PASS | |
echo | |
TYPE="$1" | |
HOSTNAME="$2" | |
VAL="$3" | |
case $TYPE in | |
a|aaaa|A|AAAA) | |
curl -u "$USER:$PASS" "https://iwantmyname.com/basicauth/ddns?hostname=$HOSTNAME&myip=$VAL" | |
;; | |
txt|mx|cname|naptr|srv|TXT|MX|CNAME|NAPTR|SRV) | |
curl -u "$USER:$PASS" "https://iwantmyname.com/basicauth/ddns?hostname=$HOSTNAME&type=$TYPE&value=$VAL" | |
;; | |
*) | |
echo "Invalid record type: $1" | |
usage | |
exit 1;; | |
esac | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment