Home Assistant 推薦DDNS使用Dynu

Dynamic DNS是能讓域名跟浮動IP綁住,確保換對外IP時,使用固定的域名都能對應到自家的對外IP,然後就能使服務正常被連線到。

Home Assistant內建DuckDNS,也有配套Let’s Encrypt作爲憑證產生,雖然很簡單,但是Let’s Encrypt有兩種Challenge方式:HTTP、DNS。

HTTP要開80 Port,要額外在路由器或防火牆設定轉發,比較不方便。

DNS則不支援DuckDNS。

DuckDNS有穩定性問題,我用Telegram Webhook會出現解析不到域名。用筆電實測也確實解不到,這使得Telegram找不到Webhook URL,於是改用別家的DDNS。

因此推薦免費的Dynu,可以使用DDNS與Let’s Encrypt,可以一舉建構低維護成本與信任的HTTPS環境。

操作步驟

註冊Dynu的帳號

在Dynu上註冊自己的域名

在Dynu上取得API Key

在Home Assistant安裝附加元件(add-on)Dynu DNS

設定Dynu DNS

執行Dynu DNS

註冊Dynu

參考文章 https://www.mobile01.com/topicdetail.php?f=110&t=6879493

Dynu官方連結

建立dynu帳號並登入

點擊齒輪icon,進入選單

點擊「DDNS Services」,添加自己指定的域名。

點擊「API Credentals」,然後取得API Key,複製保存。

在Home Assistant安裝Dynu DNS

參考文章

https://community.home-assistant.io/t/add-on-dynu-dns-alternative-to-duckdns/331584

以下是文章的How To Install

Installation

Navigate in your Home Assistant frontend to Supervisor → Add-on Store.

Click 3-dots menu at upper right > Repositories 
and add this repository URL: https://github.com/koying/ha-addons 1.3k

Scroll down the page to find the new repository “Add-ons from Koying”, and click one of the new add-ons.

Click Install and give it a few minutes to finish downloading.
Configure at Configuration tab or separate file in Configuration folder 390 according to the instructions of the add-on.

Click Start, give it a few dozen seconds to spin up.

Enjoy.

重新整理頁面,再進到附加元件商店,點擊Dynu DNS並安裝。

等待安裝好了之後,再點擊Dynu DNS,依照Dynu DNS內的Document,以下是How to use

How to use
Visit dynu.com and create an account by logging in through any of the available account services (Google, Github, Twitter, Persona, Reddit).

In the Control Panel area, click on the DDNS services section, click Add. Choose amongst the available domains, and type the name of the subdomain .

If registration was a success, the subdomain is listed in the DDNS services section along with current ip being the public IP address of the device you are currently using to access dynu.com. The IP address will be updated by the DynuDNS add-on.

In the DynuDNS add-on configuration, perform the following:
Copy the DynuDNS API key (in the control panel, go to API credentials, reveal and copy) from dynu.com and paste into the token option.

Update the domains option with the full domain name you registered. E.g., my-domain.ddnsfree.com.

以下是參考的Config設定

lets_encrypt的accept_terms:爲true的話,就會自動以輸入域名產生憑證,並放到指定位置。

lets_encrypt:
  accept_terms: true
  certfile: fullchain_dynu.pem
  keyfile: privkey_dynu.pem
token: <dynu api key>
domains:
  - <your-domain name>
aliases: []
seconds: 300

按下啓動,隨着日誌跑完,在Dynu上的IP也改動了。