基于Centos7.2的DNS服务器搭建

基于Centos7.2的DNS服务器搭建

  (2018-05-21 23:17:19)
标签: 

it

分类: Linux

1.关闭防火墙以及SeLinux.html

防火墙相关设置:linux

systemctl stop firewalld  //临时关闭防火墙服务器

systemctl disable firewalld  //禁止开机启动防火墙ide

selinux相关设置:工具

SeLinux配置文件,/etc/selinux/config测试

设置 SELINUX=disabledurl

 

2.安装相应的软件包spa

yum -y install bind.net

yum -y install bind-utils  //bind-utils提供DNS查询工具,如dig、host、nslookuprest

安装完后,检测有没有安装

[root@localhost ~]# rpm -qa | grep bind

rpcbind-0.2.0-42.el7.x86_64

bind-libs-9.9.4-61.el7.x86_64

bind-libs-lite-9.9.4-61.el7.x86_64

bind-license-9.9.4-61.el7.noarch

bind-9.9.4-61.el7.x86_64

 

bind-utils-9.9.4-61.el7.x86_64    //确保以上操做都没有错误进行下一步

3.修改配置文件

配置文件路径: /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.

//

// See the BIND Administrator's Reference Manual (ARM) for details about the

// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html

options {

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

};

 

zone "com" {

type master;

file "com";

};

 

zone "111.168.192.in-addr.arpa" {

type master;

file "111.168.192";

};

 

拷贝示例配置文件到tmp文件夹下

cp /usr/share/doc/bind-9.9.4/sample/etc/named.conf  /tmp         //红色的版本信息跟本身的相对应

 

4.重启服务

systemctl restart named

systemctl enable named   //开机启动DNS服务

客户端:

切换到NAT模式下:

yum -y install bind-utils

切换到OnlyHost模式下:

配置文件 :/etc/resolv.conf

添加以下:

 

nameserver 192.168.111.130(DNS IP地址)

5.正向解析文件配置实例:路径:/var/named/com

$TTL 86400

com. IN SOA dns.com. root.com (

20180511 ; serial

1H ; refresh

15M ; retry

1W ; expire

1D ) ; minimum

com. IN NS dns.com.

dns         IN A 192.168.111.130

linttle IN A 192.168.111.131

hello IN A 192.168.111.132

 

haha IN A 192.168.111.133

6.反向解析文实例:  路径:/var/named/111.168.192

$TTL 86400

@ IN SOA 111.168.192.in-addr.arpa. root.com (

20180511 ; serial

1H ; refresh

15M ; retry

1W ; expire

1D ) ; minimum

@ IN NS dns.com.

130 IN PTR dns.com.

131 IN PTR linttle.com.

132 IN PTR hello.com.

 

133 IN PTR haha.com.

7.测试
基于Centos7.2的DNS服务器搭建 分别可以正向和反向解析成功表明DNS服务器搭建成功。
相关文章
相关标签/搜索