当前位置:网站首页>ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通怎么解决?
ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通怎么解决?
2022-07-02 22:09:00 【洒满阳光的午后】
异常现象
ping域名报错unknown host,nslookup/systemd-resolve可以正常解析,ping公网地址通。
[email protected]:/etc# ping baidu.com
ping: unknown host baidu.com
[email protected]:/etc# nslookup www.baidu.com
Server: 192.168.61.200
Address: 192.168.61.200#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 183.232.231.174
Name: www.a.shifen.com
Address: 183.232.231.172
[email protected]:/etc# systemd-resolve www.baidu.com
www.baidu.com: 183.232.231.172
183.232.231.174
(www.a.shifen.com)
-- Information acquired via protocol DNS in 74.1ms.
-- Data is authenticated: no
[email protected]:/etc# ping 183.232.231.174
PING 183.232.231.174 (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174: icmp_seq=1 ttl=54 time=33.4 ms
64 bytes from 183.232.231.174: icmp_seq=2 ttl=54 time=32.7 ms
64 bytes from 183.232.231.174: icmp_seq=3 ttl=54 time=33.9 ms
64 bytes from 183.232.231.174: icmp_seq=4 ttl=54 time=45.0 ms
^C
--- 183.232.231.174 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3013ms
rtt min/avg/max/mdev = 32.723/36.281/45.043/5.077 ms需要检查的异常点
1、检查/etc/nsswitch.conf
[email protected]:~# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
gshadow: files
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis检查hosts行,是否为 files dns,files 表示使用 /etc/hosts 和 /etc/network 配置文件,dns 表示使用 /etc/resolv.conf文件中的DNS解析地址。
ping 程序解析域名依赖于C库中的函数 gethostbyname() 和 gethostbyaddr(),对应配置文件 /etc/nsswitch.conf 中的hosts 配置项。nslookup 是直接使用 /etc/resolv.conf 中的DNS解析域名,因此不受该文件影响。
2、检查/etc/resolv.conf文件权限
# Ubuntu系统
# Ubuntu系统中resolv.conf为一个软连接,如有问题,可以手动重建软连接ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf
# 重建完成后注意检查/etc/resolvconf/run/resolv.conf配置是否正确
[email protected]:~# ll /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Apr 26 16:20 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
# CentOS系统
[[email protected] ~]$ ll /etc/resolv.conf
-rw-r--r--. 1 root root 61 Nov 3 2021 /etc/resolv.conf如果resolv.conf文件无读权限,也会造成ping uknown host的情况。
边栏推荐
- LeetCode 968. Monitor binary tree
- [favorite poems] OK, song
- 首批 | 腾讯云完成国内首个云原生安全成熟度评估
- QT qsplitter splitter
- 【板栗糖GIS】arcscene—如何做出有高度的高程图
- Detailed explanation and application of merging and sorting
- Lc173. Binary search tree iterator
- Redis 过期策略+conf 记录
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- Hanging mirror security won four global infosec awards on rsac2022
猜你喜欢
随机推荐
泛型与反射,看这篇就够了
Golang's learning route
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
Jericho's thimble reaction when directly touching the prototype is abnormal [chapter]
WebRTC音视频采集和播放示例及MediaStream媒体流解析
Loss function~
力扣刷题(2022-6-28)
Redis 过期策略+conf 记录
海思3559万能平台搭建:在截获的YUV图像上旋转操作
Qt QProgressBar详解
数据标注典型案例,景联文科技如何助力企业搭建数据方案
How does Jerry test the wrong touch rate of keys [chapter]
中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
The kth largest element in the [leetcode] array [215]
P1007 single log bridge
LeetCode 968. Monitor binary tree
Brief introduction of emotional dialogue recognition and generation
Lambda表达式:一篇文章带你通透
静态文件显示问题






![[npuctf2020]ezlogin XPath injection](/img/6e/dac4dfa0970829775084bada740542.png)

![P7072 [CSP-J2020] 直播获奖](/img/bc/fcbc2b1b9595a3bd31d8577aba9b8b.png)
