CentOS 7 DNS部署

CentOS 7DNS服务器架设

项目背景和要求

要保证即能够解析内网域名bigcloud.local的解析,又能解析互联网的域名。

主DNS服务器:ZZYH1.BIGCLOUD.LOCAL

辅助DNS服务器:ZZYH2.BIGCLOUD.LOCAL

包含以下域的信息:

1bigcloud.local域的信息:

FQDN IP地址 备注
zzyh1.bigcloud.local 192.168.188.15 DNS1服务器
zzyh2.bigcloud.local 192.168.188.16 DNS2服务器
ftp.bigcloud.local 192.168.188.15
mailyh1.bigcloud.local 192.168.188.22
smtp.bigcloud.local 192.168.188.22
pop3.bigcloud.local 192.168.188.22
www.bigcloud.local 192.168.188.15
crm.bigcloud.local 192.168.188.15

2192.168.188.0/24192.168.189.0/24反向解析域

要求实现chroot功能,以提高安全性

实现到202.102.224.68、202.102.227.68的DNS转发。

防止非授权用户的DNS记录的枚举(防止出现类似上海烟草公司的安全隐患)。仅允许管理员在192.168.188.10上进行操作。

DNS网络配置

除了传统的修改/etc/resolv.conf之外,还有通过在ifcfg文件中添加配置的方式。

Tip: 与Windows在某个网卡中设置DNS服务器的IP地址类似

# vi/etc/sysconfig/network-scripts/ifcfg-eno16777728

# Generated by parse-kickstart

IPV6INIT=no

BOOTPROTO=static

DEVICE=eno16777728

ONBOOT=yes

TYPE=Ethernet

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

NAME="System eno16777728"

IPADDR=192.168.188.15

NETMASK=255.255.255.0

GATEWAY=192.168.188.2

DNS1=192.168.188.15

DNS2=192.168.188.16

这样,当重新启动network服务时,会生成/etc/resolv.conf中的配置

# servicenetwork restart

Restarting network (via systemctl):                        [  OK  ]

# cat/etc/resolv.conf


# Generated by NetworkManager

search bigcloud.local

nameserver 192.168.188.15

nameserver192.168.188.16

配置Yum库

[[email protected] ~]# cd /etc/yum.repos.d/

[[email protected] yum.repos.d]# ls

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo

[[email protected] yum.repos.d]#

[[email protected] yum.repos.d]# cpCentOS-Base.repo CentOS-Base.repo.origin

[[email protected] yum.repos.d]# viCentOS-Base.repo

配置内容

[base]

name=CentOS-$releasever - Base

baseurl=file:///media

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

安装DNS支持包

#yum -y installbind bind-util bind-chroot     //

[[email protected] ~]# cd /media/Packages/

[[email protected] Packages]# yum -y install bindbind-util bind-chroot

Warning: RPMDB altered outside of yum.

Installing : 32:bind-libs-9.9.4-14.el7.x86_64                             1/3

Installing : 32:bind-9.9.4-14.el7.x86_64                                  2/3

Installing : 32:bind-chroot-9.9.4-14.el7.x86_64                           3/3

Verifying  :32:bind-9.9.4-14.el7.x86_64                                  1/3

Verifying  : 32:bind-libs-9.9.4-14.el7.x86_64                             2/3

Verifying  :32:bind-chroot-9.9.4-14.el7.x86_64                           3/3

Installed:

bind.x86_64 32:9.9.4-14.el7        bind-chroot.x86_64 32:9.9.4-14.el7

Dependency Installed:

bind-libs.x86_6432:9.9.4-14.el7

Complete!

查看bind的生成包

[[email protected] ~]# rpm -qc bind

/etc/logrotate.d/named

/etc/named.conf

/etc/named.iscdlv.key

/etc/named.rfc1912.zones

/etc/named.root.key

/etc/rndc.conf

/etc/rndc.key

/etc/sysconfig/named

/var/named/named.ca

/var/named/named.empty

/var/named/named.localhost

/var/named/named.loopback

配置文件

[[email protected] ~]# cd /etc

[[email protected] etc]# cp named.confnamed.conf.origin

[[email protected] etc]# vi /etc/named.conf

[[email protected] etc]# cat /etc/named.conf、

//listen-on port 53 { 127.0.0.1; };

listen-on port 53 { any; };

//dnssec-enable yes;

//dnssec-validation yes;

dnssec-enable no;

dnssec-validation no;

配置转发地址:

forwarders {202.102.224.68; 202.102.227.68;};

allow-transfer {192.168.188.15; 192.168.188.12;};

查看状态

[[email protected] etc]# rndc status

version: 9.9.4-RedHat-9.9.4-14.el7<id:8f9657aa>

CPUs found: 1

worker threads: 1

UDP listeners per interface: 1

number of zones: 101

