Dynamically Update DNS When Your Server IP Address Changes

I've been running my website on a Raspberry Pi in my home for years.

Whenever my router got restarted, my home would have a new external IP address, and so I needed to find out that IP address, then log into the registrar I use and update the IP address to direct my domain name to my website server.

My website didn't really need to be live most of the time, so it didn't bother me occasionally changing the IP address.

Recently, I was thinking it must be possible to automate logging into my account and changing the IP address. So I looked up to see if someone had already made a solution, and it turns out there is a standard one. It's called dynamic DNS.

  1. Make sure your domain registrar supports dynamic DNS. You can move your domain to another registrar if not.
  2. Install ddclient on the server. This is one of several options of software which performs dynamic DNS updates to domain providers. It may not support all registrars.
  3. Configure your domain in your registrar to use a dynamic DNS record. Your registrar may have instructions for this.
  4. Configure /etc/ddclient.conf to update the right domain, with the right registrar, with the right password, which you'll find somewhere in your registrar account.
    • e.g.
      protocol=namecheap # check your registrar for which protocol
      use=web, web=dynamicdns.park-your-domain.com/getip server=dynamicdns.park-your-domain.com

      # website 1
      login=thomasrichards.dev
      password='...'
      *,@ # which subdomains to match (here all and none)

      # website 2
      login=thomasrichards.xyz
      password='...'
      *,@
      # which subdomains to match (here all and none)
  5. Test your configuration. Read the output of this command carefully to see if it worked or what precisely went wrong.
    sudo ddclient -daemon=0 -debug -verbose -noquiet
  6. Ensure ddclient runs when your server starts. The command may vary by OS.
    sudo systemctl enable ddclient.service
  7. Start the service.
    sudo systemctl start ddclient.service

Comments

Popular posts from this blog

Fix Controller Input when a Game Doesn't Use Steam Input

VSC Vanishing Go Imports

En Dash with ComposeKey (Shift+AltGr)