DNS服务器搭建方案
1.服务器硬件要求
1.1服务器配置要求
16核以上 32G以上 500G以上 1个千兆网卡
1.2服务器数量
2台服务器
2 操作系统要求
2.1 Linux 操作系统
64 位 Centos 7.3
2.2 操作系统分区要求
/boot 500M
swap 2G
/ 其余的所有磁盘空间
2.3 其他
不需要安装图形界面相关的东西,工具软件包默认的即可
语言选择English,时区选择Asia/Shanghai
若安装需选择类型,选择最小化安装
3.DNS服务器软件环境准备(M-S)
master-server 192.168.2.101
slave-server 192.168.2.102
# centos 7
#systemctl stop firewalld 关闭防火墙
#systemctl disable firewalld 关闭防火墙(开机不启动)
# setenforce 0 关闭selinux
# vi /etc/selinux/config
SELINUX=disabled
# yum install bind -y
4.DNS主配置文件(master)
# vim /etc/named.conf
options {
listen-on port 53 { 192.168.2.0/24; };
//listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { 192.168.2.0/24;192.168.3.0/24; };
};
...
# 配置区域解析文件
zone "nw.com" IN {
type master;
file "nw.com.zone";
notify yes;
also-notify {192.168.2.102; };
allow-transfer {192.168.2.102; };
};
5.制作区域解析文件(master)
# cp -p /var/named/named.localhost /var/named/nw.com.zone
# vim /var/named/nw.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
2018121601 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.nw.com.
dns A 127.0.0.1
www A 192.168.2.101
mail A 192.168.2.102
6.测试master配置文件的语法错误并启动服务
# named-checkconf
# named-checkzone nw.com /var/named/nw.com.zone
# systemctl start named
# systemctl enable named
7.DNS主配置文件(slave)
options {
listen-on port 53 { 192.168.2.0/24; };
//listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { 192.168.2.0/24;192.168.3.0/24; };
...
};
...
zone "nw.com" IN {
type slave;
masters { 192.168.2.101; };
file "slave/nw.com.zone";
};
8.测试slave配置文件的语法错误并启动服务
# named-checkconf
# systemctl start named
# systemctl enable named
9.应用服务器设置DNS服务器
# vim /etc/resolv.conf
...
nameserver 192.168.2.102
nameserver 192.168.2.101
10.测试
应用服务器测试
yum install bind-utils -y
# nslookup mail.nw.com
Server: 192.168.2.102
Address: 192.168.2.101#53
Name: mail.nw.com
Address: 192.168.2.102
# 当备用DNS服务器宕掉时,会选择master作为DNS服务器
# nslookup www.nw.com
Server: 192.168.2.102
Address: 192.168.2.101#53
Name: mail.nw.com
Address: 192.168.2.102