基于Centos7.2的DNS服务器搭建
(2018-05-21 23:17:19)标签: | 分类: |
1.关闭防火墙以及SeLinux.
防火墙相关设置:
systemctl stop firewalld //临时关闭防火墙
systemctl disable firewalld //禁止开机启动防火墙
selinux相关设置:
SeLinux配置文件,/etc/selinux/config
设置 SELINUX=disabled
2.安装相应的软件包
yum -y install bind
yum -y install bind-utils //bind-utils提供DNS查询工具,如dig、host、nslookup
安装完后,检测有没有安装
[root ~]# 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.