We have a fibre connection at home and like most of the home setups, you will be assigned a new external IP address every time your router re-connects, or when your lease is renewed by your ISP (whenever they feel like it :-))
As we want to expose some of our internal server(s) [Docker containers] to the outside world, and be able to access it via a URL which we know, we’ve in the past opted to use NOIP.com. The free version of NOIP.com allows for up to 3 hosts to be configured, on one of the domain names they offer – like mydomain.ddns.net (just an example).
If you want to use your OWN domain, then you need to purchase a PLUS DNS Management package.
ENTER – DuckDNS.org !
DuckDNS.org is a free service (running on AWS) which allows for the creation of known URLs linked to your dynamic IP address (similar to noip.com)
You will typically get a URL like mydomain.duckdns.org – BUT you can update that (via your domain registrar/DNS provider) to point to your own configuration – like http://www.mydomain.com.
You still need to update your IP address with DuckDNS to make sure it has the latest IP address assigned to you and this is where the DuckDNS Docker container comes in handy.
DOWN TO BUSINESS … [HOW ?]:
Ok, after that long-winded intro here is how I configured the following domain – http://www.greystormydesigns.com to point to a locally hosted WordPress container (running on Docker) and hosting my wife’s blog.
Step 1 – Setup a DuckDNS Account
Go to DuckDNS.org
Register to get access [Free]
Once registered, you will get an access token assigned to your account.
You can now also select to add a unique sub-domain to duckdns.org and link it to your account.
We added greystormydesigns.duckdns.org to my account.
You also have the option on this screen to manually update the external IP address assigned to you by your ISP.
You now have a URL (greystormydesigns.duckdns.org) which points your IP assigned to your router. (although at this point it probably won’t do anything as you still have to configure a couple of other things to make it all work)
Step 2 – Docker container for DuckDNS updates
As your IP address assigned to you by your ISP changes all the time, you need to let DuckDns.org know about these changes to make sure that the IP on their side always resolves correctly to your environment.
Fortunately there is a docker container to assist with this.
Check hub.docker.com to see the DuckDNS container maintained by the linuxserver.io team [they do some AWESOME stuff ! – I’m using some other containers maintained by them and will cover this in later posts]
NOTE: I won’t go into how to get Docker installed in this post and assume you already have docker up and running.
So from the command line, I used the following to pull the latest DuckDNS container and creating it on Docker:
docker create –name=duckdns –restart unless-stopped \
-e TZ=Africa/Johannesburg \
-e SUBDOMAINS=greystormydesigns \
-e TOKEN=*******-****-****-****-***** \
Let’s unpack that a bit:
name = this is the name of your container for your own reference
–restart unless stopped = this tells docker to restart the container if something goes wrong, except if you specifically stopped it
-e TZ = sets the timezone
-e SUBDOMAINS= this is the important bit for DuckDNS – it let’s them know which domain you want to update – you only specify the 1st bit (greystormydesigns.duckdns.org)
-e TOKEN= this needs to be your token assigned to your account when you registered
and then lastly the name of the container to pull from hub.docker.com – linuxserver/duckdns
With all this done, the docker container should be created and ready to be run.
All you now have to do is run the container on docker and it will update the IP address on DuckDNS.org every 5 minutes.
A typical start-up log will look like this:
| | ___ _ __
| | / __| | | / \
| | \__ \ | | | () |
Brought to you by linuxserver.io
We gratefully accept donations at:
User uid: ***
User gid: ***
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 40-config: executing...
Retrieving subdomain and token from the environment variables
log will be output to docker log
Your IP was updated at Sat Jan 5 16:47:04 SAST 2019
[cont-init.d] 40-config: exited 0.
[services.d] starting services
So that’s it – you now have a docker container running which updates your dynamic IP address on DuckDNS.org every 5 minutes.
We’re almost there – just a couple of small things to complete !
Step 3 – Update you router to allow for port-forwarding to your locally hosted website
Port-forwarding can be tricky (and risky), so please be careful with this setting if you’re not 100% sure what you’re doing. 🙂
I suggest you search google for instructions on configuring port-forwarding on your specific router.
Please note that most routers have this option and you would not have to buy anything …
I have an Asus Router and configured the port-forwarding on the WAN side – pointing to my internal server (192.168.2.5) on port 8080.
So this rule routes all external port 80 calls to the internal network to a server running on 192.168.2.5 port 8080
Step 4 – Update the CNAME-record on your domain DNS to point to the DuckDNS.org configuration
As you now have a DuckDNS.org subdomain (greystormydesigns.duckdns.org) pointing to you server, you can add a CNAME record on your DNS provider link these together.
I registered our domain on Doster.com and from the configuration panel, I updated the CNAME Alias entry and added www pointing to greystormydesigns.duckdns.org
That’s it !
All should work fine now.
Hitting www.greystormydesigns.com should open the Blog site 🙂
I hope this helps someone in future and that they will support the efforts of the DuckDNS.org team by donating to them !
Have fun !