配置dns服务的正反向解析

配置dns的正向解析

1,安装包

root@localhost ~]# mount /dev/sr0 /mnt                #挂载
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# yum install bind -y                #安装bind
Complete!

2,配置

[root@localhost ~]# vim /etc/named.conf
[root@localhost ~]# cat /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
    listen-on port 53 { 192.168.220.128;};
#    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";
#    secroots-file    "/var/named/data/named.secroots";
#    recursing-file    "/var/named/data/named.recursing";
    allow-query     { any; };

    /* 
     - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
     - If you are building a RECURSIVE (caching) DNS server, you need to enable 
       recursion. 
     - If your recursive DNS server has a public IP address, you MUST enable access 
       control to limit queries to your legitimate users. Failing to do so will
       cause your server to become part of large scale DNS amplification 
       attacks. Implementing BCP38 within your network would greatly
       reduce such attack surface 
    */
#    recursion yes;

#    dnssec-enable yes;
#    dnssec-validation yes;

#    managed-keys-directory "/var/named/dynamic";

#    pid-file "/run/named/named.pid";
#    session-keyfile "/run/named/session.key";

    /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */
#    include "/etc/crypto-policies/back-ends/bind.config";
};

#logging {
#        channel default_debug {
#                file "data/named.run";
#                severity dynamic;
#        };
#};

zone "qq.com" IN {                        #正向解析配置
        type master;                        #主服务器配置
        file "named.qq.com";
};

zone "220.168.192.in-addr.arpa" IN {    #  反向解析配置
    type master;
    file "named.192.168.220";
};

#include "/etc/named.rfc1912.zones";
#include "/etc/named.root.key";

[root@localhost ~]# vim /var/named/named.qq.com 
[root@localhost ~]# cat /var/named/named.qq.com 
$TTL 1D
@     IN    SOA   @   admin.qq.com. (
                                   2022090100
                                   1D
                                   1H
                                   3D
                                   1D)
@     IN    NS    dns.qq.com.
dns   IN    A     192.168.220.128
www   IN    A     192.168.220.10
en    IN    A     192.168.220.20
ftp   IN    A     192.168.220.30
fff   IN    CNAME ftp 
[root@localhost ~]# vim /var/named/named.192.168.220
[root@localhost ~]# cat /var/named/named.192.168.220

$TTL 1D
@     IN    SOA   @   admin.qq.com. (
                                   2022090100
                                   1D
                                   1H
                                   3D
                                   1D)
@     IN    NS    dns.qq.com.
128   IN    PTR   dns.qq.com.
10    IN    PTR   www.qq.com.
20    IN    PTR   en.qq.com.
30    IN    PTR   ftp.qq.com.
 

[root@localhost ~]# systemctl restart named    #重启服务

[root@localhost ~]# vim /etc/resolv.conf 
[root@localhost ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search localdomain
nameserver 192.168.220.128
 

3,测试

[root@localhost ~]# nslookup www.qq.com
Server:        192.168.220.128
Address:    192.168.220.128#53

Name:    www.qq.com
Address: 192.168.220.10
 

配置dns的反向解析

[root@localhost ~]# nslookup 192.168.220.20
20.220.168.192.in-addr.arpa    name = en.qq.com.

[

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值