遇见心流:Edwiin.cn

9 object(s)
 

Centos7环境中搭建DNS并配置正反向解析

本文仅简易配置流程,详细配置转:https://www.edwiin.cn/post-213.html

0x01 服务安装

yum install bind -y

0x02 修改named.conf

vim /etc/named.conf

//监听端口,默认为127.0.0.1,修改为any,监听所有地址的53端口,或删除此行配置,默认监听所有地址的53端口

 listen-on port 53 { any; };,

//允许查询DNS服务器的来源,默认为localhost,修改为any代表允许所有来源,或删除此行配置,默认允许所有来源

 allow-query     { any; };
vim /etc/named.rfc1912.zones
    zone "hello.com" IN {
        type master;
        file "mydomain.com.zone";
    };
    zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "mydomain.com.local";
    };

0x03 创建正解析文件

cd /var/named
cp -p named.localhost mydomain.com.zone
$TTL 1D
@       IN SOA  mydomain.com.  admin.mydomain.com (
                                        1       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@        IN    NS   dns.mydomain.com.
dns     IN     A    192.168.1.125
@        IN    A     192.168.1.122

0x04 创建反解析文件

cp -p named.localhost mydomain.com.local
$TTL 1D
@       IN SOA  mydomain.com.  admin.mydomain.com (
                                        1       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@        IN    NS     dns.mydomain.com.
125     IN    PTR   dns.mydomain.com.
122     IN    PTR   mydomain.com.

0x05 主配置文件语法检查

named-checkconf -z /etc/named.conf

0x06 权限修改

chown named mikuac.cn.zone
chown named mikuac.cn.loacl

0x07 端口开放

firewall-cmd --permanent --add-port=53/tcp
firewall-cmd --permanent --add-port=53/udp
firewall-cmd --reload

0x08 服务启动

systemctl start named