由於LG、小米、三星、TCL、、、、等3C大廠有海量工程師,底下做法只能防君子不防小人!
我家使用國際牌電視(安卓系統14),用WiFi 5GHz 通道52 頻寬80M。
我在chatGPT協助下已經讓我家區網的3C設備盡量經由路由器的SmartDNS套件查詢。
底下是我叫GPT整理的步驟,重點在於每次重啟Smart DNS後,要等待一分鐘以上,並在TV或PC確認可以正常查詢DNS,才算是重啟完成!
德國DNS優點在本頁面最上面!
我給GPT的提示:
列出ImmortalWrt 25.12恢復原廠設定後,完成下列工作的Bash指令,並評估是否能讓區網的各種3C設備都由SmartDNS送出查詢!
(路由器是Tplink Ax23)
1、用Ssh進入 ImmortalWrt後,檢測目前防火牆版本。如果是FW3,則移除FW3,並安裝FW4。當防火牆改為FW4或原本就是FW4,則先啟動「軟體流量卸載」,再去做第二點工作。
2、將Wan的DNS改為8.8.8.8和8.8.4.4,而Wan6的DNS維持自動模式。
3、安裝Smart DNS,並啟動「自動調整DNSmasq設定」。然後,將底下Doh3寫入/etc/smartdns/custom.conf
server-h3 h3://76.76.2.11/x-oisd -host-name x-oisd.freedns.controld.com
4、設定防火牆轉發規則,以便區網的3C設備都經由SmartDNS的Doh3送出查詢。
5、提供檢測「區網的3C設備都經由SmartDNS送出查詢」的Bash指令。
GPT回答:
https://chatgpt.com/s/t_6abc8eed171...d21cd53e8d54f31
Gemini 3.6 Flash的回答:
在 ImmortalWrt 25.12 恢復原廠設定後,可以透過下列 Bash 指令自動完成系統設定、安裝 SmartDNS、配置自訂 DoH3 上游以及設定 FW4 DNS 重定向。
一、系統設定與配置腳本
請透過 SSH 連線至 TP-Link Archer AX23 (ImmortalWrt) 後,複製並執行以下指令:
Bash
# ==========================================
# 1. 檢測防火牆版本 (FW3 -> FW4) & 啟動軟體流量卸載
# ==========================================
if opkg list-installed | grep -q "firewall4"; then
echo "[+] 目前防火牆已是 FW4 (nftables)"
else
echo "[!] 目前為 FW3,升級至 FW4 (nftables)..."
opkg update
opkg remove firewall uci-firewall iptables
opkg install firewall4 nftables
fi
# 啟動軟體流量卸載 (Software Flow Offloading)
# 註:Archer AX23 (MT7621) 不支援硬體流量卸載,故設定 hw='0'
uci set firewall.@defaults[0].flow_offloading='1'
uci set firewall.@defaults[0].flow_offloading_hw='0'
uci commit firewall
/etc/init.d/firewall restart
# ==========================================
# 2. 設定 WAN DNS (WAN 改為 8.8.8.8 與 8.8.4.4,WAN6 維持 auto)
# ==========================================
uci set network.wan.peerdns='0'
uci delete network.wan.dns 2>/dev/null
uci add_list network.wan.dns='8.8.8.8'
uci add_list network.wan.dns='8.8.4.4'
# 確保 WAN6 維持自動取得 (ISP 配發 DNS)
uci set network.wan6.peerdns='1'
uci commit network
/etc/init.d/network restart
# ==========================================
# 3. 安裝 SmartDNS,配置 DoH3 並啟動「自動調整 DNSmasq 設定」
# ==========================================
opkg update
opkg install smartdns luci-app-smartdns
# 將自訂 DoH3 伺服器寫入 /etc/smartdns/custom.conf
cat << 'EOF' > /etc/smartdns/custom.conf
server-h3 h3://76.76.2.11/x-oisd -host-name x-oisd.freedns.controld.com
EOF
# 啟動 SmartDNS 服務與「自動調整 DNSmasq 設定」
uci set smartdns.@global[0].auto_set_dnsmasq='1'
uci set smartdns.@global[0].enabled='1'
uci commit smartdns
/etc/init.d/smartdns restart
/etc/init.d/dnsmasq restart
# ==========================================
# 4. FW4 防火牆重定向 (劫持區網 Port 53 至路由器 SmartDNS)
# ==========================================
# 移除過往同名重定向,避免重複建立
while uci -q delete firewall.@redirect[0]; do :; done
# IPv4 DNS 重定向 (DNAT Port 53)
uci add firewall redirect
uci set firewall.@redirect[-1].name='Redirect-DNS-IPv4'
uci set firewall.@redirect[-1].src='lan'
uci set firewall.@redirect[-1].proto='tcp udp'
uci set firewall.@redirect[-1].src_dport='53'
uci set firewall.@redirect[-1].dest_port='53'
uci set firewall.@redirect[-1].target='DNAT'
# IPv6 DNS 重定向 (DNAT Port 53)
uci add firewall redirect
uci set firewall.@redirect[-1].name='Redirect-DNS-IPv6'
uci set firewall.@redirect[-1].src='lan'
uci set firewall.@redirect[-1].proto='tcp udp'
uci set firewall.@redirect[-1].src_dport='53'
uci set firewall.@redirect[-1].dest_port='53'
uci set firewall.@redirect[-1].family='ipv6'
uci set firewall.@redirect[-1].target='DNAT'
uci commit firewall
/etc/init.d/firewall restart
二、評估:是否能讓區網所有 3C 設備都由 SmartDNS 的 DoH3 送出查詢?
結論:涵蓋大部分普通設備(約 80%~90%),但「無法 100%」攔截所有 3C 設備。
1. 運作鏈條:
標準設備(依賴 DHCP 發放 DNS):設備 ➔ DNSmasq (Port 53) ➔ SmartDNS ➔ 上游 Control D (DoH3/HTTP3)。
硬編碼 DNS 設備(寫死 8.8.8.8:53 或 1.1.1.1:53 的 IoT 設備):FW4 的 DNAT 規則會攔截 Port 53 的普通 UDP/TCP 流量並重定向至路由器的 DNSmasq,最終一樣由 SmartDNS 的 DoH3 送出。
2. 漏網之魚(無法攔截的情況):
Private DNS / DoT (Port 853): Android 手機若開啟「私人 DNS」,會經由 TCP/853 埠直接連線外部 DoT 伺服器,FW4 僅攔截 Port 53,因此會繞過 SmartDNS。
內建 DoH/DoH3 的 App 或設備: 現代瀏覽器(Chrome/Firefox)或智慧電視 App 若硬編碼了 Cloudflare/Google 的 HTTPS DNS IP(443 埠),這些流量為標準 HTTPS 流量,Port 53 重定向無法影響它們。
建議改善方案: 若要強制阻斷所有繞過行為,需在 FW4 額外封鎖 LAN 對外存取 TCP Port 853,並拒絕常見公共 DNS 的 443 埠連線,強制讓設備退回標準 DNS。
三、檢測「區網 3C 設備經由 SmartDNS 查詢」的 Bash 指令
登入 SSH 後,可以使用以下 3 個指令來驗證系統是否運作正常:
Bash
# 1. 驗證 custom.conf 的 DoH3 伺服器是否已被 SmartDNS 載入
smartdns -f -c /etc/smartdns/smartdns.conf --check-config
# 2. 模擬區網設備進行 DNS 查詢,確認能正確返回 IP
nslookup example.com 127.0.0.1
# 3. 即時監控 SmartDNS 的查詢日誌 (在區網設備上開網頁,觀察是否有發起 Control D / DoH3 的查詢紀錄)
logread -e smartdns -f