Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> DNS 伺服器

Linux 動態 DNS (DDNS) 架設實戰:BIND 9 + DHCP 3.0 安全整合

編輯:DNS 伺服器

手動維護 DNS 區域檔案在大型網路不切實際。DDNS(動態 DNS)讓 DHCP 伺服器在租約分配/釋放時自動更新 DNS 記錄。本文詳細實作基於 Slackware Linux 9.0、BIND 9.2.2、DHCP 3.0pl2 的安全 DDNS 環境,核心在於 HMAC-MD5 金鑰驗證機制。

環境需求

  • BIND 8+(支援動態更新)
  • DHCP Server 3.0+(完整支援 DDNS 協定)
  • 本文環境:Slackware 9.0,同機運行 DNS + DHCP

步驟一:產生 TSIG 金鑰

# dnssec-keygen -a HMAC-MD5 -b 128 -n USER myddns
Kmyddns.+157+37662

產生兩個檔案:

  • Kmyddns.+157+37662.key(公開金鑰)
  • Kmyddns.+157+37662.private(私鑰,含共享密鑰 4gEF1Mkmn5hrlwYUeGJV3g==)

此共享密鑰將作為 DHCP 向 DNS 發動動態更新的憑證。

步驟二:修改 DNS 主配置 /etc/named.conf

options {
  directory "/var/named";
};

zone "." IN { type hint; file "caching-example/named.ca"; };

zone "localhost" IN { type master; file "caching-example/localhost.zone"; allow-update { none; }; };

zone "0.0.127.in-addr.arpa" IN { type master; file "caching-example/named.local"; allow-update { none; }; };

key "myddns" {
  algorithm HMAC-MD5.SIG-ALG.REG.INT;
  secret "4gEF1Mkmn5hrlwYUeGJV3g==";
};

zone "tcbuu.cn" IN {
  type master;
  file "tcbuu.cn";
  allow-update { key myddns; };
};

zone "1.22.10.in-addr.arpa" IN {
  type master;
  file "tcbuu.cn.arpa";
  allow-update { key myddns; };
};

關鍵設定解析

  • key "myddns" 區塊定義共享密鑰與演算法
  • allow-update { key myddns; }; 僅允許持有此金鑰的實體(DHCP 伺服器)動態更新該區域
  • 相較舊式 allow-update { 192.168.1.0/24; }; 僅限 IP 方式,金鑰驗證安全性大幅提升
  • 可為不同區域定義不同金鑰,實現細粒度權限控制

步驟三:啟動 DNS 服務

# named

檢查 /var/log/messages 確認無錯誤啟動。

後續整合 DHCP(下篇重點)

DHCP 端需在 dhcpd.conf 中:

  • 引用相同金鑰:key "myddns" { algorithm hmac-md5; secret "4gEF1Mkmn5hrlwYUeGJV3g=="; };
  • 啟用 DDNS:ddns-update-style interim; / ddns-updates on;
  • 指定更新區域與金鑰:zone tcbuu.cn. { primary 127.0.0.1; key myddns; }

完成雙端配置後,用戶端取得 DHCP 租約即自動註冊 A/PTR 記錄,釋放時自動移除,實現零人工介入的動態名稱管理。

Copyright © Windows教程網 All Rights Reserved