Skip to content

Instantly share code, notes, and snippets.

@mansouryaacoubi
Last active March 25, 2024 03:12
Show Gist options
  • Save mansouryaacoubi/6774911fe2ffa60fac7738913aae34e2 to your computer and use it in GitHub Desktop.
Save mansouryaacoubi/6774911fe2ffa60fac7738913aae34e2 to your computer and use it in GitHub Desktop.
Duck DNS DNS Settings

Guide How To use custom domain with Duck DNS: home-assistant/addons#1331 (comment)

Let us imagine the following:

You have a domain example.duckdns.org and you have the domain example.com and want to access your home assistant via home.example.com.

Short Guide

  1. Set CNAME records for your domain: *.home and home pointing to example.duckdns.org
  2. Install or Reinstall the DuckDNS Addon on your home assistant instance.
  3. Set your addon config and leave out your alias for this step
  4. Start the duckdns addon and watch the log for completion of certificate creation
  5. Now add the alias to your config
  6. Restart addon and watch the log for completion of certificate creation
  7. Add http section to your configurations.yaml and set your alias domain as your base_url
  8. Restart your home assistant

Detailled Guide

  1. Set CNAME records for your domain
CNAME     *.home      example.duckdns.org
CNAME       home      example.duckdns.org
  1. Install or Reinstall the DuckDNS Addon on your home assistant instance.
  2. Set the following configuration in your addon configuration:
lets_encrypt:
  accept_terms: true
  certfile: fullchain.pem
  keyfile: privkey.pem
token: take-the-token-from-your-duckdns-account
domains:
  - example.duckdns.org
aliases: []
seconds: 300
  1. Start your addon and let your addon create your keypairs (you can follow the process in the Logs tab)

Log output should be:

INFO: Renew certificate for domains: example.duckdns.org and aliases: 
# INFO: Using main config file /data/workdir/config
 + Creating chain cache directory /data/workdir/chains
Processing example.duckdns.org
 + Creating new directory /data/letsencrypt/example.duckdns.org ...
 + Signing domains...
 + Generating private key...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 1 authorizations URLs from the CA
 + Handling authorization for example.duckdns.org
 + 1 pending challenge(s)
 + Deploying challenge tokens...
OK + Responding to challenge for example.duckdns.org authorization...
 + Challenge is valid!
 + Cleaning challenge tokens...
OK + Requesting certificate...
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!
  1. Now after certificates has been created change your addon configuration to the following:
lets_encrypt:
  accept_terms: true
  certfile: fullchain.pem
  keyfile: privkey.pem
token: take-the-token-from-your-duckdns-account
domains:
  - example.duckdns.org
aliases:
  - domain: home.example.com
    alias: example.duckdns.org
seconds: 300
  1. Restart your addon and follow process in the Log-tab

Log output should be:

INFO: Renew certificate for domains: example.duckdns.org and aliases: 
home.example.com
# INFO: Using main config file /data/workdir/config
Processing home.example.com with alternative names: example.duckdns.org
 + Signing domains...
 + Generating private key...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 2 authorizations URLs from the CA
 + Handling authorization for example.duckdns.org
 + Found valid authorization for example.duckdns.org
 + Handling authorization for home.example.com
 + 1 pending challenge(s)
 + Deploying challenge tokens...
OK + Responding to challenge for home.example.com authorization...
 + Challenge is valid!
 + Cleaning challenge tokens...
OK + Requesting certificate...
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!
  1. Add the following to your configurations.yaml file:
http:
  server_port: 8123
  base_url: home.example.com
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  1. Restart your home assistant

These steps will definitely work with everybody!

Have fun :D

P.S.: Don't forget forwarding your local port 8123 to 443 in your router 👍

If you need to set TXT record for your duckdns domain:
https://www.duckdns.org/update?domains={domain}.duckdns.org&token={token}&txt={dns_txt}

@IanK6449
Copy link

IanK6449 commented Mar 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment