Opening up Home Assistant to the internet with Duck DNS

No comments
Disclosure: This post contains affiliate links. If you click through and make a purchase, I’ll earn a commission, at no additional cost to you. Read my full disclosure here.
Advertisement
A digital art piece of ducks taking over the world.

With Home Assistant installed on your Raspberry Pi, automatic backups set up, and the Studio Code Server add-on added, you’re now ready to dive into more exciting projects. If you are anything like me, you want to have the ability to control your smart home from outside of it as well. This beginner-friendly guide will show you how to achieve that, without spending any money, using Duck DNS.

Advertisement

For those with privacy concerns, the following steps may not be suitable. This guide will demonstrate how to open your Home Assistant to the internet, exposing it to potential risks. It is essential to set a strong password for your Home Assistant account before proceeding.

In the following paragraphs, I will show you how to set up a custom URL using Duck DNS, and how to encrypt it using Let’s Encrypt. Additionally, we will explain which ports need to be opened on your router to complete the setup.

Advertisement

Table of Contents

What is Duck DNS?

Duck DNS is a (currently) free dynamic DNS hosted on Amazon Web Services (AWS), which will point a subdomain of duckdns.org to an IP of your choice. Using it, you can open any service you have running locally to the internet. It can be used with just about every operating system on the market, and also with various routers. Duck DNS is supported by Patreon subscribers and accepts Bitcoin donations.

The great thing about using Duck DNS with Home Assistant is that you don’t need to worry about owning a static IP or the correct certificates. The Home Assistant add-on takes care of everything: It will update your Duck DNS subdomain with your current public IP, and it will make sure that the free Let’s Encrypt certificates are always valid.

Advertisement

Configuring Home Assistant to use a static IP

It is imperative to configure Home Assistant to use a static IP before anything else. There are a few ways of doing this, but the easiest is built right into the Home Assistant settings. Open the Home Assistant Dashboard and navigate to the Settings, next select System, and finally Network. In the card titled ‘Configure network interfaces‘ you should see your wired and wireless network interfaces.

If you have followed my recommendations, you will be using a wired connection, and thus will be using ETH0. Simply switch from DHCP to Static and Home Assistant will automatically insert the current configuration it has received from the DHCP. If, for some reason, the information is not automatically entered, I have described how to figure out your gateway and IP address in a previous guide.

The reason behind doing this is that we will need to configure port forwarding in a later step. If the DHCP lease is up, and your Raspberry Pi running Home Assistant is assigned a new IP address, the port forwarding will no longer work.

Advertisement

Signing up for a Duck DNS account

Signing up for a Duck DNS account only requires you logging in using a Twitter, Google, or Google account. Once logged in, you can register your subdomain using the prominent text field. The only other information you will need from this site is your token, As with all tokens and password, you should never share this one with anyone.

Installing and configuring the Duck DNS add-on for Home Assistant

I’ve covered the installation of Home Assistant add-ons in a previous guide. If you are unsure on how to proceed, refresh your memory by reading that article. The Duck DNS add-on is found as part of the official add-ons. Simply select and install it to get started.

Once installed, there is no need to immediately start the Duck DNS add-on, as it won’t be able to function without having been set up first.

Select the Configuration tab and enter your domain name and token, which you previously copied from Duck DNS. You will also have to change one line in the text field for Let’s Encrypt: Instead of accept_terms: false, you will want to change it to accept_terms: true. As mentioned earlier, the free SSL certificate is provided by Let’s Encrypt, making sure your connection is safe and secure. If interested, you can read up on the terms of service on their website. Once done, you will need to click on the button titled ‘save’ to continue.

You can now return to the Info tab, and finally start the Duck DNS add-on. However, before you start it, you can also decide whether you want to enable the watchdog and auto-updates.

Configuring Home Assistant’s internal and external URL

After having configured the Duck DNS add-on, you will need to define Home Assistant’s external/internet and internal/local URL. This is done so that you can access the Home Assistant Dashboard locally when at home, and using the URL when you are out. Head back to the same place where you configured the static IP address, and enter the appropriate URLs.

Letting Home Assistant know where the SSL certificates are

The last piece of information Home Assistant needs to be aware of is the location of the SSL certificates. To accomplish this, you can use the Studio Code Server add-on to open up the configuration.yaml file. Towards the bottom of this file, you simply need to add the following code:

http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

The last piece of information Home Assistant needs to be aware of is the location of the SSL certificates. To accomplish this, you can use the Studio Code Server add-on to open up the configuration.yaml file. Towards the bottom of this file, you simply need to add the following code:

http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

Leave a comment

Share to...