DNS domain name service and common domestic DNS server addresses

DNS domain name service

DNS server classification

Cache name server

  1. Also known as cache server
  2. Obtain the domain name -> IP address record by querying other domain name servers
  3. Cache domain name query results locally to improve the speed of repeated queries

Primary domain name server

  1. The official server of a specific DNS zone, unique
  2. Responsible for maintaining the mapping records of all domain names -> IP addresses in the zone

From the domain name server

  1. Also known as secondary name server
  2. The domain name -> IP address record maintained by it comes from the main domain name server

Build DNS server

install software

[root@wpt ~]# yum install bind bind-chroot bind-utils -y

Profile introduction

使用BIND软件构建域名服务是,主要涉及两种类型的配置文件:主配置文件和区域数据文件。其中,主配置文件用于设置named服务的全局选项、注册区域及访问控制等各种运行参数;区域数据文件用于保存 DNS 解析记录的数据文件(正向或反向记录)。
BIND配置文件保存在两个位置:
/etc/named.conf BIND服务主配置文件
/var/named/ zone文件(域的dns信息)
如果安装了bind-chroot,BIND会被封装到一个伪根目录内,原先的文件配置文件的路径位置变为:
/var/named/chroot/etc/named.conf ----BIND服务主配置文件
/var/named/chroot/var/named/ ---------zone文件

Copy configuration related files


[root@wpt ~]# cp -rv /usr/share/doc/bind-9.11.4/sample/etc/* /var/named/chroot/etc/
[root@wpt ~]#  cp -rv /usr/share/doc/bind-9.11.4/sample/var/* /var/named/chroot/var/