debug level: 0

xfers running: 0

xfers deferred: 0

soa queries in progress: 0

query logging is OFF

recursive clients: 0/0/1000

tcp clients: 0/100

server is up and running

测试一下解析

补充一下


#find / -name nslookup

/usr/bin/nslookup

#rpm -qf/usr/bin/nslookup  //查询这个命令依附于那个包

bind-utils-9.9.4-14.el7.x86_64.rpm

执行

#nslookup              //如果找不到nslookup那是因为没有安装bind-utils-9.9.4-14.el7.x86_64.rpm

> server 192.168.188.15

Default server: 192.168.188.15

Address: 192.168.188.15#53

> g.cn                                //尝试解析g.cn

Server:         192.168.188.15

Address:        192.168.188.15#53

Non-authoritative answer:

Name:  g.cn

Address: 203.208.36.17

Name:  g.cn

Address: 203.208.36.18

Name:  g.cn

Address: 203.208.36.16

Name:  g.cn

Address: 203.208.36.20

Name:  g.cn

Address: 203.208.36.19

//解析成功

添加自定义zone

自定义,修改配置文件

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

在最后添加

zone "bigcloud.local" IN {

type mester;

file "bigcloud.local.zone";

}

zone "188.168.192.in-addr.arpa"IN {

type master;

file "192.168.188.zone";

}

zone "189.168.192.in-addr.arpa"IN {

type master;

file "192.168.189.zone";

}

include"/etc/named.rfc1912.zones";

include "/etc/named.root.key";

[[email protected]]# cp named.empty bigcloud.local.zone   //修改前备份一下

[[email protected] named]# ls

bigcloud.local.zone  data    named.ca     named.localhost  slaves

chroot               dynamic  named.empty named.loopback

配置文件

[[email protected]]# vi  bigcloud.local.zone

$TTL 3H

@      IN SOA  zzyh1.bigcloud.local.  chenzhou312.blog.51cto.com (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H)    ; minimum

IN      NS           zzyh1.bigcloud.local.

IN      NS          zzyh2.bigcloud.local.

zzyh1                IN      A            192.168.188.15

zzyh2                IN      A            192.168.188.16

ftp                   IN      A            192.168.188.15

mailyh1              IN      A            192.168.188.22

smtp                  IN      CNAME        mailyh1.bigcloud.local.

pop3                  IN      CNAME        mailyh1.bigcloud.local.

www                   IN      A            192.168.188.15

crm                   IN      A            192.168.188.15

#vi192.168.188.zone

$TTL 3H

@      IN SOA  zzyh1.bigcloud.local.  chenzhou312.blog.51cto.com (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expiredgG

3H)    ; minimum

IN        NS           zzyh1.bigcloud.local.

IN        NS           zzyh2.bigcloud.local.

15      IN        PTR           zzyh1.bigcloud.local.

15      IN        PTR           ftp.bigcloud.local.

16      IN        PTR           zzyh2.bigcloud.local.

16      IN        PTR           mailyh1.bigcloud.local.

#vi192.168.189.zone

$TTL 3H

@       IN SOA zzyh1.bigcloud.local. chenzhou312.blog.51cto.com (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H)    ; minimum

IN    NS                   zzyh1.bigcloud.local.

IN    NS                   zzyh2.bigcloud.local.

www     IN    NS                   192.168.188.15

重启服务

[[email protected] named]# systemctl restartnamed.service

[[email protected] named]# service named restart

Redirecting to /bin/systemctl restart  named.service

[[email protected] named]# rndc status

version: 9.9.4-RedHat-9.9.4-14.el7<id:8f9657aa>

CPUs found: 1

worker threads: 1

UDP listeners per interface: 1

number of zones: 104

debug level: 0

xfers running: 0

xfers deferred: 0

soa queries in progress: 0

query logging is OFF

recursive clients: 0/0/1000

tcp clients: 0/100

server is up and running

设置为自动启动

# systemctl enable named


[[email protected] named]# systemctl status named

named.service - Berkeley Internet NameDomain (DNS)

Loaded: loaded (/usr/lib/systemd/system/named.service; enabled)

Active: active (running) since Mon 2014-08-25 00:36:59 CST; 3min 47s ago

MainPID: 2807 (named)

CGroup: /system.slice/named.service

a””a”2807 /usr/sbin/named -u named

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 189.168.192.in-addr.ar...

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 189.168.192.in-addr.ar...

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 1.0.0.127.in-addr.arpa...

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 1.0.0.0.0.0.0.0.0.0.0....

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: all zones loaded

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: running

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 188.168.192.in-addr.ar...

Aug 25 00:36:59 zzyh1.bigcloud.localnamed[2807]: zone 189.168.192.in-addr.ar...

Aug 25 00:36:59 zzyh1.bigcloud.localsystemd[1]: Started Berkeley Internet N....

