Linux服务-bind

Linux服务-Bind

1.安装bind

[root@cwh ~]# yum -y install bind*
# 设置开机启动
[root@cwh ~]# systemctl enable named

2.配置bind

[root@cwh ~]# 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 指向生效的配置文件

[root@localhost ~]# vim /etc/named.rfc1912.zones
//正向
zone "cwhbind.com" IN {
        type master;
        file "cwhbind.com.zone";
        allow-update { none; };
};

//反向
zone "112.168.192.in-addr.arpa" IN {
        type master;
        file "112.168.192.zone";
        allow-update { none; };
};

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

[root@localhost named]# vim cwhbind.com.zone 
$TTL 1D
@  IN  SOA cwhbind.com.   admin.cwhbind.com. (
            0   ; serial  
            1D  ; refresh  
            1H  ; retry  
            1W  ; expire 
            3H )    ; minimum 
        NS  www.cwhbind.com.
        NS  ftp.cwhbind.com.
        A  127.0.0.1
        AAAA    ::1
        MX  10 mx.cwhbind.com.
ttl IN  A   192.168.112.149 //写配置bind的本机IP
www     IN  A   192.168.112.149 
bbs IN  CNAME   www
mx  IN  A   192.168.112.149
ftp IN  A   192.168.112.149


[root@localhost named]# vim 112.168.192.zone
$TTL 1D
@       IN      SOA     cwhbind.com. admin.cwhbind.com. (
                         0
                         2H
                         10M
                         7D
                         1D )
        NS  ttl.cwhbind.com.
        A   127.0.0.1
        AAAA    ::1
149  IN      PTR     cwhbind.com.
149  IN      PTR     www.cwhbind.com.
149 IN      PTR     ftp.cwhbind.com.
149  IN      PTR     mx.cwhbind.com.

//配置完成后更改属主和属组还有给配置文件权限
[root@localhost named]# chown named.named cwhbind.com.zone 
[root@localhost named]# chown named.named 112.168.192.zone 
[root@localhost named]# chmod 755 cwhbind.com.zone 
[root@localhost named]# chmod 755 112.168.192.zone 

//启动服务
[root@localhost named]# systemctl start named-chroot

4.验证

[root@150 ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.112.149
//dns指向我设置好的IP
[root@150 ~]# nslookup 192.168.112.149
Server:     192.168.112.149
Address:    192.168.112.149#53

149.112.168.192.in-addr.arpa    name = ftp.cwhbind.com.
149.112.168.192.in-addr.arpa    name = cwhbind.com.
149.112.168.192.in-addr.arpa    name = mx.cwhbind.com.
149.112.168.192.in-addr.arpa    name = www.cwhbind.com.

[root@150 ~]# nslookup cwhbind.com
Server:     192.168.112.149
Address:    192.168.112.149#53

Name:   cwhbind.com
Address: 127.0.0.1

[root@150 ~]# nslookup ftp.cwhbind.com
Server:     192.168.112.149
Address:    192.168.112.149#53

Name:   ftp.cwhbind.com
Address: 192.168.112.149

[root@150 ~]# nslookup mx.cwhbind.com
Server:     192.168.112.149
Address:    192.168.112.149#53

Name:   mx.cwhbind.com
Address: 192.168.112.149

[root@150 ~]# nslookup www.cwhbind.com
Server:     192.168.112.149
Address:    192.168.112.149#53

Name:   www.cwhbind.com
Address: 192.168.112.149
//可以使用
posted @ 2019-05-05 09:46  春秋义甲  阅读(848)  评论(0编辑  收藏  举报