1.安裝bind9
sudo apt install bind9
2.配置/etc/bind/named.conf.options文件
sudo nano /etc/bind/named.conf.options
內容如下:
// cat /etc/bind/named.conf.options
options {
// 這個目錄決定了我們域名解析數據配置的目錄,記住這個目錄,后面會用到
directory "/var/cache/bind";
// 配置 bind9 上游的 DNS 服務器
// 如果 bind9 中找不到某個域名的解析,會把域名解析請求發送到上游 DNS 服務器
forwarders {
114.114.114.114;
};
allow-query {
0.0.0.0/0;
};
// 因為 114.114.114.114安全性不是很高?????
// 需要關閉下面這幾個安全相關參數才可以使用
dnssec-enable no;
dnssec-validation no;
dnssec-lookaside auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
3.配置/etc/bind/named.conf.local
sudo nano /etc/bind/named.conf.local
內容如下:
// cat /etc/bind/named.conf.local
// 這里定義在 bind9 中添加 dns.com 解析
zone "dns.com"{
type master;
// 這里定義了在哪個文件中配置了 IP 信息
file "db.dns.com";
};
4.配置 /var/cache/bind/db.dns.com 文件,把db.empty復制過來
sudo cp /etc/bind/db.empty /var/cache/bind/db.dns.com
在最后添加:
@ IN A 192.168.6.4
5.重啟bind9
# 重新載入配置
sudo systemctl daemon-reload
# 重啟 bind9
sudo systemctl restart bind9.service
結束