Linux 下 DHCP 与 DNS 集成的实用配置指南

一、方案总览与适用场景
二、方案一 ISC DHCP 与 BIND9 动态更新(含安全密钥)
key "dhcp_dns_update" {algorithm hmac-sha256;secret "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";};options {directory "/var/named";allow-update { key dhcp_dns_update; };};zone "example.com" {type master;file "/etc/bind/zones/db.example.com";allow-update { key dhcp_dns_update; };};zone "1.168.192.in-addr.arpa" {type master;file "/etc/bind/zones/db.192.168.1";allow-update { key dhcp_dns_update; };};$TTL 604800@ INSOA ns1.example.com. admin.example.com. (3 ; Serial604800 ; Refresh 86400 ; Retry 2419200 ; Expire604800 ) ; Negative Cache TTL@ INNSns1.example.com.ns1 INA 192.168.1.2$TTL 604800@ INSOA ns1.example.com. admin.example.com. (3 ; Serial604800 ; Refresh 86400 ; Retry 2419200 ; Expire604800 ) ; Negative Cache TTL@ INNSns1.example.com.option domain-name "example.com";option domain-name-servers 192.168.1.2;ddns-update-style interim;update-static-leases on;key "dhcp_dns_update" {algorithm hmac-sha256;secret "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";};zone example.com. {primary 127.0.0.1;key dhcp_dns_update;}zone 1.168.192.in-addr.arpa. {primary 127.0.0.1;key dhcp_dns_update;}subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.10 192.168.1.100;option routers 192.168.1.1;default-lease-time 600;max-lease-time 7200;}三、方案二 dnsmasq 一体化配置
interface=eth0dhcp-range=192.168.1.10,192.168.1.100,255.255.255.0,12hdhcp-option=option:router,192.168.1.1dhcp-option=option:domain-name,"example.com"dhcp-option=option:dns-server,192.168.1.2# 可选:为已知主机名做静态映射# address=/host1.example.com/192.168.1.10四、方案三 PowerDNS 与 ISC DHCP 集成(数据库后端)
launch=gmysqlgmysql-host=127.0.0.1gmysql-dbname=pdnsgmysql-user=pdnsgmysql-password=YourStrongPassword五、客户端与排错要点