Opening up Home Assistant to the internet with Duck DNS

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.

Now that you have successfully installed Home Assistant on a Raspberry Pi, configured automatic backups, and installed the Studio Code Server add-on, it is time to move on to more interesting matters. If you are anything like me, you will want to be able to control your smart home not just from within it. This beginner’s guide will show how to do just that without spending a penny.

The following steps might want to be avoided by anyone with privacy concerns. Following this guide will open up your Home Assistant to the big, bad internet. It’s more important than ever to set a secure password for your Home Assistant account before going any further. In this guide, I’ll be showing you how to open your Home Assistant to the internet, configure a custom URL (using Duck DNS) with encryption (using Let’s Encrypt) and what ports you have to open on your Router.

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.

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.

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

Frequently asked questions about opening up Home Assistant using Duck DNS

Below are answers to some of the questions that have been put to me in comments or personal messages.

I can’t access Home Assistant using my Duck DNS domain

Leave a comment