Aug 25 00:37:00 zzyh1.bigcloud.localnamed[2807]: managed-keys-zone: No DNSKE...

Hint: Some lines were ellipsized, use -l toshow in full.

测试

# nslookup

> server192.168.188.15

Default server: 192.168.188.15

Address: 192.168.188.15#53

>www.bigcloud.local.

Server:        192.168.188.15

Address:       192.168.188.15#53

Name:  www.bigcloud.local

Address: 192.168.188.15

>smtp.bigcloud.local.

Server:        192.168.188.15

Address:       192.168.188.15#53

smtp.bigcloud.local     canonical name = mailyh1.bigcloud.local.

Name:  mailyh1.bigcloud.local

Address: 192.168.188.22

>192.168.188.15

Server:        192.168.188.15

Address:       192.168.188.15#53

15.188.168.192.in-addr.arpa     name = ftp.bigcloud.local.

15.188.168.192.in-addr.arpa     name = zzsrv1.bigcloud.local.

> exit

zzyh2上的DNS配置

安装BIND

与zzyh1上的主DNS配安装一样。

操作略。

配置

Cache Only Server

与zzyh1上的主DNS配安装一样。

操作略。

添加辅助Zone

# vi /etc/named.conf

添加如下zone信息

zone "bigcloud.local" IN {

type slave;

masters {192.168.188.15; };

file "bigcloud.local.zone";

};

zone "188.168.192.in-addr.arpa"IN {

type slave;

masters {192.168.188.15; };

file "192.168.188.zone";

};

zone "189.168.192.in-addr.arpa"IN {

type slave;

masters {192.168.188.15; };

file "192.168.189.zone";

};

修改目录权限

[[email protected] named]# ll /var/named/ -d

drwxr-x--- 6 root named 133 Aug 15 14:06/var/named/

[[email protected] named]# chmod g+w /var/named/

[[email protected] named]# ll /var/named/ -d

drwxrwx--- 6 root named 133 Aug 15 14:06/var/named/

启动服务

[[email protected] ~]# systemctl startnamed.service

Redirecting to /bin/systemctl restart  named.service

设置为自动启动

[[email protected] ~]# systemctl enable named

ln -s‘/usr/lib/systemd/system/named.service‘‘/etc/systemd/system/multi-user.target.wants/named.service‘

查看日志,检查是否有报错信息。(建议在启动时,就在另外一个会话时就打开)

# tail -f /var/log/messages

测试BIND

在zzyh1上生成了相应的zone文件

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

total 28

-rw-r--r-- 1 named named  451 Aug 15 14:58 192.168.188.zone

-rw-r--r-- 1 named named  254 Aug 15 15:05 192.168.189.zone

-rw-r--r-- 1 named named  647 Aug 15 15:16 bigcloud.local.zone

drwxr-x--- 7 root  named  56 Aug 15 14:06 chroot

drwxrwx--- 2 named named   22 Aug 15 14:19 data

drwxrwx--- 2 named named   58 Aug 15 16:20 dynamic

-rw-r----- 1 root  named 2076 Jan 28  2013 named.ca

-rw-r----- 1 root  named 152 Dec 15  2009 named.empty

-rw-r----- 1 root  named 152 Jun 21  2007 named.localhost

-rw-r----- 1 root  named 168 Dec 15  2009 named.loopback

drwxrwx--- 2 named named    6 Jun 10 16:13 slaves

[[email protected] ~]# vi /var/named/bigcloud.local.zone

添加一个A记录

test    IN A 10.0.0.1

并且将,zone的序列号增大

[[email protected] ~]# rndc reload

server reload successful

在zzyh1的日志中会看到

zone bigcloud.local/IN: sending notifiesrial 15)

client 192.168.188.16#41658 (bigcloud.loc:transfer of ‘bigcloud.local/IN‘: AXFR-style IXFR started

client 192.168.188.16#41658 (bigcloud.loc:transfer of ‘bigcloud.local/IN‘: AXFR-style IXFR ended

在zzyh2的日志中会看到

client 192.168.188.15#33856: received notifyfor zone ‘bigcloud.local‘

zone bigcloud.local/IN: Transfer started.

transfer of ‘bigcloud.local/IN‘ from192.168.188.15#53: connected using 192.168.188.16#41658

zone bigcloud.local/IN: transferred serial15

transfer of ‘bigcloud.local/IN‘ from192.168.188.15#53: Transfer completed: 1 messages, 13 records, 339 bytes, 0.005secs (67800 bytes/sec)

zone bigcloud.local/IN: sending notifies(serial 15)

测试

# nslookup

> server 192.168.188.16

Default server: 192.168.188.16

Address: 192.168.188.16#53

> test.bigcloud.local.

Server:         192.168.188.16

Address:        192.168.188.16#53

