不知道从哪里开始,但最近我的 DNS 查找变得非常慢,总是 5 秒。运行后strace ping -c 1 google.com
我注意到第一次 DNS 查找总是超时:
poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [56]) = 0
recvfrom(5, "a\322\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\34\0\1\300\f\0\34"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [28->16]) = 56
>>>
>>> Timeout happens here
>>> poll([{fd=5, events=POLLIN}], 1, 4960
>>> ) = 0 (Timeout)
>>>
poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
sendto(5, "\361\226\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL, NULL, 0) = 28
poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [44]) = 0
recvfrom(5, "\361\226\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\1\0\1\300\f\0\1"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [28->16]) = 44
poll([{fd=5, events=POLLOUT}], 1, 4958) = 1 ([{fd=5, revents=POLLOUT}])
sendto(5, "a\322\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\34\0\1", 28, MSG_NOSIGNAL, NULL, 0) = 28
poll([{fd=5, events=POLLIN}], 1, 4958) = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [56]) = 0
recvfrom(5, "a\322\201\200\0\1\0\1\0\0\0\0\6google\3com\0\0\34\0\1\300\f\0\34"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [28->16]) = 56
close(5)
我读得strace
正确吗?这里可能发生什么?
运行 Fedora 25。
答案1
添加options single-request-reopen
到我/etc/resolv.conf
解决的问题!