Self-hosting: domain and DNS zone#
Over next few weeks/posts, I’ll focus solely on self-hosting adventure. To start, beside free time and motivation to learn new things, you will need just a few components:
internet connection with public IP
router allowing port forwarding
server hardware (old computer, old laptop or mini PC)
domain with DNS zone
server software (yunohost)
and apps/services.
Previosly, I wrote about points 1-2 and 3. Today, let’s focus on the point 4: domain and DNS zone.
Internet domains#
Wikipedia is probably the best source of information about Internet domains, registrars and DNS hosting.
Sticktly speaking, you don’t need to register a domain to start selfhosting adventure. You can use your public IP. But having a registered domain is usually more user friendly than typing set of numbers such as 79.116.183.7 in your web browser. Beside, you’ll need a domain if you want to protect trafic to your server with TLS certificate.
In the beginning of your selfhosting journey, you may consider using one of the free subdomains offered by yunohost: .nohost.me, .noho.st or .jnh.fr. Note, you can register only a single of these free subdomains per instance. What’s great, if you decide to go this way, yunohost will take care of DNS hosting and dynamic IP address updates. If you go this way, you can finish reading here.
If you would prefer more customised addresses, continue reading.
Register new domain#
There are numerous registrars (domain stores if you will). I decided to rely on OVH, because it’s EU-based and it has good track recort.
Also, you can choose from enless list of top-level domains (TLD). Just keep in mind, that some TLD come cheap for the first year, but you may be surprised with higher renewal cost for subsequent years. In addition, some services may offer you cheaper domain fee, but will charge you additionally for other mandatory services.
One of the cheapest TLDs you can get is .ovh (2-3€ / year). The only downside is that you won’t be able to migrate it to other registrars, because .ovh TLD belongs to OVH. OVH is EU-based, so I was comfortable with this limitation. But you may choose another option. As I said earlier, the TLD variety is nearly endless!
DNS Hosting#
Most of the registrars offers DNS hosting (DNS zone) for free. If you register your domain with OVH, you should access your preconfigured DNS zone and update IP (all A entires) to the public IP of your server.
You can read more DNS zone configuration in yunohost docs.
Note, yunohost offers automatic DNS zome setup via Administration > Domains > Your domain > DNS panel. It worked for me just fine, but this is still experimantal! So be careful and ideally keep a copy of your DNS zone config just in case.
In order to use it, you’ll need to generate an API key, namely Application key, Application secret key and Consumer key. For OVH just follow this tutorial.
And provide your API key in Administration > Domains > Your domain > DNS panel. If everything worked fine, yunohost will automatically detect your current DNS zone config and propose changes, so everything works as it should.
Good luck!
DynDNS#
If your public IP isn’t static (it changes every now and then for example when you restart a modem/router), it’s recommended to enable Dynamic DNS zone.
You can detailed info aboud setting up DynDNS here.
In brief, go to https://www.ovh.com/manager/#/web/zone, click on your domain name and DynHost.
First, you’ll need to create a new user.
Click Manage access > Create a username and fill the form.
I used *
as a subdomain so all subdomains are controlled.
Store username (it looks like DOMAIN-USER) and password safely.
Then, create a DynDNS host. Enter DynDNS menu again > Add DynDNS record. This time I provided empty string as a subdomain. At this point you can provide any IP.
Finally, try updating your entry using curl
by providing your DOMAIN, USERNAME and PASSWORD as follows:
curl --user "USERNAME:PASSWORD" "https://www.ovh.com/nic/update?system=dyndns&hostname=DOMAIN"
You should see either message starting with
good
followed with updated IP address ornochg
followed with actual IP address if your IP didn’t change.
Refresh DynDNS website, if everything worked, you should see your IP updated there.
If it does work, you can enable automatic cron job using crontab -e
.
For me something like this works well
(again, replacing DOMAIN, USERNAME & PASSWORD):
*/15 * * * * curl -s --user "USERNAME:PASSWORD" "https://www.ovh.com/nic/update?system=dyndns&hostname=DOMAIN" >> /tmp/curl.log 2>&1
Above, will update your IP every 15 minutes (*/15
)
and append DynDNS responses to /tmp/curl.log
file.
That’s all.
Breakdown of the costs of self-hosting so far:
public IP: 1€ monthly (assuming you already have a fiber connection and a router)
mini PC: 200-300€ one time payment (or nothing if you use some old laptop/computer)
domain: 2-3€ annually for .ovh (or nothing if using one of the subdomains offered by yunohost)