Since I already had a self-deployed dyndns server for personal use I decided to get a cert for my home server (which is behind NAT, standard ports are not forwarded). So, I’ve written a small script to “reach out” to my DNS server and update the challenge. Find it below:
#!/bin/bash
DYNZONE="dyn.mydomain.com"
if [ -z "$CERTBOT_DOMAIN" ] || [ -z "$CERTBOT_VALIDATION" ]
then
echo "EMPTY DOMAIN OR VALIDATION"
exit -1
fi
HOST="_acme-challenge"
/usr/bin/nsupdate -k /root/scripts/Kdyn.mydomain.com.+xxx+yyyyy.private << EOM
zone ${DYNZONE}
update delete ${HOST}.${CERTBOT_DOMAIN} A
update add ${HOST}.${CERTBOT_DOMAIN} 300 TXT "${CERTBOT_VALIDATION}"
send
EOM
echo ""
Simply works by calling " certbot certonly --agree-tos --manual --preferred-challenges=dns --manual-auth-hook /root/scripts/certbot-dns-auth.sh -d home.dyn.mydomain.com"
(don’t forget to copy both key/private file to server with the update key added to BIND zone)