1. 程式人生 > >dns服務之bind淺談

dns服務之bind淺談

date workman yum directory title gen mem 虛擬 添加

目錄

  • 1、 安裝需要的軟件
  • 2.配置bind
  • 3.添加正、反向解析域
    • 3.1指向生效的配置文件
    • 3.2生成配置文件cljhfy.com.zone163.168.192.zone
  • 4.驗證

1、 安裝需要的軟件

[[email protected] ~]# yum -y install bind*

# 開機啟動
[[email protected] ~]# systemctl enable named

2.配置bind

[[email protected] ~]# vim /etc/named.conf

options {
        listen-on port 53 { any; };//將大括號內的內容改成any
        //listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };//將大括號內的內容改成any

3.添加正、反向解析域

3.1指向生效的配置文件

[[email protected] ~]# vim /etc/named.rfc1912.zones 
//正向
zone "cljhfy.com" IN {
        type master;
        file "cljhfy.com.zone";
        allow-update { none; };
};
//反向
zone "163.168.192.in-addr.arpa" IN {
        type master;
        file "163.168.192.zone";
        allow-update { none; };
};
~                                                                          
~                            

3.2生成配置文件cljhfy.com.zone163.168.192.zone

[[email protected] ~]# cd /var/named/

[[email protected] named]# vim cljhfy.com.zone 

$TTL 1D
@  IN  SOA cljhfy.com.   admin.cljhfy.com. (
            0   ; serial  
            1D  ; refresh  
            1H  ; retry  
            1W  ; expire 
            3H )    ; minimum 
        NS  www.cljhfy.com.
        NS  ftp.cljhfy.com.
        A  127.0.0.1
        AAAA    ::1
        MX  10 mx.cljhfy.com.
ttl IN  A   192.168.163.128
www     IN  A   192.168.163.128
bbs IN  CNAME   www
mx  IN  A   192.168.163.128
ftp IN  A   192.168.163.128

[[email protected] named]# vim 163.168.192.zone 

$TTL 1D
@       IN      SOA     cljhfy.com. admin.cljhfy.com. (
                         0
                         2H
                         10M
                         7D
                         1D )
        NS  ttl.cljhfy.com.
        A   127.0.0.1
        AAAA    ::1
128  IN      PTR     cljhfy.com.
128  IN      PTR     www.cljhfy.com.
128  IN      PTR     ftp.cljhfy.com.
128  IN      PTR     mx.cljhfy.com.
~                                           

//註意:一點要給權限
[[email protected] named]# chown named.named cljhfy.com.zone 
[[email protected] named]# chown named.named 163.168.192.zone 
[[email protected] named]# chmod 755 cljhfy.com.zone 
[[email protected] named]# chmod 755 163.168.192.zone 

//啟動服務
[[email protected] named]# systemctl start named-chroot

4.驗證

//我是在另一臺虛擬主機上實驗

[[email protected] ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.163.128
//dns指向我設置好的IP
[[email protected] ~]# nslookup 192.168.163.128
Server:     192.168.163.128
Address:    192.168.163.128#53

128.163.168.192.in-addr.arpa    name = ftp.cljhfy.com.
128.163.168.192.in-addr.arpa    name = cljhfy.com.
128.163.168.192.in-addr.arpa    name = mx.cljhfy.com.
128.163.168.192.in-addr.arpa    name = www.cljhfy.com.

[[email protected] ~]# nslookup cljhfy.com
Server:     192.168.163.128
Address:    192.168.163.128#53

Name:   cljhfy.com
Address: 127.0.0.1

[[email protected] ~]# nslookup ftp.cljhfy.com
Server:     192.168.163.128
Address:    192.168.163.128#53

Name:   ftp.cljhfy.com
Address: 192.168.163.128

[[email protected] ~]# nslookup mx.cljhfy.com
Server:     192.168.163.128
Address:    192.168.163.128#53

Name:   mx.cljhfy.com
Address: 192.168.163.128

[[email protected] ~]# nslookup www.cljhfy.com
Server:     192.168.163.128
Address:    192.168.163.128#53

Name:   www.cljhfy.com
Address: 192.168.163.128
//可以使用

dns服務之bind淺談