How to setup DuckDNS in Home-Assistant

This guide will help you setup DuckDNS with Home assistant, this is useful to give your home assistant a domain name to access it outside of your home. DuckDNS provide free DNS names but also provide Dynamic DNS resolution.

At home most people have dynamic IP addresses on their router, this means that the internet address issued by your service provider changes periodically. Domain names like blah.duckdns.org need to point to an IP address, and if the IP address changes the website will not work.

DuckDNS helps keep your domain name up to date as your IP address changes but also gives you a free domain name to use to access your site.

What You’ll Need:

Section 1: Set Up Port Forwarding (Including Finding Your Home Assistant IP)

What is Port Forwarding ?
Think of your router as the gatekeeper to your home network. When you’re away, it’s like trying to get mail delivered to a specific room in a big house. Without clear instructions (port forwarding), the router doesn’t know where to send the data request. Setting up port forwarding tells the router to route requests for Home Assistant to the right device in your network.

Step 1: Find Your Home Assistant’s IP Address

You need this IP address to tell the router where to send the data.

  1. Open Home Assistant on your browser (e.g., http://homeassistant.local:8123).
  2. Go to Settings > System > Network.
  3. Look for the IPv4 Address (e.g., 192.168.1.100). This is the internal IP of your Home Assistant device.

Make a note of this address. You’ll use it in the next step.

Step 2: Access Your Router’s Settings
  1. Open a browser and enter 192.168.1.1 (or your router’s gateway IP).
  2. Log in with your admin username and password (usually found on the back of your router).
Step 3: Configure Port Forwarding

Once logged in, follow these steps:

  1. Navigate to Advanced Settings, Firewall, or Port Forwarding (menu names vary).
  2. Look for an option to add or create new port forwarding rules.

Create the following two rules:

  • Rule 1 (Port 8123):
    • Name: Home Assistant 8123
    • Internal IP: The IP you found earlier (e.g., 192.168.1.100)
    • Protocol: TCP/UDP
    • Internal Port: 8123
    • External Port: 8123
  • Rule 2 (Optional, for SSL/TLS encryption on port 443):
    • Name: Home Assistant 4430
    • Internal IP: Same as above
    • Protocol: TCP/UDP
    • Internal Port: 443
    • External Port: 443
Step 4: Save and Test
  1. Save the changes on your router.
  2. Try accessing Home Assistant from outside your home network using your Duck DNS URL, e.g., https://yourname.duckdns.org:8123.
Step 5: . Assign a Static IP to Home Assistant

What Is a Static IP?

Think of an IP address like a phone number for devices on your network. By default, routers assign dynamic (changing) IPs. This means your Home Assistant’s IP address could change over time. If it changes, your port forwarding rules won’t work.

A static IP is a fixed address that never changes. Assigning a static IP ensures your router always knows where to direct incoming traffic.

How to Assign a Static IP:

  1. In your router’s settings, find Device List or Connected Devices.
  2. Locate your Home Assistant device by matching the IP or MAC address.
  3. Look for an option like Reserve IP, Assign Static IP, or IP Binding.
  4. Enter the current IP address of your Home Assistant (e.g., 192.168.1.100).
  5. Save the settings.

This step prevents your router from reassigning a different IP to Home Assistant.

Section 2: Register on Duck DNS

Set up the add-on to connect your Duck DNS address to Home Assistant.

  1. Open the Duck DNS add-on.
  2. Click “Configuration.”
  3. Fill in the details:
    • Paste your token (from Duck DNS).
    • Enter your domain name (myhome.duckdns.org).
  4. Enable SSL certificates for secure access by adding the line accept_terms: true under lets_encrypt:.

    Here’s an example configuration:
lets_encrypt:
  accept_terms: true
  certfile: fullchain.pem
  keyfile: privkey.pem
token: your_duckdns_token_here
domains:
  - myhome.duckdns.org
  1. Save the configuration and then start the add-on.
Step 3: Update Home Assistant Configuration

Update your Home Assistant settings to use secure access.

  1. Install the File Editor add-on:
    • Go to “Settings” > “Add-ons” > “Add-on Store.”
    • Search for File Editor, install it, and start the add-on.
    • Open the File Editor from the sidebar and locate the configuration.yaml file.
  2. Add or update the http: section with:
http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  1. Save the file
Step 4: Restart Home Assistant

Restart Home Assistant to apply the changes. Here’s how:

  1. Click “Settings” on the sidebar.
  2. Select “System.”
  3. Scroll down to “Hardware” and click “Restart.”

Wait a few minutes for Home Assistant to reboot.

Step 5: Set the Home Assistant URL

Tell Home Assistant to use your new Duck DNS URL.

  1. Go to Settings > System > Network.
  2. In the Home Assistant URL field, enter your secure address: https://myhome.duckdns.org.
  3. Save your changes.
Step 6: Test Your Setup

Verify that everything works.

  1. Open a browser and visit https://myhome.duckdns.org.
  2. You should see your Home Assistant login page. If it doesn’t load, check for errors in your configuration.

Analogy Recap

  • Duck DNS gives your system an address on the internet.
  • A subdomain is your unique address (like a house number).
  • The add-on forwards requests to your Home Assistant.
  • SSL certificates secure the connection, like security guards checking visitors.
  • Restarting Home Assistant is like rebooting the system to apply new settings.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *