当前位置:网站首页>DNS故障分析优化
DNS故障分析优化
2022-07-27 05:22:00 【小小小糖果人】
1、DNS解析失败
1.1 报connection timed out; no servers could be reached错误
[email protected]:/# nslookup time.geekbang.org
;; connection timed out; no servers could be reached
1.2 对网络进行排查,或者是使用 nslookup -debug www.baidu.com。结果发现网络是征程连接的,但是访问baidu这个网址取通过本机环回口取访问的,所以导致连接失败。
[email protected]:/# ping 114.114.114.114
PING 114.114.114.114 (114.114.114.114): 56 data bytes
64 bytes from 114.114.114.114: icmp_seq=0 ttl=127 time=29.275 ms
64 bytes from 114.114.114.114: icmp_seq=1 ttl=127 time=27.183 ms
^C--- 114.114.114.114 ping statistics [email protected]:/# nslookup -debug www.baidu.com
;; Connection to 127.0.0.1#53(127.0.0.1) for www.baidu.com failed: connection refused.
;; Connection to ::1#53(::1) for www.baidu.com failed: address not available.
1.3 查看Dns配置文件,发现内容为空。所以我们需要配置DNS服务
/# cat /etc/resolv.conf[email protected]:/# echo "nameserver 114.114.114.114 " > /etc/resolv.conf
[email protected]:/# nslookup www.baidu.com
Server: 114.114.114.114
Address: 114.114.114.114#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 14.215.177.39
Name: www.a.shifen.com
Address: 14.215.177.38
2、DNS解析不稳定
2.1 用time nslookup mp.csdn.net为例,来查看时延,可以看到real这一栏的时延有15S之久
[email protected]:~$ time nslookup mp.csdn.net
Server: 114.114.114.114
Address: 114.114.114.114#53
Non-authoritative answer:
Name: mp.csdn.net
Address: 101.201.178.55
real 0m15.099s
user 0m0.000s
sys 0m0.013s
2.2 如果多测试一下,会出现哪些现象呢,可能也会出现解析失败的现象
/# time nslookup mp.csdn.net
;; connection timed out; no servers could be reached
real 0m15.011s
user 0m0.006s
sys 0m0.006s2.3 对于上述出现的结果,可能会出现多种原因:
2.3.1 DNS服务器本身有问题,响应慢并且不稳定
2.3.2 客户端到DNS服务器的网络延迟比较大
2.3.3 DNS请求或者响应包,在某些情况下请求包被丢弃
2.4 根据不同的延时,我们可以更换不同的DNS,使用ping命令进行观测
[email protected]:~$ ping mp.csdn.net
PING mp.csdn.net (101.201.178.55) 56(84) bytes of data.
64 bytes from 101.201.178.55 (101.201.178.55): icmp_seq=1 ttl=128 time=38.4 ms
64 bytes from 101.201.178.55 (101.201.178.55): icmp_seq=2 ttl=128 time=34.5 ms
2.5 针对DNS解析时间过长的问题,可以为目标进行DNS缓存,使用dnsmasq
#该命令是在容器上执行
/# /etc/init.d/dnsmasq start
* Starting DNS forwarder and DHCP server dnsmasq [ OK ]2.6 修改/etc/resolv.conf,将DNS服务器改为DNSmasq的监听地址,本次用的是本机地址 114.114.114.114,然后多次执行nslookup命令
[email protected]:/# time nslookup mp.csdn.net
Server: 114.114.114.114
Address: 114.114.114.114#53
Non-authoritative answer:
Name: mp.csdn.net
Address: 101.201.178.55
real 0m0.115s
user 0m0.011s
sys 0m0.026s
2.7 可以看到执行多次以后,DNS解析都比较快。
2、DNS优化解决方法
2.1 对DNS解析结果进行缓存,但是要注意,缓存过期以后,需要重新获取新纪录,有经验的小伙伴可以写一个脚本,定期进行获取新记录。
2.2 对DNS解析的结果进行预取,这是浏览器等 Web 应用中最常用的方法,也就是说,不等用户点击页面上的超链接,浏览器就会在后台自动解析域名,并把结果缓存起来。
2.3 使用HTTPDNS取代常规的DNS解析,特别是如今域名劫持普遍存在,使用 HTTP 协议绕过链路中的 DNS 服务器,就可以避免域名劫持的问题
2.4 基于 DNS 的全局负载均衡(GSLB)。这不仅为服务提供了负载均衡和高可用的功能,还可以根据用户的位置,返回距离最近的 IP 地址。
本文整理自极客时间 倪朋飞:《Linux性能优化实战》
边栏推荐
- ROS通信机制进阶
- 5g network identity - detailed explanation of 5g Guti
- Briefly remember the top ten orders
- Unity engine starts to migrate from mono to.Net coreclr
- Communication mechanism cases
- Common SQL optimization methods
- OSG environment construction (win10+vs2019)
- wireshark图形界面介绍
- 接口测试流程及面试问题
- Dynamic programming for solving problems (7)
猜你喜欢

What is the difference between single line and three line when renting servers in Hong Kong?

Li Kou daily question leetcode 513. find the value in the lower left corner of the tree

Unityshader depth texture (understanding and problems encountered)

How to choose the correct server backup method

Index and transaction of database (emphasis)

允许或者禁止同时连接到一个non-domain和一个domain网络

Wireshark packet modification -- IP address modification (I)

Understand the pointer in a picture

ROM of IP core

Chapter for software testing
随机推荐
七大排序详解
数据库的联合查询
Three ways to get RPM packages using yum
Tangent space and TBN matrix
Non photorealistic rendering (NPR) paper understanding and reproduction (unity) - stylized highlights for cartoon rendering and animation
Brief introduction to unity menu interface
网络原理的简单认识
wireshark图形界面介绍
selenium知识点
Pycharm installation and import project considerations
Chapter for software testing
遥感影像识别-多类识别下的错分问题
TF坐标变换
Shell script if nested for loop script
Socket long link
Thesis writing (harvest)
数据库命令
Li Kou daily question (linked list simulation)
shell script if嵌套for循环脚本
Random points in non overlapping rectangle (force deduction daily question)