5 ms·
In my case I have a dynamic IP but I use a Linux box as a router and set up Google DNS record sets for my domains and after every reconnect to Internet (or PPP
by lstamour 6y ago
In my case I have a dynamic IP but I use a Linux box as a router and set up Google DNS record sets for my domains and after every reconnect to Internet (or PPP connection in this case), a shell script checks to see if the IP address changed by comparing with a text file, and if it has, it updates the IP address using the gcloud CLI utility.
The DNS timeout is set relatively low, 5 minutes. I used Google Cloud DNS because it’s scalable, cheap (the setup costs under $2/month for low traffic) and has a great API and command line tool. Just took a half day of tinkering to get it all set up and most days I forget it’s there. (I should probably set up monitoring, but it’s fine most days...)
If using CloudFlare, it’s possible you could push your dynamic IP to CF as a DNS host. Haven’t looked into it yet.
And of course there’s the DynDNS approach but most of those approaches seemed more complicated or costly these days. I also use gcloud to update the DNS for LetsEncrypt roughly once a month, so it does double duty. The language for the gcloud DNS CLI tool is a bit technical but try it, test it out, and it’ll start to make more sense by example: https://cloud.google.com/sdk/gcloud/reference/dns https://cloud.google.com/sdk/gcloud/reference/dns
For a bit more security, the apps I’m running are in their own virtual machines and I’ve tried to enable default auto updates everywhere. I keep telling myself I’ll set up something more complicated to create a continuous deployment pipeline with test cases and automatic rollback but I haven’t yet gotten around to it. (Though it would be fun to set up my own virtual PPP server at some point for running test scenarios, etc.)
- xrisk 6y agothere’s ddclient which can handle dynamic DNS updates. also has cloudflare integration.
- ryanmjacobs 6y agoHey that's really cool. On a related note, Cloudflare's API is _really_ simple. Here's a script that I used to run on several machines that would update/insert a DNS record matching hostname->public IP. https://notryan.com/code/net/cloudflare-ddns.js https://notryan.com/code/net/cloudflare-ddns.js
- pvtmert 6y agoI 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
- BenjiWiebe 6y agoJust for those who aren't aware, Hurricane Electric has a good free DNS system at dns.he.net. Also is DDNS compatible.