Name:  test.bigcloud.local

Address: 10.0.0.1

> exit

时间: 2024-10-12 22:03:55

CentOS 7 DNS部署的相关文章

Centos 使用dnsmasq部署DNS服务器

Centos 使用dnsmasq部署DNS服务器 一.默认情况下Centos已安装dnsmasq,如未安装,请自行安装. 12  yum install dnsmasq   13  yum install bind-utils 二.配置hosts文件,解析域名.   14  vim /etc/hosts #添加内容格式 172.17.100.26    ns1.xnnet.com 三.配置主配置文件.   19  vim /etc/dnsmasq.conf #配置在最后三行log-queries

CentOS 7 DNS服务器架设

CentOS 7 DNS服务器部署 项目背景和要求 要保证即能够解析内网域名linuxidc.local的解析,又能解析互联网的域名. 主DNS服务器:ZZYH1.LINUXIDC.LOCAL 辅助DNS服务器:ZZYH2.LINUXIDC.LOCAL 包含以下域的信息: 1.linuxidc.local域的信息: FQDN IP地址 备注 zzyh1.linuxidc.local 192.168.188.15 DNS1服务器 zzyh2.linuxidc.local 192.168.188.1

centos 6.5 部署openvpn服务器

centos 6.5 部署openvpn服务器一:协议原理OpenVpn的技术核心是虚拟网卡,其次是SSL协议实现,这里重点对虚拟网卡及其在OpenVpn的中的工作机理进行介绍. 虚拟网卡是使用网络底层编程技术实现的一个驱动软件, 安装后在主机上多出现一个网卡,可以像其它网卡一样进行配置.服务程序可以在应用层打开虚拟网卡,如果应用软件(如IE)向虚拟网卡发送数据,则服务程序可以读取到该数据,如果服务程序写合适的数据到虚拟网卡,应用软件也可以接收得到.虚拟网卡在很多的操作系统下都有相应的实现,这也

在CentOS 6.7部署wordpress博客系统Discuz论坛系统

在CentOS 6.7部署wordpress博客系统Discuz论坛系统 服务器操作系统:CentOS6.7 博客部署服务器:Httpd-2.2 后台语言:PHP 数据库:MySql 前端框架:WordPress 1.首先安装需要的软件 yum -y install mysql-server httpd phpphp-mysql 2.启动mysql以及httpd服务 service mysqld start service httpd start 3.创建虚拟主机 4.测试 PHP 和Httpd

Centos 7中部署LAMP

在Centos 7中部署LAMP(Linux,Apache,MariaDB,PHP) 说明:Centos 7中用MariaDB替换MySQL,但是PHP连接MariaDB还是使用的php-mysql模块. [来自维基百科]MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险.MariaDB的目的是完全兼容MySQL,包括API和命令行

centos 6.2 部署pptp服务器

一.系统环境说明 [[email protected] ~]# uname -a Linux cdit-00007b48 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16 00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux [[email protected] ~]# cat /etc/issue CentOS release 6.2 (Final)Kernel \r on an \m 二.系统环境检查,查看是

CentOS下dns服务器之授权

dns授权 dns授权分为两步 1]父域dns对子域dns实现授权, 2]子域对父域 1.改变根提示,把父域dns视为根 2.转发器 dns服务器的搭建请看dns服务器搭建 一.修改父域实现对子域的授权 修改dns服务器配置文件注释最后一行 [[email protected] chroot]# vim etc/named.conf options { listen-on port 53 { any; }; listen-on-v6 port 53 { ::1; }; directory    

DNS部署

一.DNS系统说明 目前后端系统的应用均采用硬IP的方式访问,虽然简单易辩,但是不利于系统的扩展和迁移.现搭建主备两台内网DNS服务器,建立严格的监控机制,以保证DNS的高可用性.DNS解析记录的修改和查看采用web界面形式,并通过管理员和guest用户分别控制权限. DNS系统采用最新的Bind-DLZ+mysql架构,解析记录存在mysql数据库表中.这样可以避免传统Bind的以下几个问题: 1.Bind解析记录存储在zone文件中,容易因编辑错误出现问题 2.Bind需要将解析数据加载到内

CentOS 6.5部署Apache+SVN

说明:运维朋友都知道,常常会配合开发人员搭建一些他们需要的环境,来提高开发工作效率,他们每天面对的无非就是代码,所以代码的可用性和管理性对 开发至关重要的,开发公司每接到一个项目就是一个团队来开发,这样多人同时对一些代码进行修改,会面临一些问题,比如:误删除,对同一文件修改发生冲突, 对某些人不让有所有权限,都会造成工作效率降低,要想解决这些问题就需要有一个专业的版本管理系统来集中管理这些代码,这样的版本管理系统很多,我们这次 使用的是SVN(subversion),是cvs接班人,是现在开源软