顯示具有 Bind9 標籤的文章。 顯示所有文章
顯示具有 Bind9 標籤的文章。 顯示所有文章

9月 12, 2023

設定 BIND9 伺服器

關於 BIND 的設定之前(2014)有寫過一篇,不過年代久遠。兩相對照語法,其實架構沒太大改變。現在都用免費託管方案 Cloudflare DNS 顯少自己維運,畢竟還是有機會被打爆。

/etc/bind# vim named.conf.local

zone "example.com" in {
  type master;
  file "/etc/bind/db.example.com";
};

/etc/bind# vim db.example.com

$TTL    86400
$ORIGIN example.com.    ; base domain-name

@  IN  SOA  dns.example.com. admin.example.com. (
   20230909    ; Serial
   43200       ; Refresh
   3600        ; Retry
   1209600     ; Expire
   180 )       ; Minimum TTL

; Nameservers
@                  IN  NS  dns.example.com.;

; Records
dns.example.com.   IN  A   [IP];
test.example.com.  IN  A   [IP];

/etc/bind# vim named.conf.options

options {
  directory "/var/cache/bind";
  dnssec-validation auto;
  
  auth-nxdomain yes;    # conform to RFC1035
  listen-on-v6 { none; };
  listen-on port 53 { any; };
  allow-query { any; };
  allow-query-cache { none; };
  recursion no; 
  also-notify { };
};

3月 04, 2014

設定 BIND9 伺服器

BIND9 有點吃記憶體,如果要跑在小型機器上的話,最好改用其他替他方案(如:NSD, Name Server Daemon),稍微講一下 BIND 裝好之後要設定的部份。這邊假設:委派 sub.domain.net 網域給 dns.domain.net 解析。

1. 在 named.conf.options 中加入全域設定
options {
  forwarders {
    8.8.8.8;
  };
  recursion no;
  version "[SECURED]";
};
2. 在 named.conf.local 加入代管 Zone 名稱
zone "sub.domain.net" in {
  type master;
  file "/etc/bind/db.sub.domain.net";
};
3. 新增 Zone 檔案 (即:db.sub.domain.net)
$TTL 604800
@    IN  SOA   dns.domain.net. root.localhost. (
     2014030301   ; Serial
     1200         ; Refresh
     7200         ; Retry
     2419200      ; Expire
     86400 )      ; Negative Cache TTL
;  
@     IN  NS    dns.domain.net.
@     IN  MX    10  mail
@     IN  A     [ IP of sub.domain.net ]
dns   IN  A     [ IP of dns.domian.net ]
mail  IN  A     [ IP of Mail Server ]
4. 重新載入 BIND 服務