Dynamic DNS with CloudFlare
-
This post is deleted! -
@NashBrydges I would have bet money that the
$recordID
was just the short name of the record (ie. "sub" of "sub.example.com"). I swear I did it like that and it worked, but apparently not :flushed_face:.The script to get the real identifier is above.
-
@bnrstnr said in Dynamic DNS with CloudFlare:
@NashBrydges I would have bet money that the
$recordID
was just the short name of the record (ie. "sub" of "sub.example.com"). I swear I did it like that and it worked, but apparently not :flushed_face:.The script to get the real identifier is above.
Thanks. I'll give that a try later.
-
@nashbrydges said in Dynamic DNS with CloudFlare:
Interesting feature with Cloudflare that I just discovered is that they flatten a CNAME record to the root of the domain. So I can enter my DDNS domain as a CNAME record. It will query the IP of that domain and return the IP address to use for the root domain. So this script isn't really needed since it will do the lookup for you.
Ya I don’t have a DDNS name so that’s why I Serb it up this way.
-
Very useful. bookmarking this!
-
I've confirmed that Cloudflare's CNAME flattening feature works exactly as advertised.
Create a CNAME record with following values:
- Type = CNAME
- Name = Your root mydomain.com domain name
- Domain Name = Your DDNS domain subdomain.ddns.net (I use No-IP for example but change yours as needed)
I then created another CNAME record to handle the www subdomain and everything works as expected. Both root domain name and www route correctly.
-
@nashbrydges I thought somebody already said this, but I cant find it. The only bad part about the CNAME method if you're using a free account on no-ip, then you have to login to their site and confirm that you're still using the DDNS every 30 days, which is a PITA. Setup the script with a cron job and never have to worry about checking in on no-ip or afraid.org every n days.
-
@stacksofplates said in Dynamic DNS with CloudFlare:
ip=$(curl http://icanhazip.com)
While I was looking into the Cloudflare API a little further yesterday, I came across this. I don't know much about it, but here it is.
Consider replacing
curl -s http://icanhazip.com
withdig +short myip.opendns.com @resolver1.opendns.com
. It works exactly the same.Querying icanhazip.com or other similar sites requires a fairly expensive TCP connection, HTTP overhead, etc. This can be burdensome when queried regularly via cron jobs. A UDP-based DNS connection is considerably faster, lighter weight, and uses far less resources.
-
@bnrstnr said in Dynamic DNS with CloudFlare:
@nashbrydges I thought somebody already said this, but I cant find it. The only bad part about the CNAME method if you're using a free account on no-ip, then you have to login to their site and confirm that you're still using the DDNS every 30 days, which is a PITA. Setup the script with a cron job and never have to worry about checking in on no-ip or afraid.org every n days.
That's correct, if you have the free account with No-IP you have to reconfirm every 30 days. I have the paid account so that's not a problem. It doesn't expire.
-
@bnrstnr said in Dynamic DNS with CloudFlare:
@nashbrydges I thought somebody already said this, but I cant find it. The only bad part about the CNAME method if you're using a free account on no-ip, then you have to login to their site and confirm that you're still using the DDNS every 30 days, which is a PITA. Setup the script with a cron job and never have to worry about checking in on no-ip or afraid.org every n days.
afraid.org does require reauth but like every 6 months or so.
-
To each their own... I'll opt for the free, never reauth, option for 3 minutes of setup.
-
@nashbrydges said in Dynamic DNS with CloudFlare:
@bnrstnr said in Dynamic DNS with CloudFlare:
@nashbrydges I thought somebody already said this, but I cant find it. The only bad part about the CNAME method if you're using a free account on no-ip, then you have to login to their site and confirm that you're still using the DDNS every 30 days, which is a PITA. Setup the script with a cron job and never have to worry about checking in on no-ip or afraid.org every n days.
That's correct, if you have the free account with No-IP you have to reconfirm every 30 days. I have the paid account so that's not a problem. It doesn't expire.
Ya this is why I set this up. I’m cheap and I was tired of reauth with no-ip.
-
Edgerouters can now handle custom dynamic dns providers without the need of the script - here is the guide with Cloudflare as the example: https://help.ubnt.com/hc/en-us/articles/204976324