Skip to content

5. Getting a domain with DuckDNS

spaceface777 edited this page Mar 28, 2019 · 1 revision

In this tutorial you will use DuckDNS to get a domain for your site, which will make the URL to your server easier to remember, and keep the same URL if your external IP changes for some reason. A domain is also required for HTTPS.

DISCLAIMERS

  • These instructions are written for Debian-based Linux distributions (Debian, Ubuntu, Raspbian...). You may need to change some of the commands for them to work in other Linux distros, and Windows is unsupported and will most likely not work.

  • You need a Hermes server already running through Nginx and port 80 open in your router in order to follow these instructions! Follow guides #1, #2, #3 and #4 to get this.

CREATING A DUCKDNS DOMAIN

You should get a domain for your site. To get one you can use DuckDNS, which will give you other advantages such as keeping the same web address even if your IP changes.

To create one, create an account on https://duckdns.org.

When you have registered, you will see a page like this one.

Main DuckDNS page

Create a subdomain on the site. Remember to save the token shown on the page, you will need it in the next step.

CONFIGURING THE DOMAIN

Enter these commands on your server:

mkdir ~/Scripts && cd ~/Scripts
nano DuckDNS

This will open a text editor, into which you should paste this in (Replace DOMAIN and TOKEN for your own):

DOMAIN="exampledomain"
TOKEN="00000000-0000-0000-0000-000000000000"

echo url="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&verbose=true" | curl -k -o ~/Scripts/DuckDNS.log -K - 

Once you have done this, press CTRL + X to exit and Y to save your changes. Then paste in these commands:

chmod 700 DuckDNS
./DuckDNS
cat DuckDNS.log

At the end of the terminal output, you should see "OK" printed. If you don't, check that your domain and token are correct.

At this point, if you go to {DOMAIN}.duckdns.org, you should be able to access your Hermes server.

MAKING THE DOMAIN POINT TO THE CORRECT IP ADDRESS

Right now, you have a domain which forwards to the IP of your server. However, if the IP changes for some reason, the domain won't be able to connect to it. Now we will make the server update the active IP address every 5 minutes using cron so this doesn't happen.

Enter this command on your server:

crontab -e

If it asks you to choose an editor, select nano, it's the one we have been using throughout the entire tutorial.

You will enter a text editor. Go down to the bottom of the file, and paste this in:

*/5 * * * * ~/Scripts/DuckDNS>/dev/null 2>&1

This will run the update script every five minutes.


You should have your own domain to host Hermes on!

Clone this wiki locally