2018年8月20日 星期一

Ubuntu Bind subDomain設定

編輯 /etc/bind/named.conf.local

//master host
zone "demo.domain" {
type master;
file "/路徑/你的檔名";
// 若有slave主機,在這裡新增slave的IP
allow-transfer { 192.168.100.10; }; 
};

//slave host
zone "demo.domain" {
      type slave;
      file "/路徑/你的檔名";
      // master主機的IP
      masters { 192.168.100.254; };
};

//subdomain
zone "sub.demo.domain" {
type master;
file "/路徑/你的檔名";
};

編輯主網域的設定檔
$TTL    86400

@       IN      SOA     dns1.demo.domain. root.demo.domain. (
                     2018082001         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
;
@       IN      NS      dns1.demo.domain.
@       IN      A       192.168.118.232
dns1    IN      A       192.168.118.232
www     IN      A       2.3.4.5
mail    IN      A       5.6.7.8
sub     IN      NS      dns1.sub.demo.domain. //子網域NS記錄
ns.sub  IN      A       192.168.118.232  //子網域A記錄


編輯子網域的設定檔,添加需要的記錄
$TTL    86400

@       IN      SOA     dns1.sub.demo.domain. root.sub.demo.domain. (
                     2018082001         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
;
@       IN      NS      dns1.sub.demo.domain.
@       IN      A       11.12.13.14
dns1    IN      A       192.168.118.232
www     IN      A       11.12.13.14
o365    IN      A       100.101.102.103

重新啟動bind!