bind-chroot安装好之后不会有预制的配置文件,但是在BIND的文档文件夹内(/usr/share/doc/bind-9.11.4),BIND为我们提供了配置文件模板,我们可以直接拷贝过来:
# 拷贝bind相关文件,准备 bind chroot 环境
cp -R /usr/share/doc/bind-*/sample/var/named/* /var/named/chroot/var/named/

# 将 /etc/named.conf 拷贝到 bind chroot目录
# -p 复制后目标文件保留源文件的属性 (包括所有者、所属组、权限和时间)
cp -p /etc/named.conf /var/named/chroot/etc/named.conf



# 在 bind chroot 的目录中创建相关文件
touch /var/named/chroot/var/named/data/cache_dump.db
touch /var/named/chroot/var/named/data/named_stats.txt
touch /var/named/chroot/var/named/data/named_mem_stats.txt
touch /var/named/chroot/var/named/data/named.run
mkdir /var/named/chroot/var/named/dynamic

# 修改文件属主和属组
chown -R named:named /var/named/chroot/var/named

# 启动服务
systemctl start named-chroot

Build a cache name server

Case Introduction

  • The IP address of the cache domain name server is 192.168.142.128.
  • ​ The PC in the LAN sets the preferred DNS server to 192.168.142.128.
  • The cache domain name server can access other DNS servers on the Internet.
  • ​ Responsible for processing DNS resolution requests from PCs on the LAN and caching the query results.

The basic steps:

​ 1. Establish the named.conf main configuration file, specify the resolution source through the root domain or forwarder mechanism;
2. Confirm to establish the named.ca root zone data file, if the forwarder mechanism is used, this step is not required;
​ 3. Start named Service;
4. Verify the cache domain name server;

Implementation plan

### 1.修改主配置文件
[root@wpt ~]# vim /var/named/chroot/etc/named.conf

# 指定数据文件的存放目录 默认无需修改
directory 	"/var/named";

# 指定服务器监听的地址和端口
listen-on port 53       {
    
     127.0.0.1; 192.168.142.128; };

# 指定允许内网网段地址主机可以查询授权区域数据
allow-query					{
    
     192.168.142.0/24; };

# 哪些主机查询非授权区域记录时,为其做递归
allow-query-cache       {
    
     192.168.142.0/24; };

# 开启递归 默认为开启
# 如果你要建立一个 授权域名服务器 服务器, 那么不要开启 recursion(递归) 功能。
# 如果你要建立一个 递归 DNS 服务器, 那么需要开启recursion 功能。
# 如果你的递归DNS服务器有公网IP地址, 你必须开启访问控制功能,
# 只有那些合法用户才可以发询问. 如果不这么做的话,那么你的服
# 服务就会受到DNS 放大攻击。实现BCP38将有效抵御这类攻击。
recursion yes;

########################使用转发器#################################
# 如果不使用根区域,也可以选择设置转发器,即可以指向另外一个DNS服务器。
# forward 可以是first,也可以是only
# forward first设置优先使用forwarders DNS服务器做域名解析,如果查询不到再使用本地DNS服务器做域名解析。
# forward only设置只使用forwarders DNS服务器做域名解析,如果查询不到则返回DNS客户端查询失败。

# 在 options{}; 中加入以下内容
# forward only;
# forwarders {8.8.8.8};
##################################################################

### 2. 配置根区域 这样服务器不知道域名记录时,就去找根DNS服务器 在区域文件目录中必须存在"/var/named/named.ca"这个文件,里面记录了根DNS服务器的地址(共13个)
cat /var/named/chroot/var/named/named.ca | grep -v '^;'|grep -v '^$'

### 3.检查配置文件语法
named-checkconf /var/named/chroot/etc/named.conf

### 180错误解决
dnssec-keygen -a HMAC-MD5 -b 128 -n HOST "test_key"
[root@localhost ~]# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST "test_key"
Ktest_key.+157+09104
[root@localhost ~]# cat Ktest_key.+157+09104.key
test_key. IN KEY 512 3 157 XkByzMnhtuSq4IItAzKb3w==
## 复制XkByzMnhtuSq4IItAzKb3w== 然后修改文件key 大概在180行左右

# 4 重启服务
systemctl restart named-chroot

##	测试前把双方的防火墙都关掉,或者在服务器端配置dns服务
[root@wpt ~]# firewall-cmd --add-service=dns
##	测试时把客户端的dns地址解析改为服务端的,文件在/etc/resolv.conf下 


###############################################################
##################客户端验证是否可以解析#########################
###############################################################
# 5 安装客户端命令行工具
yum install bind-utils

# 6 配置首选DNS为192.168.215.3
cp /etc/resolv.conf /etc/resolv.conf.bak
vim /etc/resolv.conf
# 修改以下内容
nameserver 192.168.215.3

# 7 解析域名
# 第一台客户端解析会慢一些,第二台客户端解析相同域名会很快,因为有了缓存。
nslookup www.baidu.com

#eg:
root@experiment2 ~# nslookup www.baidu.com
Server:		192.168.142.128
Address:	192.168.142.128#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 39.156.66.18
Name:	www.a.shifen.com
Address: 39.156.66.14

Build the main name server

Case Introduction

  • Responsible for the resolution of abc.com domain
  • Website server www.abc.com, IP address is 192.168.142.10
  • Mail server mail.abc.com, IP address is 192.168.142.20
  • Online video server video.abc.com, IP address is 192.168.142.30
  • The main domain name server ns1.abc.com, the IP address is 192.168.142.3
  • From the domain name server ns2.abc.com, the IP address is 192.168.142.5

The basic steps

  1. Confirm the local network address, host mapping, and default DNS server address.
  2. Create the main configuration file named.conf.
  3. Create forward and reverse zone data files.
  4. Start the named service or reload the configuration.
  5. Verify the primary domain name server.

Implementation plan

### 1 确认本机网络地址、主机映射、DNS服务器地址
# 为了提高域名解析效率,将两个DNS服务器的地址映射直接写入到/etc/hosts文件中
vim /etc/hosts
192.168.142.128	ns1.abc.com		ns1
192.168.142.6	ns2.abc.com		ns2

# 指定两个DNS服务器的地址为首选和备份DNS
vim /etc/resolv.conf

# 写入以下内容
# search 定义域名的搜索列表
nameserver 192.168.142.128
nameserver 192.168.142.6

### 2 修改主配置文件
vim /var/named/chroot/etc/named.conf
# 在 zone "." IN 前面加入以下内容

# 一个zone关键字定义一个域区

# type类型有三种,它们分别是master,slave和hint它们的含义分别是:
# master:表示定义的是主域名服务器
# slave [sleɪv]:表示定义的是辅助域名服务器
# hint [hɪnt]暗示:表示是互联网中根域名服务器

# file 指定具体存放DNS记录的文件

# allow-transfer [trænsˈfɜːr , ˈtrænsfɜːr]指定哪些主机可以从服务器上接收区域传输,未指定将允许传说到所有的主机
zone "abc.com" IN {
    
    
        type master;
        file "abc.com.zone";
        allow-transfer {
    
    192.168.142.6;};
};
# 定义一个IP为192.168.215.*的反向域区 
zone "142.168.192.in-addr.arpa" {
    
    
        type master;
        file "192.168.142.arpa.zone";
        allow-transfer {
    
    192.168.142.6;};
};

### 3 建立正向区域数据文件
cp -p /var/named/named.localhost /var/named/chroot/var/named/abc.com.zone
vim /var/named/chroot/var/named/abc.com.zone
# 修改以下内容
# “@”表示当前的DNS区域名,相当于“abc.com.”	
# $TTL(Time To Live,生存时间)记录
# SOA(Start Of Authority[əˈθɔːrəti],授权信息开始)记录
# 分号“;” 开始的部分表示注释信息
# NS 域名服务器(Name Server):记录当前区域的DNS服务器的主机地址
# MX 邮件交换(Mail  Exchange[ɪksˈtʃeɪndʒ]):记录当前区域的邮件服务器的主机地址,数字10表示优先级。
# A 地址(Address):记录正向解析条目,只用在正向解析区域中
# CNAME 别名(Canonical[kəˈnɑːnɪkl] Name):记录某一个正向解析条目的其他名称
# PTR   指针(Point)记录,只用在反向解析区域中
$TTL 1D
@       IN SOA  abc.com. admin.abc.com. (
                                2020112901      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN      NS      ns1.abc.com.
        IN      NS      ns2.abc.com.
                MX      10      mail.abc.com.
www     IN      A       192.168.142.10
mail    IN      A       192.168.142.20
video   IN      A       192.168.142.30
ns1     IN      A       192.168.142.128
ns2     IN      A       192.168.142.6
# 验证区域数据文件
# named-checkzone zonename filename
named-checkzone abc.com /var/named/chroot/var/named/abc.com.zone

### 4 建立反向区域数据文件
cd /var/named/chroot/var/named/
cp -p abc.com.zone 192.168.142.arpa.zone
vim 192.168.142.arpa.zone
$TTL 1D
@       IN SOA  abc.com. admin.abc.com. (
                                2020112901      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN      NS      ns1.abc.com.
        IN      NS      ns2.abc.com.
10      IN      PTR www.abc.com.
20      IN      PTR mail.abc.com.
30      IN      PTR study.abc.com.
128     IN      PTR ns1.abc.com.
6       IN      PTR ns2.abc.com.
# 验证区域数据文件
named-checkzone 215.168.192.in-addr.arpa 192.168.142.arpa.zone
# 5 重启服务
systemctl restart named-chroot


###############################################################
##################客户端验证是否可以解析#########################
###############################################################
[root@wpt named]# nslookup
> www.abc.com
Server:		192.168.142.128
Address:	192.168.142.128#53

Name:	www.abc.com
Address: 192.168.142.10
> mail.abc.com
Server:		192.168.142.128
Address:	192.168.142.128#53

Name:	mail.abc.com
Address: 192.168.142.20
> 192.168.142.30
30.142.168.192.in-addr.arpa	name = study.abc.com.

Build from a domain name server

In order to reduce the pressure on the primary domain name server, a secondary domain name server can be constructed, which can not only share the load, but also play a backup role.

The basic steps

  1. Confirm the local network address, host mapping, and default DNS server address.
  2. Create the main configuration file named.conf.
  3. Start the named service and check whether the area data file is downloaded successfully.
  4. Verify from the domain name server.

Implementation plan

# 1 安装
yum install bind bind-chroot bind-utils

# 2 启动服务
systemctl start named-chroot.service

# 3 确认本机网络地址、主机映射、DNS服务器地址
# 为了提高域名解析效率,将两个DNS服务器的地址映射直接写入到/etc/hosts文件中
vim /etc/hosts
192.168.142.128	ns1.abc.com		ns1
192.168.142.6	ns2.abc.com		ns2

# 指定两个DNS服务器的地址为首选和备份DNS
vim /etc/resolv.conf

# 写入以下内容
# search 定义域名的搜索列表
nameserver 192.168.142.128
nameserver 192.168.142.6

# 4 建立主配置文件
cd /var/named/chroot/
vim /etc/named.conf
# 修改如下配置
listen-on port 53	{
    
     127.0.0.1; 192.168.142.6; };
zone "abc.com" IN {
    
    
        type slave;
        file "slaves/abc.com.zone";
        masters {
    
    192.168.142.128;};
};
zone "142.168.192.in-addr.arpa" IN {
    
    
        type slave;
        file "slaves/192.168.142.arpa.zone";
        masters {
    
    192.168.142.128;};
};

# 5 关闭两个机器的防火墙
systemctl stop firewalld

# 6 重启服务
systemctl restart named-chroot

# 7 查看是否同步成功
ll /var/named/chroot/var/named/slaves/

-rw-r--r--. 1 named named 362 Nov 23 22:35 abc.com.zone
# 8 使用从域名服务器进行验证
root@experiment2 /v/n/chroot# nslookup
> www.abc.com
Server:		192.168.142.6
Address:	192.168.142.6#53

Name:	www.abc.com
Address: 192.168.142.20

Detailed nslookup command

###   nslookup命令详解
nslookup -qt=type domain [dns-server]

其中,type可以是以下这些类型:

A 地址记录
AAAA 地址记录
AFSDB Andrew文件系统数据库服务器记录
ATMA ATM地址记录
CNAME 别名记录
HINFO 硬件配置记录,包括CPU、操作系统信息
ISDN 域名对应的ISDN号码
MB 存放指定邮箱的服务器
MG 邮件组记录
MINFO 邮件组和邮箱的信息记录
MR 改名的邮箱记录
MX 邮件服务器记录
NS 名字服务器记录
PTR 反向记录
RP 负责人记录
RT 路由穿透记录
SRV TCP服务器信息记录
TXT 域名对应的文本信息
X25 域名对应的X.25地址记录
###例如
[root@localhost ~]# nslookup -qt=mx baidu.com 8.8.8.8

Commonly used DNS servers in China

114DNS

114DNS opens the curtain of the era of high-reliability DNS services. 114DNS began to provide the public with high-speed, stable and credible DNS recursive resolution services at the same time; to provide websites with powerful anti-attack capabilities and authoritative intelligent DNS resolution services; to provide reliable DNS disaster recovery and outsourcing services for ISPs, as the largest domestic user The veteran DNS, with fast access speed, has nodes in various regions, loads users of various operators, and DNS anti-hijacking capabilities are naturally among the best.
DNS server IP address:

  1. First choice : 114.114.114.114
  2. Alternative : 114.114.114.115

2017 Public DNS Server Address Evaluation-DNS Recommendation

DNSPod DNS

DNSPod was founded in March 2006. It is the largest third-party domain name service provider in China and ranked fourth in the world. DNSPod is the first website to provide free smart DNS products in China. It is committed to providing high-quality telecommunications, Netcom, and education networks with two-line or three-line smart DNS free resolution for various websites. As one of 114DNS competitors, whether it is access speed or Node coverage and anti-hijacking capabilities in all regions are top-notch.
DNS server IP address:

  1. First choice : 119.29.29.29
  2. Alternative : 182.254.116.116

2017 Public DNS Server Address Evaluation-DNS Recommendation

Ali DNS

Alibaba Public DNS is a DNS recursive resolution system launched by Alibaba Group. As the largest Internet basic service provider in China, Alibaba has inherited many years of excellent technology and provides excellent public DNS services to provide the most Internet users with the best Reliably provide "fast", "stable" and "smart" free DNS recursive resolution services for Internet users.
DNS server IP address:

  1. First choice : 223.5.5.5
  2. Alternative : 223.6.6.6

2017 Public DNS Server Address Evaluation-DNS Recommendation

Baidu DNS

Baidu Open DNS is mainly for enterprises, aiming to gather industry forces and jointly create the world's largest, stable, efficient, and pure public DNS platform in an open manner. As a core infrastructure to serve the entire Internet, Baidu DNS has a first-class foundation Facilities and strong technical strength provide users with free DNS services.
DNS server IP address:

  1. First choice : 180.76.76.76
  2. Alternative : Not yet announced

2017 Public DNS Server Address Evaluation-DNS Recommendation

CNNIC SDNS

SDNS has deployed multiple nodes around the world, providing intelligent and flexible platform support capabilities that can vary with user needs. Each node is built in the operator's 4A, 5A level computer room, each node is equipped with a server cluster, multi-line outlets, and mutual redundancy backup between nodes. Through multiple lines, to ensure that the global routing of each query is optimized, to the greatest extent possible for users to analyze nearby responses.
DNS server IP address:

  1. First choice : 1.2.4.8
  2. Alternative : 202.98.0.68

2017 Public DNS Server Address Evaluation-DNS Recommendation

DNS Pie

DNS Pie has the world's most advanced cloud DNS cluster technology, leading distributed cloud services, resolution servers all over the country, and years of professional research in the DNS field. DNS Pie has the world's most advanced cloud DNS cluster technology and leading distributed cloud services. Resolution servers all over the country can provide strong support for the authoritative resolution of domain names.
DNS server IP address:

  1. First choice : 101.226.4.6
  2. Alternative : 218.30.118.6

Attachment: Commonly used DNS servers abroad

  1. Google Public DNS (8.8.8.8, 8.8.4.4)
  2. OpenDNS (208.67.222.222, 208.67.220.220)
  3. OpenDNS Family (208.67.222.123, 208.67.220.123)
  4. DNS man(216.146.35.35 , 216.146.36.36)
  5. Comodo Secure (8.26.56.26, 8.20.247.20)
  6. UltraDNS(156.154.70.1 , 156.154.71.1)
  7. Norton ConnectSafe (199.85.126.10, 199.85.127.10)

Part of the content of this article is taken from: https://blog.csdn.net/weixin_49912759/article/details/110419273 and https://blog.csdn.net/weixin_43634280/article/details/84361024

Guess you like

Origin blog.csdn.net/KH_FC/article/details/111245572