How to set up dynamic DNS for a home computer or server

I recently purchased a mini computer from aliexpress. It's quite powerful, and much more cost effective than renting Amazon EC2 instances. It sits near my router in my apartment, constantly on 24/7, sipping just 10 to 15W.

I have a regular internet service provider (ISP) that I pay monthly. Most importantly, I do not have a static IP address. Usually a static IP either costs more money each month, or is simply not an option.

What's the solution? How can I connect to my home computer/server? Dynamic DNS!

Configuring dynamic DNS

Okay, so I have a domain name, a home internet service provider (ISP), a router, and a home server (the mini computer). I do not have a static IP. But I want to consistently connect to my home computer/server from a remote source (such as from my phone, or from my laptop while traveling).

I registered my domain through Google Domains, so let's start there. You may have to do something similar through the settings wherever you registered your domain.

In the Google Domains section there's an option to set up dynamic DNS for a given domain name. You just specific the subdomain (I named mine 'scooter' as seen below) and pointed it to one of my domain names that I had registered with Google Domains.

Next I went to my home router, which is a TP-LINK Archer C7 and found the section for Dynamic DNS. I was hoping it would be easy enough to just point it to my domain name with the username/password that Google Domains created for me.

Unfortunately TP-LINK isn't very flexible. They expect users to use No-IP, Dyndns, or Comexe for their Dynamic DNS needs.

Fortunately, Google Domains is much more flexible. They let you use a client or their API to update your dynamic DNS.

Okay, so maybe I'll try the DDclient, since that looks to be a supported client.

Using DDclient for Dynamic DNS

You can learn about DDclient here. Since I was running an Ubuntu operating system, I chose to use the apt-get package manager.

Running sudo apt-get install ddclient immediately launched me into a setup wizard.

The only part I was confused about was the network interface.

Running ifconfig -a helped figure that out. Here's the output of running that:

 $ ifconfig -a
 lo        Link encap:Local Loopback
           inet addr:127.0.0.1  Mask:255.0.0.0
           inet6 addr: ::1/128 Scope:Host
           UP LOOPBACK RUNNING  MTU:65536  Metric:1
           RX packets:4207361 errors:0 dropped:0 overruns:0 frame:0
           TX packets:4207361 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:444136775 (444.1 MB)  TX bytes:444136775 (444.1 MB)

 p2p1      Link encap:Ethernet  HWaddr 00:e0:4c:68:26:63
           inet addr:192.168.0.104  Bcast:192.168.0.255  Mask:255.255.255.0
           inet6 addr: fe80::2e0:4cff:fe68:2663/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:81683207 errors:0 dropped:0 overruns:0 frame:0
           TX packets:48801901 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:107403166761 (107.4 GB)  TX bytes:4635165051 (4.6 GB)

 p3p1      Link encap:Ethernet  HWaddr 00:e0:4c:68:26:64
           BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

 wlan0     Link encap:Ethernet  HWaddr 48:5d:60:4f:1f:59
           BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Based on the amount of traffic, it looks like I want p2p1.

After ddclient installation

After the setup wizard was finished, I expected a generated ddclient.conf file somewhere. According to the docs, there should be one at

/etc/ddclient.conf

But there wasn't. I tried to debug ddclient by running

ddclient -daemon=0 -noquiet -debug

and it showed a file located at

/var/cache/ddclient/ddclient.cache

But then it also showed:

DEBUG:    get_ip: using if, p2p1 reports 192.168.0.104

Which is not the IP address I want!

So I manually created a configuration file at /etc/ddclient.conf

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

protocol=dyndns2
use=web
ssl=yes
server=domains.google.com
login=loginname
password='password'
scooter.mydomain.com

Then edit

sudo nano /etc/default/ddclient

Make sure run_daemon=”true”

$ sudo service ddclient status
Status of Dynamic DNS service update utility: ddclient is running.

If it's not running type

$ sudo service ddclient start

Success!

DDclient is a neat piece of software that can detect when my IP address changes (such as when my ISP randomly decides to rotate it). DDclient then transmits the new IP address to Google Domains, so whenever I visit scooter.mydomain.com it knows which IP address to route the traffic to. Yay!

Stephen

Read more posts by this author.


View or post Comments