軟體工程師的小事:到底要不要 Close

在 CentOS 8 Stream 作業系統使用 Bind 作為 DNS 伺服器

環境說明

作業系統使用 CentOS 8 Stream 並僅安裝 Server 功能

安裝並設定 DNS 服務

安裝 Bind

yum install bind

設定 DNS 服務自動啟動

systemctl enable named

檢查 DNS 服務的狀態

systemctl status named

修改 named.conf 檔案指定正解檔案位址

options {
    listen-on port 53 { [外部 IP Address]; };
    ...
    allow-query     { any; };   
    ...
};

...

zone "txstudio.tw" IN {
    type master;
    file "zone-txstudio.tw";
};

在 /var/named 建立 zone-txstudio.tw 的正解設定檔案

如果要讓外面可以查詢到你設定的 DNS 服務,記得設定外部 IP 位址

$TTL    86400
@       IN      SOA     dns.txstudio.tw. txstudio.outlook.com. (
                       20191116         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400        ; Negative Cache TTL
);

@               IN      NS      dns.txstudio.tw.
@               IN      A       [外部 IP Address]
dns.txstudio.tw.        IN      A       [外部 IP Address]

設定完成後要記得重新啟動服務才會生效

備註

txstudio.outlook.com. 這個是讓其他人知道這台 DNS 管理員的連絡資訊:就是 txstudio@outlook.com

設定防火牆

在 CentOS 8 Stream 使用 firewalld 做防火牆

預設情況下是不提供存取 DNS 服務使用的 UDP 53

使用下面指令開放 DNS,並重新啟動服務

firewall-cmd --add-service=dns --permanent
firewall-cmd --reload

使用下面指令確認已設定好的服務跟開放的連接埠與協定

firewall-cmd --list-all

參考資料

留言