The Home Assistant Beginner’s Guide Part 2: Web Access 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.
Advertisement

Now that we’ve got our Home Assistant set up, it’s time to move on to more interesting matters. If you’re anything like me, the first thing you might want to do is control your Home Assistant using a Google Home speaker or the Google Assistant on your phone. And while we’re at it, wouldn’t it also be nice to be able to access the Home Assistant when you’re not at home? Luckily for you, that’s precisely what we’re going to be doing today!

Advertisement

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 password for your Home Assistant before going any further (you can find out how to do that in the first part of the beginner’s guide). 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

Creating a URL for Home Assistant with Duck DNS

To get things started, sign up to Duck DNS. Duck DNS is a free dynamic DNS. To put things simply, this service will translate your router’s public IP into an easily remembered URL. You could just enter your router’s public IP into your browser to access Home Assistant, but there is one main drawback. The main reason you can’t just use the router’s IP is because it changes. Duck DNS will regularly check your IP and update the settings, so you will always have access to your Home Assistant.

Advertisement
CanaKit Raspberry Pi 4 Extreme Kit - Aluminum Edition (8GB RAM)
CanaKit Raspberry Pi 4 4GB Basic Starter Kit with Fan (4GB RAM)
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)
Product
CanaKit Raspberry Pi 4 Extreme Kit - Aluminum Edition
CanaKit Raspberry Pi 4 Basic Starter Kit
CanaKit Raspberry Pi 4 4GB Starter PRO Kit
CanaKit Raspberry Pi 4 Basic Kit
Model
Raspberry Pi 4 Model B (8 GB)
Raspberry Pi 4 Model B (4 GB)
Raspberry Pi 4 Model B (4 GB)
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Power supply with noise filter
Power supply with noise filter
Power supply with noise filter
Accessories
Premium Aluminum Case with Built-In Passive Heat Sink Cooling
Clear case, fan, and set of heat sinks
Premium High-Gloss Case with Integrated Fan Mount, Low Noise Bearing System Fan
Set of 3 aluminium heat sinks
Price
Price not available
Price not available
Price not available
Price not available
-
-
-
-
CanaKit Raspberry Pi 4 Extreme Kit - Aluminum Edition (8GB RAM)
Product
CanaKit Raspberry Pi 4 Extreme Kit - Aluminum Edition
Model
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Accessories
Premium Aluminum Case with Built-In Passive Heat Sink Cooling
Price
Price not available
-
CanaKit Raspberry Pi 4 4GB Basic Starter Kit with Fan (4GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Starter Kit
Model
Raspberry Pi 4 Model B (4 GB)
PSU
Power supply with noise filter
Accessories
Clear case, fan, and set of heat sinks
Price
Price not available
-
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
Product
CanaKit Raspberry Pi 4 4GB Starter PRO Kit
Model
Raspberry Pi 4 Model B (4 GB)
PSU
Power supply with noise filter
Accessories
Premium High-Gloss Case with Integrated Fan Mount, Low Noise Bearing System Fan
Price
Price not available
-
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Kit
Model
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Accessories
Set of 3 aluminium heat sinks
Price
Price not available
-

Adding a new domain to Duck DNS

Once you’ve signed up to Duck DNS, you can add a new domain. Just enter your desired URL into the field following http:// and click on add domain. In the top half of the window, you’ll also see some information like your account name and account type. Keep this window open because we’ll need the token later on.

Setting up Duck DNS for Home Assistant

Next it’s back to the Home Assistant. Access it by entering the device’s IP followed by :8123 (how to find your device’s IP) or hassio.local:8123 into your browser of choice. Access the add-on store (it’s located under Supervisor in the menu), and look for the add-on Duck DNS. Install the Duck DNS add-on and enter the add-on’s settings by clicking on its card. Below, you can see the default settings:

Advertisement
Duck DNS setting in Home Assistant

Remember that token we saw on the Duck DNS website? It’s time to copy that and enter it into your Duck DNS settings. Enter the token and domain you registered, so your settings look like the following:

{
  "lets_encrypt": {
    "accept_terms": true,
    "certfile": "fullchain.pem",
    "keyfile": "privkey.pem"
},
  "token": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "domains": [
    "YOURDOMAIN.duckdns.org"
],
  "seconds": 300
}
Finished Duck DNS settings in Home Assistant

Home Assistant web access configuration

Unfortunately, the Duck DNS add-on doesn’t take care of quite everything and there are a few lines of code we’re going to have to add to the Home Assistant’s configuration.yaml file. Open the file using your favourite editor and enter the following:

Advertisement
http:
  api_password: YOUR PASSWORD
  base_url: YOUR DUCK DNS URL
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

As you can see in my screenshot, I’ve not included the api_password and base_url in my configuration.yaml file and have instead added these to the secrets.yaml file (more about that here).

Adjusting the configuration.yaml

Port forwarding your Home Assistant

The final step is telling your router what device to look for when entering the URL into your browser. This is achieved by port forwarding. This step will be a bit different for everyone because all router interfaces look a bit different. Somewhere in the settings you’ll find the option port forwarding, and you’re going to want to enter the following:

Entry port: Single port / 443
Protocol: TCP
Device: hassio
Destination port: Single port / 8123

Finishing up

The final step will be to check your configuration in the Home Assistant interface and restart it. You should now be able to access the Home Assistant using the custom .duckdns.org domain you’ve chosen!

Advertisement

The Home Assistant Beginner’s Guide Part 3: Integrating Home Assistant with the Google Assistant/Google Home

Advertisement
Liam Alexander Colman, the author and maintainer of Home Assistant Guides.

About Liam Alexander Colman

Liam Alexander Colman has been using Home Assistant for various projects for quite some time. What started off with a Raspberry Pi quickly became three Raspberry Pis and eventually a full-blown server. I now use Unraid as my operating system, and Home Assistant happily runs in a Docker container. My personal setup includes many Zigbee devices as well as integrations with existing products such as my Android TV box. Read on to find out more on how I got started with Home Assistant.

Leave a comment

Advertisement
Share to...