架構師成長之路6.5 DNS服務器搭建(添加記錄、負載均衡、DNS視圖)

點擊返回架構師成長之路html

架構師成長之路6.5 DNS服務器搭建(添加記錄、負載均衡、DNS視圖)

 部署主DNS : 點擊
 部署從DNS : 點擊服務器

1.添加A記錄、CNAME記錄、MX記錄、PTR記錄

1.1 添加A記錄

編輯主DNS : /var/named/chroot/etc/carlos.com.zone,在文件末尾添加一條記錄架構

\$ORIGIN .    
\$TTL 3600       ; 1 hour
carlos.com                  IN SOA  op.Carlos.com. dns.carlos.com. (
                                2003       ; serial 
                                900        ; refresh (15 minutes) 
                                600        ; retry (10 minutes) 
                                86400      ; expire (1 day) 
                                3600       ; minimum (1 hour)#TTL
                                )
                        NS      op.carlos.com.
\$ORIGIN carlos.com.
shanks              A       1.2.3.4
  op                A       1.2.3.4
  a                  A     192.168.122.100  

 注意:負載均衡

  • 將serial值+1 , 從DNS才能主動同步
  • 執行rndc reload命令
  • 分別對主從DNS解析下:host a.carlos.com 127.0.0.1結果應該是192.168.122.100

1.2.添加CNAME記錄

 編輯主DNS : /var/named/chroot/etc/carlos.com.zone,在文件末尾添加一條記錄測試

\$ORIGIN .    
\$TTL 3600       ; 1 hour
carlos.com                  IN SOA  op.Carlos.com. dns.carlos.com. (
                                2004       ; serial 
                                900        ; refresh (15 minutes) 
                                600        ; retry (10 minutes) 
                                86400      ; expire (1 day) 
                                3600       ; minimum (1 hour)#TTL
                                )
                        NS      op.carlos.com.
\$ORIGIN carlos.com.
shanks              A       1.2.3.4
  op                  A        1.2.3.4
  a                    A        192.168.122.100
cname          CNAME    a.carlos.com.   

 注意:spa

  • 將serial值+1 , 從DNS才能主動同步
  • 執行rndc reload命令
  • 分別對主從DNS解析下:host cname.carlos.com 127.0.0.1結果應該是192.168.122.100

1.3.添加MX記錄

 編輯主DNS :/var/named/chroot/etc/carlos.com.zone,在文件末尾添加一條記錄htm

\$ORIGIN .    
\$TTL 3600       ; 1 hour
carlos.com                  IN SOA  op.Carlos.com. dns.carlos.com. (
                                2005       ; serial 
                                900        ; refresh (15 minutes) 
                                600        ; retry (10 minutes) 
                                86400      ; expire (1 day) 
                                3600       ; minimum (1 hour)#TTL
                                )
                        NS      op.carlos.com.
\$ORIGIN carlos.com.
shanks              A       1.2.3.4
  op                  A        1.2.3.4
  a                    A        192.168.122.100
cname          CNAME    a.carlos.com. 
MX                 MX 5    1 92.168.122.101

  注意:blog

  • 將serial值+1 , 從DNS才能主動同步
  • 執行rndc reload命令
  • 分別對主從DNS解析下:host mx.carlos.com 127.0.0.1結果應該是192.168.122.100

1.4.添加PTR記錄

  編輯主DNS :/var/named/chroot/etc/view.conf,加入ptrzone配置dns

zone "168.192.in-addr.arpa" {
        type    master;
        file    "168.192.zone";
        allow-transfer {
                10.6.0.254;
        };
        notify  yes;
        also-notify {
                10.6.0.254;
        };
  }; 

 編輯主DNS :/var/named/chroot/etc/168.192.zone部署

$TTL 3600       ; 1 hour
@                  IN SOA  op.carlos.com. dns.carlos.com. (
                                2006       ; serial
                                900        ; refresh (15 minutes)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                3600       ; minimum (1 hour)
                                )
                        NS      op.carlos.com.
102.122     IN      PTR     a.carlos.com.

 修改168.192.zone文件的屬性

chown named.named 168.192.zone
rndc reload

 編輯從DNS:/var/named/chroot/etc/view.conf,加入ptr的zone配置

zone "168.192.in-addr.arpa" {
             type    slave;
             masters {10.5.35.14; };
             file    "slave.168.192.zone";
        };

 從DNS執行rndc reload命令。

    分別對兩臺機器作ptr記錄的解析   host 192.168.122.102 127.0.0.1     結果應爲a.carlos.com  。

2.  經過DNS實現服務的負載均衡

  編輯主DNS:/var/named/chroot/etc/carlos.com.zone,在文件末尾添加一條記錄

\$ORIGIN .    
\$TTL 3600       ; 1 hour
carlos.com                  IN SOA  op.Carlos.com. dns.carlos.com. (
                                2007       ; serial 
                                900        ; refresh (15 minutes) 
                                600        ; retry (10 minutes) 
                                86400      ; expire (1 day) 
                                3600       ; minimum (1 hour)#TTL
                                )
                        NS      op.carlos.com.
\$ORIGIN carlos.com.
shanks              A       1.2.3.4
  op                  A        1.2.3.4
  a                    A        192.168.122.100
cname          CNAME    a.carlos.com. 
MX                 MX 5    192.168.122.101
 a                     A       192.168.122.101

  注意:

  • 將serial值+1 , 從DNS才能主動同步
  • 執行rndc reload命令
  • 分別對主、從DNS解析下:host a.carlos.com 127.0.0.1結果應該是192.168.122.100和192.168.122.101

3.  配置DNS視圖(智能DNS)

配置主DNS: /var/named/chroot/etc/named.conf,在include上面添加

acl group1 {
  10.5.35.14;
};

acl group2 {
  10.5.35.15;
}; 

配置主DNS: /var/named/chroot/etc/view.conf

view "GROUP1" {
  match-clients { group1; };
  zone "viewcarlos.com" {
    type master;
    file "group1.viewcarlos.com.zone";
  };
};

view "GROUP2" {
  match-clients { group2; };
  zone "viewcarlos.com" {
    type master;
    file "group2.viewcarlos.com.zone";
  };
};

配置主DNS:  /var/named/chroot/etc/group1.viewcarlos.com.zone 

$ORIGIN .
$TTL 3600       ; 1 hour
viewcarlos.com                  IN SOA  op.viewcarlos.com. dns.viewcarlos.com. (
                                2008       ; serial
                                900        ; refresh (15 minutes)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                3600       ; minimum (1 hour)
                                )
                        NS      op.viewcarlos.com.
$ORIGIN viewcarlos.com.
op                 A       192.168.122.1
view               A       192.168.122.1

修改文件所屬,加載配置。

chown named.named /var/named/chroot/etc/group*.zone
rndc reload

分別在主機A與B上作view.viewcarlos.com的域名解析測試,結果應爲主機A上是192.168.122.1,主機B上是192.168.122.2

....

相關文章
相關標籤/搜索