I’ve been using GoDaddy for a few years. I have a few domains with them. Eventually I ran into a few snags that lead me to switch to Cloudflare. In this article I’m going to go over why I switched, and a brief overview of the more challenging aspects of setting up Dynamic DNS.
TL:DR Cloudflare wins due to:
- Supports root domain CNAME records.
- Cheaper domain renewal costs.
- Both Godaddy and Cloudflare support DDNS. You don’t need DuckDNS.
Dynamic IPs & Dyanmic DNS (DDNS)
I host my website on a server whose public IP changes from time to time. I don’t have control over when it’s public IP is changed, nor am I notified when it happens. There are a few reasons why this may be the case for you. If you host your site on a server in your home, your ISP might change your IP. If you host your site on a server with one of the major cloud providers, maybe you can’t afford to pay for a static IP.
When I first set up my website, the solution I came across for dynamic dns was Duck DNS. Duck DNS is a free service that allows you to set up one or more subdomains on the duckdns.org
domain, and configure that subdomain to resolve to the IP of your choosing. They provide a shell script that ensures your subdomain will stay up to date with your latest IP.
This works just fine, unless you want to use your root domain. More on that below.
Limitations of DuckDNS + GoDaddy
On my first domain, all of my services were reachable via subdomains. I didn’t need my root domain to resolve to anything. My networking looked something like this:
myapp.mydomain.com <-- GoDaddy
|
V
myapp.duckdns.com <-- DuckDNS
|
V
SERVER_PUBLIC_IP <-- My Server
|
V
REVERSE_PROXY <-- Traefik via Docker
|
V
SERVICE_IP <-- Docker Container
When configuring your domain, you can use A records to point your subdomains to IPs, but if you want to point one domain to another, you have to use a CNAME. Unforunately, CNAME’s were not designed to be placed on the root domain.
Works:
CNAME myapp.mydomain.com -> myapp.duckdns.com
A root domain to another domain’s subdomain doesn’t work:
CNAME mydomain.com -> myapp.duckdns.com
Root to root doesn’t work:
CNAME mydomain.com -> myotherdomain.com
If you’re curious as to why CNAME’s behave this way, you can get started here. That StackOverflow post mentions an RFC that outlines why CNAME’s aren’t intended to be placed on the root domain.
I wanted my blog to be accessible on https://patrickmotard.com. Due to CNAME limitations, I had to use a subdomain. I chose https://www.patrickmotard.com. I suppose I could have used https://blog.patrickmotard.com. Regardless, my root domain was unusable. I had to leave it parked because I couldn’t point it to DuckDNS.
While I was googling around for a solution, I came across a post that said Cloudflare supported using root domains via CNAMEs. They aren’t following the spec for CNAMEs but they provide it anyways as a convenience. Cloudflare has been on my list of things to look into for some time now, and I kept putting it off. Godaddy did what I needed to do for the most part. I wasn’t happy with my blog / root domain issue though. I need to fix that if I’m going to write more articles and share articles with others.
Moving my domain to Cloudflare
Jon, AKA Wiyre, has an excellent YouTube video covering how you can move your domain(s) from Godaddy to Cloudflare. I was able to follow it verbatim. In it he covers step by step how to transfer. He does a great job of covering how to get through all the questionable decisions Godaddy has made to make it as difficult as possible to transfer your services away from them. Luckily it’s not as difficult as cancelling a Planet Fitness membership.
The best part about Cloudflare, for me, is the cost. Godaddy has cheap name registration. Where they get you is on domain renewals. My initial domain was only $5
. A year later, upon renewal, it was $35
. They’ve done this with both of my domains. Cloudflare on the other hand promises to charge the same upon renewal that they charged for the original domain.
DDNS on Cloudflare via ddclient
Once I switched over to Cloudflare I configured my root domain to bypass DuckDNS and point directly to my servers IP. I then started looking into DDNS options. Turns out both Godaddy and Cloudflare support DDNS. Both services provide APIs that can be used to programatically update the IPs on your domain configuration.
I’ve not personally set up DDNS on Godaddy but you can probably get started with this article. There are open source solutions that could be hosted via docker to do this.
If you’re looking to configure DDNS on Cloudflare, I’ve taken some notes here to help get you started. Maybe you’ll be able to get it going faster than I did. There are many open source projects you can use. I chose to use ddclient. Ddclient is one of the more popular and long-standing options out there. Normally I try to avoid services that are written in Perl, but this service looks well supported.
On my server I run Docker swarm mode, so containers are deployed as stacks and services. Here’s an excerpt from my stack file that is responsible for ddclient.
---
version: "3.7"
services:
ddclient:
image: lscr.io/linuxserver/ddclient:3.10.0
container_name: ddclient
environment:
- PUID=1000
- PGID=1000
- TZ=America/Chicago
volumes:
- PATH_ON_HOST_WHERE_CONFIG_FILE_LIVES:/config
# example:
# - /home/myuser/ddclient/config:/config
restart: unless-stopped
Ddclient requires a config file called ddclient.conf
. The example above assumes that ddclient.conf
is in /home/myuser/ddclient/config/
on the host.
It’s suprisingly difficult to find working config file examples for Cloudflare. If you get something wrong with the config file, either you mess up the syntax, or have an incorrect setting, ddclient isn’t the best at explaining to you what you did wrong. It took me several deploys and restarts to figure it out. Here is what my config file ended up as.
daemon=1800 # check every 300 seconds
syslog=yes # log update msgs to syslog
#mail=root # mail all msgs to root
#mail-failure=root # mail failed update msgs to root
pid=/var/run/ddclient/ddclient.pid
ssl=yes
use=web
web='https://cloudflare.com/cdn-cgi/trace'
web-skip='ip='
##
## CloudFlare (www.cloudflare.com)
##
protocol=cloudflare, \
zone=yourdomain.com, \
ttl=5, \
login=REPLACE_ME@MY_EMAIL.com, \
password='{{cloudflare_global_api_key}}'
yourdomain.com
Replace yourdomain.com
with your domain. The single quotes around the password=
field are important, as are the trailing \
characters in the Cloudflare portion of the configuration. They are needed for each line until the password line. If you’re not able to find your global API key this reference might be helpful.
With ddclient running on your server, you can rest assured that Cloudflare will be updated when your public IP changes. An easy way to test that it’s working is to update your IP on your domain configuration in Cloudflare to an incorrect IP, and then redeploy ddclient. When it starts up it will send a call to Cloudflare and your domain cloudflare will update to point to your actual IP.
Should you switch?
I would recommend Cloudflare to anyone over Godaddy based on the price of domain renewals alone. In addition, Cloudflare seems a lot more open and developer friendly with their various services than Godaddy. Godaddy’s admin UI at first feels very modern, but the more I used it, the more I realized that most of their user interface is geared towards getting more of your money. They seem more geared towards the non-tech savy. As someone who works with AWS, Azure, and Google Cloud professionally, Cloudflare by comparison feels a lot more familiar than Godaddy.
Even if you’re not technical, I would probably still recommend giving Cloudflare a shot. It’s not as complex as the cloud providers, and their documentation is really good. With Cloudflare being as popular as it is, there are plenty of articles out there explaining how to do just about anything with it.
If you have any questions about this article, or any comments in general, feel free to comment below and I’ll try to help.