3 ms·
I am using digitalocean's dns api for similar needs. setting ext.mac.mydomain.com and int.mac.mydomain.com internal and external addresses from crontab. since
by pvtmert 6y ago
I am using digitalocean's dns api for similar needs.
setting ext.mac.mydomain.com and int.mac.mydomain.com internal and external addresses from crontab.
since i'm using mac, you may need to change ipconfig command to hostname -i/-I)
DO_INT={internal_record_id}
DO_EXT={external_record_id}
DO_BASE=https://api.digitalocean.com/v2/domains/{yourdomain}
DO_TOKEN={your_token}
DO_TYPE=content-type:application/json
*/15 */1 * * * (set -o pipefail; /usr/sbin/ipconfig getifaddr en0 | curl -sX PUT -H "${DO_TYPE}" -H "Authorization: Bearer ${DO_TOKEN}" "${DO_BASE}/records/${DO_INT}" -d "{ \"data\": \"$(cat)\" }" | tee /tmp/ip.int;) &>/dev/null
*/15 */1 * * * (set -o pipefail; curl -sf wtfismyip.com/text | curl -sX PUT -H "${DO_TYPE}" -H "Authorization: Bearer ${DO_TOKEN}" "${DO_BASE}/records/${DO_EXT}" -d "{ \"data\": \"$(cat)\" }" | tee /tmp/ip.ext;) &>/dev/null