Tags: Dynamic DNS
Do you have files stashed on a computer at home but you're halfway around the world? In theory the Internet is equally usable by all of us, but in practice it's a little different. We're told we can only store our data on servers owned by other people, and cannot do so on our own server. In actual practice it is fairly easy to access computers on your home network, and the first step is associating a domain name with your home network.
Accessing a computer by domain name or by its internet address
A domain name is the name we usually refer to like techsparx.com or google.com. Domain names are meant to be an easier-to-remember label for computers attached to the Internet.
Each computer attached to the Internet has an IP Address, which is a number, that is its real identity to the Internet. But the numbers are difficult to remember, and in the modern age are prone to change frequently. The domain name system (a.k.a. DNS) was developed in the 1980's to give a user-friendly name to use instead of the user-hostile IP address. The IP address for website names like techsparx.com or google.com are recorded by entries in the Domain Name System.
Your home computer network has an IP address. For most of us we use that Internet connection solely to browse the Internet, as a consumer. But all Internet connections are two-way, and in theory your home Internet connection could support Internet services. What's lacking is a domain name associated with the IP address of your home network.
Remotely accessing home network by assigning a domain name
The first step to remotely accessing your home network is to associate a domain name with its IP address. But most Internet Service Providers randomly assign IP addresses rather than assign a fixed IP address to each customer. The random IP address makes it difficult to associate a domain name.
Another use case is folks renting cloud servers from Amazon AWS or Google Compute Engine or the like. In that case an IP address is assigned randomly each time the server is regenerated. Again, this makes it difficult to associate a domain name.
DuckDNS is just one example of a "Dynamic DNS provider". They make it easy to get a domain name assigned to an IP address, and to regularly update the domain name entry in case the IP address changes.
Example: Home network with several services accessed from tens of thousands of miles away
In my case I have an Intel NUC (a tiny low-cost low-power-consumption computer) sitting on my desk running a few useful services. Well, they're useful to software engineers, namely I have a Git server and a Jenkins build server that's used for software builds. Further, I have a Plex server in which I've stashed a bunch of video files.
Those services could instead be installed on a cloud service - like Digital Ocean. But that would cost $20 per month or so. The Plex service would be prohibitively expensive to set up on a cloud server because of the data consumption. The Intel NUC cost about $300 to set up, and it's been running for 2 years or more. Two years at $20 per month is $480 in hosting fees with Digital Ocean, meaning the NUC has paid for itself by avoiding that cost.
Last year I traveled to Europe and was able to use the NUC remotely just like I do at home. The year before I traveled to New York City and was able to do the same.
In my case the Internet Service Provider I use assigns a fixed IP address. I have already assigned a domain name to that fixed IP address and use it all the time. However, if I instead had a dynamic IP address I'd be using a Dynamic DNS service.
DuckDNS setup
With that basic knowledge under our belt, let's talk about setting up DuckDNS.
If you refer back to the home page - https://duckdns.org - you'll see some buttons at the top about signing up with different services. I clicked on the Reddit button and got this:
That's how we sign up for Duck DNS. Once signed up we are redirected to the home page:
Okay, we have an account with DuckDNS and everything.
Using DuckDNS is fairly straight-forward. Enter a "sub-domain name" into the box, and click Add Domain.
What's a Sub-Domain? The domain name system is a tree of domains. You may have seen this already without really noticing it. For example logging-in to an account on a Yahoo service involves being redirected to login.yahoo.com
. Further, many websites use the domain name www.example.com
rather than example.com
. In both cases those are subdomains.
Subdomains can be arbitrarily nested like foo.bar.baz.gronk.example.com
.
What DuckDNS asks you to do is to use a name, foobarbaz.duckdns.org
, within the duckdns.org
domain-name-space.
This is after the domain name has been assigned. Notice that DuckDNS lets you assign up to five domain names.
Automatically refreshing the domain name IP address mapping
In most cases your home network is assigned a dynamic IP address. If so, you'll need to notify DuckDNS every time it changes.
The install tab of the DuckDNS website has tools you can install in various sorts of computers to automate refreshing the domain name.
In my case I installed a Linux Cron job on my Intel NUC.
0 1,3,5,7,9,11,13,15,17,19,21,23 * * * curl https://www.duckdns.org/update?domains=DOMAIN-NAME&token=TOKEN-ASSIGNED-BY-DUCK-DNS >/dev/null 2>/dev/null
Voila it works
I don't have a snazzy picture to show proof that it works. But I am able to access the home computer network using the newly assigned domain name.
Next steps - Now what?
Home network routers include a firewall that prevents traffic from reaching inside your network. This is for security, since it prevents some of the attacks on your computers. But if you got this far it's because you want to run a service on a home computer and access it from anywhere.
It's beyond the scope of this to advise you on services to install. The Git server I use is Gogs, and the build server I use is Jenkins. But you may want to install other things.
Making these services available outside your home network requires some configuration in the Router. It's possible to configure the router to allow some outside traffic to enter the home network. The technique is called Port Forwarding where you tell the router to support certain Internet services and pass those over to a computer on the internal network.
It's beyond the scope of this to advise how to set up port forwarding - if only because every router has a different method. The DuckDNS site recommends https://portforward.com/
as a good guide.