基於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服務器搭建成功。
相關文章
相關標籤/搜索