Linux下DNS服务器配置

Linux下DNS服务器配置

简要描述各种DNS服务器的配置方法。包括正向解析DNS服务器、逆向解析DNS服务器、主从DNS服务器。

实验环境整体配置

关闭SElinux

setenfore 0

清空防火墙

iptables -F

修改主配置文件 /etc/named.conf

#监听本机外网端口
listen-on port 53 { 127.0.0.1;192.168.45.202; };
#不监听ipv6
//listen-on-v6 port 53 { ::1; };
#允许查询
allow-query     { any; };
#关闭dnssec
dnssec-enable no;
dnssec-validation no;

配置正向解析DNS服务器配置

修改zone配置 /etc/named.rfc1912.zones

#增加zone文件
zone "easylinux.com" IN {
    type master;
    file "easylinux.com.zone";
    allow-update { none;  };
};

添加easylinux.com.zone文件至 /var/named

$TTL 86400
$ORIGIN easylinux.com.

@       IN      SOA     easylinux.com.  nsadmin.easylinux.com. (
        20170528
        2H
        1M
        1W
        1D
)
        IN      NS      ns1.easylinux.com.
        IN      NS      ns2.easylinux.com.
        IN      MX      10      mx.easylinux.com.
ns1     IN      A       192.168.45.100
ns2     IN      A       192.168.45.101
mx      IN      A       192.168.45.102
www     IN      A       192.168.45.201
web     IN      CNAME   www

验证解析

~]# dig easylinux.com. @192.168.45.202

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> easylinux.com. @192.168.45.202
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48423
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;easylinux.com.            IN    A

;; AUTHORITY SECTION:
easylinux.com.        86400    IN    SOA    easylinux.com. nsadmin.easylinux.com. 20170528 7200 60 604800 86400

;; Query time: 0 msec
;; SERVER: 192.168.45.202#53(192.168.45.202)
;; WHEN: Mon May 22 11:49:28 2017
;; MSG SIZE  rcvd: 75

[root@CentOS68every named]# host easylinux.com. @192.168.45.202
host: couldn't get address for '@192.168.45.202': failure
[root@CentOS68every named]# host easylinux.com. 192.168.45.202
Using domain server:
Name: 192.168.45.202
Address: 192.168.45.202#53
Aliases: 

easylinux.com mail is handled by 10 mx.easylinux.com.

配置逆向解析DNS

修改zone配置 /etc/named.rfc1912.zones

zone "45.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.45.zone";
        allow-update { none;  };
};

添加192.168.45.zone文件至 /var/named
$TTL 86400
$ORIGIN 45.168.192.in-addr.arpa.

@       IN      SOA     ns1.easylinux.com.      nsadmin.easylinux.com. (
                20170528
                2H
                1M
                1W
                1D
)
                IN      NS      ns1.easylinux.com.
                IN      NS      ns2.easylinux.com.
192.168.45.100  IN      PTR     ns1.easylinux.com.
192.168.45.101  IN      PTR     ns2.easylinux.com.
192.168.45.102  IN      PTR     mx.easylinux.com.
192.168.45.201  IN      PTR     www.easylinux.com.

验证解析

~]# dig -x 192.168.45.201 @192.168.45.202

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> -x 192.168.45.201 @192.168.45.202
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22989
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;201.45.168.192.in-addr.arpa.    IN    PTR

;; AUTHORITY SECTION:
45.168.192.in-addr.arpa. 86400    IN    SOA    ns1.easylinux.com. nsadmin.easylinux.com. 20170528 7200 60 604800 86400

;; Query time: 1 msec
;; SERVER: 192.168.45.202#53(192.168.45.202)
;; WHEN: Mon May 22 12:06:51 2017
;; MSG SIZE  rcvd: 106

配置主从服务器

配置解析easylinux.com.的从服务器

增加一个从zone配置 /etc/named.rfc1912.zones

zone "easylinux.com" IN {
    type slave;
    file "slaves/easylinux.com.zone";
    masters { 192.168.45.202; };
};

查看是否自动生成zone文件

~]# ls /var/named/slaves/
easylinux.com.zone

验证配置

~]# dig www.easylinux.com @192.168.45.203

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6 <<>> www.easylinux.com @192.168.45.203
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28361
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;www.easylinux.com.        IN    A

;; ANSWER SECTION:
www.easylinux.com.    86400    IN    A    192.168.45.201

;; AUTHORITY SECTION:
easylinux.com.        86400    IN    NS    ns2.easylinux.com.
easylinux.com.        86400    IN    NS    ns1.easylinux.com.

;; ADDITIONAL SECTION:
ns1.easylinux.com.    86400    IN    A    192.168.45.100
ns2.easylinux.com.    86400    IN    A    192.168.45.101

;; Query time: 1 msec
;; SERVER: 192.168.45.203#53(192.168.45.203)
;; WHEN: Fri May 26 18:01:36 2017
;; MSG SIZE  rcvd: 119

原创文章,作者:easyTang,如若转载,请注明出处:http://www.178linux.com/77301

(0)
easyTangeasyTang
上一篇 2017-05-31
下一篇 2017-06-01

相关推荐

  • 上下文管理练习(为加法函数计时)

    上下文管理(为加法函数计时) 为加法函数计时 使用装饰器显示该函数的执行时长 使用上下文管理显示该函数的执行时长 装饰器实现 import time import datetime from functools import wraps def logger(fn): @wraps(fn) # wraps(fn)(wrapper) def wrapper(*…

    2017-11-18
  • 初窥门径之脚本书写

    一、几个脚本的编写: 1、编写脚本/root/bin/systeminfo.sh,显示当前主机系统信息,包括主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小。 #!/bin/bash echo "HOSTNAME: $HOSTNAME" echo "IPV4 A…

    Linux干货 2016-08-15
  • NFS服务器设置

    一、NFS的相关概念     NFS(Network File System)即网络文件系统的缩写,由Sun公司研发,其目的是为了解决网络文件共享的问题。用户可以实现像挂载本地文件系统一样挂载NFS服务器的共享目录;其具有配置简单、使用高效的特点,但只能在Linux系统使用,不能跨平台使用。 &nb…

    Linux干货 2015-06-25
  • 第二十周作业

    1、用Keepalived实现nginx与lvs的高可用集群; lvs+keepalived: 1)后端两台rs上安装web服务并创建探测页面 ~]# yum install nginx -y ~]# systemctl start nginx.service ~]# vim /usr/share/nginx/html/index.html <h1&g…

    2017-07-03
  • 无网不利

                    网络是主机之间交互的必备条件。联网就是将主机互联来形成网络,使得网络中的主机得以交换信息。       &n…

    2017-08-19
  • 马哥教育网络班N22期+第3周课程练习

    马哥教育网络班N22期+第3周课程练习 1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 示例: [root@Red Hat Enterprise Linux Desktop]# who | cut -d' &#039…

    Linux干货 2016-08-29

评论列表(1条)

  • renjin
    renjin 2017-06-02 16:58

    主要介绍了dns正向解析,反向解析及dns的主从配置,内容介绍的很详细。排版也很好!